knn_meanShift: K-d tree based k nearest neighbor search

Description Usage Arguments Value Examples

View source: R/knn.R

Description

knn_meanShift performs a search for the k nearest neighbors of a single point, where nearest is determined by the Mahalanobis distance. This search is performed through a k-d tree.

Usage

1
2
knn_meanShift(evalData, trainData, k = min(5, NROW(trainData)), weight,
  leafSize = 40, maxDist = Inf, transpose = FALSE)

Arguments

trainData

A matrix or vector of potential nearest neighbors.

k

A scalar indicating the number neighbors to find.

weight

A scalar or vector of length equal to the number of columns of trainData. This value is used as the diagonal elements for the inverse covariance matrix of the Mahalanobis distance.

leafSize

A scalar used to specify the number of points to store in the leaf nodes.

maxDist

A vector specifying the maximum value of the Mahalanobis that will be considered.

transpose

A boolean determining if you should query by columns instead of the default of rows (only for sparse matricies).

points

n vectors stored in an n by p matrix. k nearest neighbors are found for each vector.

Value

A list is returned containing two items: neighbors, an n by k matrix of k indexes for each of the n vectors in points, corresponding to the nearest neighbors in trainData. value, a matrix of scalars containing the k distances between the neighbors found in trainData and points.

Examples

1
2
x <- matrix(runif(20),10,2)
neighbors <- knn_meanShift(c(0,0),x)

jlisic/meanShiftR documentation built on Sept. 6, 2021, 8:27 p.m.