patpy.tl.predict_knn#
- patpy.tl.predict_knn(distances, y_true, n_neighbors=3, task='classification')#
Predict values of
y_trueusing K-nearest neighbors- Parameters:
distances (square matrix) – Matrix of distances between samples
y_true (array-like) – Vector with the same length as
distancescontaining values for predictionn_neighbors (
int(default:3)) – Number of neighbors to use for predictiontask (
Literal['classification','regression','ranking'] (default:'classification')) – Type of prediction task: - classification: predict class labels - regression: predict continuous values - ranking: predict ranks of the values. Currently, formulated as a regression task
- Returns:
y_predicted : array-like Predicted values of
targetfor samples with known values ofy_true