RDOS: Relative Density-based Outlier Factor (RDOS) algorithm with...

Description Usage Arguments Details Value Author(s) References Examples

Description

Function to calculate the Relative Density-based Outlier Factor (RDOS) as an outlier score for observations. Suggested by Tang, B. & Haibo, He. (2017)

Usage

1
RDOS(dataset, k = 5, h = 1)

Arguments

dataset

The dataset for which observations have an RDOS score returned

k

The number of k-nearest neighbors used to identify reverse- and shared nearest neighbors

h

Bandwidth parameter for gaussian kernel. A small h put more weight on outlying observations

Details

RDOS computes a kernel density estimation by combining the nearest, reverse nearest and shared neighbors into one neighborhood. The density estimation is compared to the density estimation of the neighborhoods observations. A gaussian kernel is used for density estimation, given a bandwidth chosen by user. A kd-tree is used for kNN computation, using the kNN() function from the 'dbscan' package.

It is a computational heavy task to identify reverse and shared neighbors from the kd-tree. Thus, the RDOS has high complexity and is not recommended to apply to datasets with n>5000. The RDOS function is useful for outlier detection in clustering and other multidimensional domains

Value

A vector of RDOS scores for observations. The greater the RDOS score, the greater outlierness

Author(s)

Jacob H. Madsen

References

Tang, B. & Haibo, He. (2017). A local density-based approach for outlier detection. Neurocomputing. pp. 171-180. DOI: 10.1016/j.neucom.2017.02.039

Examples

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

# Find outliers by setting an optional k
outlier_score <- RDOS(dataset=X, k=10, h=2)

# 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

       42       119       118        16        99       132       107        61 
1.0711021 1.0594706 1.0580209 1.0576669 1.0560756 1.0553498 1.0487719 1.0433803 
       15        58        94        14       123        34        51        23 
1.0425563 1.0410011 1.0367939 1.0299695 1.0283306 1.0276240 1.0270002 1.0260075 
      135       115        19       110        69       120       136       101 
1.0248511 1.0244808 1.0229130 1.0228483 1.0221214 1.0202821 1.0200353 1.0200283 
       88        33        53        63       114       122       109         9 
1.0166664 1.0160661 1.0155115 1.0154652 1.0147675 1.0139661 1.0134688 1.0130341 
       45       130       108       106        85        86        25        80 
1.0128128 1.0125493 1.0118916 1.0118318 1.0111651 1.0104893 1.0099293 1.0097329 
       39       149        43       131         6        17        66       142 
1.0096808 1.0091447 1.0089834 1.0085274 1.0077130 1.0069320 1.0066106 1.0060040 
      137        37        77        65        44       126        21        24 
1.0059647 1.0057365 1.0053992 1.0039930 1.0037563 1.0037508 1.0031490 1.0028608 
       60        71       102       143        67        32        57        76 
1.0013029 1.0012725 1.0003854 1.0003854 1.0002577 0.9994267 0.9984395 0.9983923 
       26        87        75       147       150        91        59         7 
0.9980817 0.9978192 0.9976248 0.9969856 0.9969496 0.9969204 0.9968459 0.9966953 
       82       104        72        13        46        73        52       145 
0.9965310 0.9962148 0.9959700 0.9958870 0.9956670 0.9956056 0.9955549 0.9952223 
       36        74        54        38       146        78         3         4 
0.9951884 0.9951210 0.9951027 0.9948534 0.9946119 0.9946049 0.9945426 0.9943292 
       48         2        47       116        11        30        41        84 
0.9938555 0.9934694 0.9929901 0.9929643 0.9926185 0.9925350 0.9918979 0.9917623 
       56        27        98        31       111        62        20        55 
0.9917351 0.9917144 0.9917075 0.9915556 0.9914622 0.9913834 0.9913473 0.9910863 
       89        81        10       138        68       133        96       134 
0.9910551 0.9909887 0.9907075 0.9905368 0.9903740 0.9902332 0.9897657 0.9897329 
      103        22        29        49       139       140        12         5 
0.9891981 0.9891206 0.9890863 0.9888819 0.9888142 0.9886927 0.9885966 0.9885135 
      129       112        35       128        40       117       124        92 
0.9884573 0.9884134 0.9882994 0.9877622 0.9871519 0.9870640 0.9866947 0.9864767 
       18         1       105        64       148         8       144        83 
0.9862796 0.9862676 0.9861708 0.9861484 0.9860954 0.9857582 0.9857210 0.9854193 
       28        50        79       127        70       141       125        90 
0.9853093 0.9852234 0.9851754 0.9850626 0.9849541 0.9845427 0.9845389 0.9842594 
       97        93        95       121       100       113 
0.9838671 0.9837982 0.9837040 0.9835548 0.9824903 0.9808320 

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