Concept

fit(X_train, y_train) for sklearn.neighbors.KNeighborsClassifier

After splitting the data and creating the knn classifier object, we can use the fit method, which trains ("fits") the model using the training data. This is necessary so that the classifier can predict the labels of test data. Note that X_train is a dataframe of items and their features, whereas y_train is a series of corresponding true labels.

0

1

Updated 2020-10-19

Tags

Data Science