knearest: The function to find n_clust nearest neighbors of each...

View source: R/knearest.R

knearestR Documentation

The function to find n_clust nearest neighbors of each instance, always removing the index of that instance if it is reported.

Description

The function will find n_clust nearest neighbors of each instance using Fast nearest neighbors (through KD-tree method) but will correct the result if it reports the index of that instance as its neighbors.

Usage

knearest(D, P, n_clust)

Arguments

D

a query data matrix.

P

an input data matrix

n_clust

the maximum number of nearest neighbors to search

Details

This function will perform K-nearest neighbor of instances in P on instances in P based on FNN. Then, it will verify if one of neighbors of each instance is itself then removes if it is.

Value

The index matrix of K nearest neighbour of each instance

Author(s)

Wacharasak Siriseriwan <wacharasak.s@gmail.com>

Examples

	data_example = sample_generator(10000,ratio = 0.80)
	P = data_example[data_example[,3]=="p",-3]
	N = data_example[data_example[,3]=="n",-3]
	D = rbind(P,N)
	knear = knearest(D,P,n_clust = 5)


smotefamily documentation built on May 29, 2024, 7:54 a.m.