Learn R Programming

fpmoutliers

R implementation of algorithms for detection of outliers based on frequent pattern mining.

If you would like to cite our work, please use:

@InProceedings{kuchar:2017:FPI,
  title =    {Spotlighting Anomalies using Frequent Patterns},
  author =   {Jaroslav Kuchař and Vojtěch Svátek},
  booktitle =    {Proceedings of the KDD 2017 Workshop on Anomaly Detection in Finance},
  year =   {2017},
  volume =   {71},
  series =   {Proceedings of Machine Learning Research},
  address =    {Halifax, Nova Scotia, Canada},
  month =    {14 Aug},
  publisher =    {PMLR},
  issn = {1938-7228}
}

Available implementations:

  • FPI, WFPI - Frequent Pattern Isolation, Weighted Frequent Pattern Isolation
    • J. Kuchar, V. Svatek: Spotlighting Anomalies using Frequent Patterns, Proceedings of the KDD 2017 Workshop on Anomaly

Detection in Finance, Halifax, Nova Scotia, Canada, PMLR, 2017. link

  • FPCOF - Frequent Pattern Contradiction Outlier Factor
    • X. Tang, G. Li and G. Chen, "Fast Detecting Outliers over Online Data Streams," 2009 International Conference on Information Engineering and Computer Science, Wuhan, 2009, pp. 1-4. link
  • FPOF - Frequent Pattern Outlier Factor
    • He, Z., Xu, X., Huang, J. Z., Deng, S.: FP-Outlier: Frequent Pattern Based Outlier Detection. Computer Science and Information Systems, Vol. 2, No. 1, 103-118. (2005). link
  • LFPOF - L. Frequent Pattern Outlier Factor
    • W. Zhang, J. Wu and J. Yu, "An Improved Method of Outlier Detection Based on Frequent Pattern," Information Engineering (ICIE), 2010 WASE International Conference on, Beidaihe, Hebei, 2010, pp. 3-6. link
  • MFPOF - Maximal Frequent Pattern Outlier Factor
    • Feng Lin, Wang Le, Jin Bo - Research on Maximal Frequent Pattern Outlier Factor for Online HighDimensional Time-Series Outlier Detection. Journal of Convergence Information Technology 5(10):66-71 · December 2010. link
  • WCFPOF - Weighted Closed Frequent Pattern Outlier Factor
    • Jiadong Ren, Qunhui Wu, Changzhen Hu, and Kunsheng Wang. 2009. An Approach for Analyzing Infrequent Software Faults Based on Outlier Detection. In Proceedings of the 2009 International Conference on Artificial Intelligence and Computational Intelligence - Volume 04 (AICI '09), Vol. 4. IEEE Computer Society, Washington, DC, USA, 302-306. link
  • WFPOF - Weighted Frequent Pattern Outlier Factor
    • ZHOU Xiao-Yun+, SUN Zhi-Hui, ZHANG Bai-Li, YANG Yi-Dong - A Fast Outlier Detection Algorithm for High Dimensional Categorical Data Streams. Journal of Software 18(4) · April 2007. link

Development Version Installation

Package installation from GitHub:

library("devtools")
devtools::install_github("jaroslav-kuchar/fpmoutliers")

Usage

Basic example

library(fpmoutliers)
dataFrame <- read.csv(system.file("extdata", "fp-outlier-customer-data.csv", package = "fpmoutliers"))
model <- FPI(dataFrame, minSupport = 0.001)
dataFrame <- dataFrame[order(model$scores, decreasing = TRUE),]
print(dataFrame[1,]) # instance with the highest anomaly score
print(dataFrame[nrow(dataFrame),]) # instance with the lowest anomaly score

Experimental explanations

Graphical explanation using bar plots

Currently not suitable for large datasets - the plot is limited by the number of rows and columns of the input data.

library("fpmoutliers")
dataFrame <- read.csv(
     system.file("extdata", "fp-outlier-customer-data.csv", package = "fpmoutliers"))
model <- FPI(dataFrame, minSupport = 0.001)
# sort data by the anomaly score
dataFrame <- dataFrame[order(model$scores, decreasing = TRUE),]
visualizeInstance(dataFrame, 1) # instance with the highest anomaly score
visualizeInstance(dataFrame, nrow(dataFrame)) # instance with the lowest anomaly score

Textual explanation

library("fpmoutliers")
dataFrame <- read.csv(
     system.file("extdata", "fp-outlier-customer-data.csv", package = "fpmoutliers"))
model <- FPI(dataFrame, minSupport = 0.001)
# sort data by the anomaly score
dataFrame <- dataFrame[order(model$scores, decreasing = TRUE),]
# instance with the highest anomaly score
out <- describeInstance(dataFrame, model, 1)
# instance with the lowest anomaly score
out <- describeInstance(dataFrame, model, nrow(dataFrame))

Other available functionalities

Experimental automatic build

library("fpmoutliers")
data("iris")
model <- fpmoutliers::build(iris)

Save the model to an experimental PMML format

  • Kuchar, Jaroslav et al. “Outlier (Anomaly) Detection Modelling in PMML.” RuleML+RR (2017).
library(fpmoutliers)
library(XML)
dataFrame <- read.csv(system.file("extdata", "fp-outlier-customer-data.csv", package = "fpmoutliers"))
model <- FPI(dataFrame, minSupport = 0.001)
saveXML(generatePMML(model, dataFrame), "example_out.xml")

Model Output

All implemented methods return a list with following parameters:

  • minSupport - minimum support setting for frequent itemsets mining
  • maxlen - maximum length of frequent itemsets
  • model - frequent itemset model represented as itemsets-class
  • scores - outlier/anomaly scores for each observation/row of the input dataframe

Contributors

Licence

Apache License Version 2.0

Copy Link

Version

Install

install.packages('fpmoutliers')

Monthly Downloads

4

Version

0.1.0

License

Apache License (== 2.0) | file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Jaroslav Kuchar

Last Published

November 22nd, 2017

Functions in fpmoutliers (0.1.0)

LFPOF

LFPOF algorithm
WFPOF

WFPOF algorithm
MFPOF

MFPOF algorithm
build

Automatic build of the anomaly detection model
WCFPOF

WCFPOF algorithm
FPOF

FPOF - Frequent Pattern Outlier Factor algorithm
WFPI

WFPI - Weighted Frequent Pattern Isolation algorithm
FPOFcontradictness

Frequent Pattern Outlier Factor
describeInstance

Explain the instance/outlier by a brief textual summary
FPCOF

FPCOF algorithm
generatePMML

PMML conversion - PMML representation of outliers
parsePMML

PMML parser
FPI

FPI - Frequent Pattern Isolation algorithm
visualizeInstance

Visualization of a data instance using a set of barplots
plotRestrictedBarplot

Plot of a restricted barplot with a highlighted selected value