Store Data in KNN

Storing Values in KNN Classifier

Function Signature

def store_vals(self, x_values, y_values, p=3, k=2):

Parameters

Return Value

This function does not return anything. It modifies the KNN instance by storing the provided values.

Description

The store_vals function stores the provided data points, labels, power parameter, and number of neighbors in the KNN classifier instance. This allows for the classifier to use these values in subsequent classification tasks without needing them to be provided again.

Examples

from deeprai.models import KNN

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

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

# Store the values in the classifier
classifier.store_vals(x_vals, y_vals, p=3, k=2)

Note: Ensure that y_vals is converted to int32 before storing.


Revision #1
Created 12 October 2023 04:52:10 by Kieran Carter
Updated 12 October 2023 04:53:59 by Kieran Carter