NOF: Natural Outlier Factor (NOF) algorithm

Description Usage Arguments Details Value Author(s) References Examples

Description

Function to calculate the Natural Outlier Factor (NOF) as an outlier score for observations. Suggested by Huang, J., Zhu, Q., Yang, L. & Feng, J. (2015)

Usage

1
NOF(dataset)

Arguments

dataset

The dataset for which observations have a NOF score returned

Details

NOF computes the nearest and reverse nearest neighborhood for observations, based on the natural neighborhood algorithm. Density is compared between observations and their neighbors. A kd-tree is used for kNN computation, using the kNN() function from the 'dbscan' package

Value

nb

A vector of in-degrees for observations

max_nb

Maximum in-degree observations in nb vector. Used as k-parameter in outlier detection of NOF

r

The natural neighbor eigenvalue

NOF

A vector of Natural Outlier Factor scores. The greater the NOF, the greater the outlierness

Author(s)

Jacob H. Madsen

References

Huang, J., Zhu, Q., Yang, L. & Feng, J. (2015). A non-parameter outlier detection algorithm based on Natural Neighbor. Knowledge-Based Systems. pp. 71-77. DOI: 10.1016/j.knosys.2015.10.014

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Select dataset
X <- iris[,1:4]

# Run NOF algorithm
outlier_score <- NOF(dataset=X)$NOF

# Sort and find index for most outlying observations
names(outlier_score) <- 1:nrow(X)
sort(outlier_score, decreasing = TRUE)

# Inspect the distribution of outlier scores
hist(outlier_score)

Example output

[1] "r is now: 2"
[1] "r is now: 3"
[1] "r is now: 4"
[1] "r is now: 5"
       42       127       144        64        55       113        28        90 
1.4568285 1.4551820 1.4432004 1.4098590 1.3595976 1.3496025 1.2933804 1.2905440 
      103        49       121       125        50        54        16        92 
1.2851906 1.2559298 1.2285780 1.2245882 1.2014043 1.1989356 1.1833303 1.1804482 
       83       100       107        79        60        40        20        23 
1.1689806 1.1686685 1.1670581 1.1511226 1.1496940 1.1482661 1.1434154 1.1405675 
      128        11        31       130       134        14        22       126 
1.1299069 1.1257786 1.1228356 1.1197920 1.1167399 1.1123065 1.1069851 1.1054310 
      117         8        18        80        46       138        99         1 
1.1050226 1.1031811 1.1005091 1.0985946 1.0957836 1.0826964 1.0820748 1.0776876 
       70       110         4        15        47        65        97        98 
1.0759488 1.0673490 1.0671666 1.0662943 1.0660229 1.0638617 1.0618035 1.0542436 
      119        52        61        48       116        95       124         7 
1.0528559 1.0523064 1.0462963 1.0462287 1.0458299 1.0454587 1.0443777 1.0353810 
       13       118        84        45       108       131        58        81 
1.0341143 1.0323089 1.0321768 1.0302485 1.0298309 1.0278494 1.0262681 1.0221270 
       75        33         2       132        51        30         3        37 
1.0203894 1.0168846 1.0108023 1.0035592 1.0034935 1.0026185 0.9987692 0.9971942 
      141        94        82       140        67       112       150         6 
0.9938880 0.9905895 0.9896148 0.9872519 0.9847001 0.9792127 0.9790012 0.9759951 
       12       114       148       135       123       133       102       143 
0.9759724 0.9742069 0.9703938 0.9678542 0.9666205 0.9649938 0.9536860 0.9536860 
      115        34        53       122       139       111        35        69 
0.9536113 0.9516014 0.9515444 0.9431567 0.9403054 0.9388869 0.9369747 0.9364066 
      147         9       149        24        59        43        57        19 
0.9347949 0.9329888 0.9328275 0.9324095 0.9273387 0.9247231 0.9244330 0.9232432 
       88       105        39       120        32        71        77       106 
0.9191701 0.9178905 0.9175899 0.9166021 0.9140269 0.9092829 0.9075090 0.9064312 
        5        27       109        72        78        25       129       101 
0.9037674 0.9013173 0.9005028 0.8992171 0.8965279 0.8922238 0.8902182 0.8900310 
      145        85        66        26        68        17        93        87 
0.8872306 0.8864447 0.8829103 0.8822318 0.8819857 0.8797700 0.8767640 0.8751420 
       41       136        56        73        89        96        63       146 
0.8739759 0.8675204 0.8623359 0.8596633 0.8523845 0.8520418 0.8509993 0.8462226 
       29        74        62        76        91        44        21        38 
0.8440434 0.8424309 0.8375984 0.8330724 0.8193339 0.8027794 0.7874575 0.7865786 
       86       104        10       137       142        36 
0.7811683 0.7773199 0.7687574 0.7658661 0.7514867 0.7202985 

DDoutlier documentation built on May 1, 2019, 10:20 p.m.