kneighbors_distance_docall: K-Nearest neighbors algorithm to compute an anomaly score

View source: R/Distance_matrix_knn_algorithm.R

kneighbors_distance_docallR Documentation

K-Nearest neighbors algorithm to compute an anomaly score

Description

The method obtain a distance matrix and find the K-nearest neighbors of each series and sum their distances in the neighborhood. The sum is defined as the anomaly score, the series with higher scores implies their neighbors are far away and such a series is a potential outlier

Usage

kneighbors_distance_docall(knn, distance, dparams)

Arguments

knn

number of nearest neighbors to consider for the anomaly score

distance

function name of the available distance matrices

dparams

a list with all the parameters for the distance matrix

Value

A list of two elements with the anomaly scores and the distance matrix

See Also

Guillermo Granados, and Idris Eckley. "Electricity Demand of Buildings Benchmarked via Regression Trees on Nearest Neighbors Anomaly Scores"

Examples

X=matrix( rnorm(2000), ncol=10  )
distance=distance_matrix_coherence
dparams=list(unit=X, span1=2, span2=2, period = 5 )
knn=5
kneighbors_distance_docall(knn,distance, dparams)

AnomalyScore documentation built on April 4, 2025, 3:13 a.m.