Instant classifier


Instant Classifier Function

Function Signature

def instant_classifier(self, x_vals, y_vals, query_point, p=3, k=2):

Parameters

Return Value

Returns the classification result for the query_point based on the k nearest neighbors in the x_vals dataset.

Description

The instant_classifier function classifies a given query_point based on the k nearest neighbors in the x_vals dataset.  The labels of the k nearest neighbors are then used to determine the classification of the query_point.

Examples

from deeprai.models import KNN

# Sample data
x_vals = [[1, 2], [2, 3], [3, 4]]
y_vals = [0, 1, 0]
query_point = [2, 2]

# Create an instance of the classifier
classifier = KNN()

# Classify the query_point
result = classifier.instant_classifier(x_vals, y_vals, query_point, p=3, k=2)
print(result) # This will print the classification result for the query_point

Note: Ensure that y_vals is converted to int32 before passing it to the function.


Revision #1
Created 12 October 2023 04:35:25 by Kieran Carter
Updated 12 October 2023 04:50:56 by Kieran Carter