Skip to contents

Local outlier factor (Geron Ch 8, morie.fn hmlof)

Usage

morie_geron_local_outlier_factor_hmlof(
  X,
  n_neighbors = 20,
  contamination = NULL
)

Arguments

X

Data.

n_neighbors

Neighbourhood size k.

contamination

Optional outlier fraction.

Value

List with lof, lrd, k_distance, neighbors, is_outlier, estimate, n, method.

Examples

X <- matrix(c(1, 2, 3, 4), ncol = 1)
morie_geron_local_outlier_factor_hmlof(X, n_neighbors = 2)
#> $lof
#> [1] 1 1 1 1
#> 
#> $lrd
#> [1] 0.6666667 0.6666667 0.6666667 0.6666667
#> 
#> $k_distance
#> [1] 2 1 1 2
#> 
#> $neighbors
#>      [,1] [,2]
#> [1,]    2    3
#> [2,]    1    3
#> [3,]    2    4
#> [4,]    3    2
#> 
#> $is_outlier
#> [1] FALSE FALSE FALSE FALSE
#> 
#> $distances
#>      [,1] [,2] [,3] [,4]
#> [1,]  Inf    1    2    3
#> [2,]    1  Inf    1    2
#> [3,]    2    1  Inf    1
#> [4,]    3    2    1  Inf
#> 
#> $estimate
#> [1] 1
#> 
#> $n
#> [1] 4
#> 
#> $method
#> [1] "Local outlier factor"
#>