rarefun is an R package that provides a collection of functions for detecting and analyzing rare events in datasets. The package includes implementations of various anomaly detection methods and tools for spatial and temporal analysis of rare events.
Anomaly Detection Methods:
rare_residuals), including the following techniques:rare_iforest)rare_dbscan)Spatial Analysis:
match_spatial_points), including fast nearest neighbor searchStatistical Methods:
mcc), including bootstrap confidence intervalsgof_qr)partial_qrf)kneedle)You can install the development version of rarefun from GitHub:
# install.packages("devtools")
# devtools::install_github("vlyubchich/rarefun")
install.packages("rarefun", repos = c('https://vlyubchich.r-universe.dev', 'https://cloud.r-project.org'))
library(rarefun)
# Example: Detect anomalies using Isolation Forest
set.seed(123)
data <- matrix(rnorm(1000), nrow = 500)
data[1:5, ] <- data[1:5, ] + 10 # Add some outliers
result <- rare_iforest(data, ntrees = 100, threshold = 0.7)
table(result$is_anomaly)
Contributions are welcome! Please feel free to submit a Pull Request.
If you encounter any bugs or issues, please report them at: https://github.com/vlyubchich/rarefun/issues