predict_knn: K-Nearest Neighbor Predictions

Description Usage Arguments Value

View source: R/neighbors.R

Description

Make predictions on a data point x_query based on the k-nearest neighbors in the dataset X. Predictions are made by averaging the Y values of the k-neighest neighbors.

Usage

1
predict_knn(X, Y, x_query, k, dist_func = mydist, ...)

Arguments

X

dataset of shape [n_samples, n_features]

Y

target vector of shape [n_samples]

x_query

vector of shape [n_features] to make predictions on.

k

number of nearest neighbors to use for predictions.

dist_func

function used to calculate the distance between two points.

...

These arguments are passed into dist_func.

Value

A single prediction for x_query.


joshloyal/STAT542 documentation built on May 4, 2019, 1:08 p.m.