patpy.tl.predict_knn

Contents

patpy.tl.predict_knn#

patpy.tl.predict_knn(distances, y_true, n_neighbors=3, task='classification')#

Predict values of y_true using K-nearest neighbors

Parameters:
  • distances (square matrix) – Matrix of distances between samples

  • y_true (array-like) – Vector with the same length as distances containing values for prediction

  • n_neighbors (int (default: 3)) – Number of neighbors to use for prediction

  • task (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 target for samples with known values of y_true