knn_params: Class to specify the parameters for the knn selection

View source: R/knn_params.R

knn_paramsR Documentation

Class to specify the parameters for the knn selection

Description

knn_params() creates an object, which lets the user specify values for the weights, and the number of neighbors to use when selecting the nearest neighbor.

Usage

knn_params(k, weights)

Arguments

k

A single integer specifying the number of neighbors to select from.

weights

a vector with length equal to k, specifying the weights to apply to the 1-k neighbors before selecting the neighbor. The weights must sum to 1.

Examples

# uniformly select from the 5 nearest neighbors
knn_params(5, rep(1/5, 5))
# select from 4 neigbors, with decreasing likelihood of being selected
knn_params(4, c(.4, .3, .2, .1))
# select the nearest neighbor
knn_params(1, 1)


rabutler-usbr/knnstdisagg documentation built on Sept. 14, 2023, 2:47 p.m.