Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.6%) to scientific vocabulary
Keywords
Repository
Outlier detection based on random forest models
Basic Info
- Host: GitHub
- Owner: mayer79
- License: gpl-2.0
- Language: R
- Default Branch: main
- Homepage: https://mayer79.github.io/outForest/
- Size: 2.63 MB
Statistics
- Stars: 13
- Watchers: 2
- Forks: 2
- Open Issues: 1
- Releases: 5
Topics
Metadata Files
README.md
{outForest} 
Overview
{outForest} is a multivariate anomaly detection method. Each numeric variable is regressed onto all other variables using a random forest. If the scaled absolute difference between observed value and out-of-bag prediction is larger than a prespecified threshold, then a value is considered an outlier. After identification of outliers, they can be replaced, e.g., by predictive mean matching from the non-outliers.
The method can be viewed as a multivariate extension of a basic univariate outlier detection method, in which a value is considered an outlier if it deviates from the mean by more than, say, three times the standard deviation. In the multivariate case, instead of comparing a value with the overall mean, rather the difference to the conditional mean is considered. {outForest} estimates this conditional mean by a random forest.
Once the method is trained on a reference data set, it can be applied to new data.
Installation
```r
From CRAN
install.packages("outForest")
Development version
devtools::install_github("mayer79/outForest") ```
Usage
We first generate a data set with about 2% outliers values in each numeric column. Then, we try to identify them.
``` r library(outForest) set.seed(3)
Generate data with outliers in numeric columns
head(irisWithOutliers <- generateOutliers(iris, p = 0.02))
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
5.1 3.500000 1.4 0.2 setosa
4.9 3.000000 1.4 0.2 setosa
4.7 3.200000 1.3 0.2 setosa
4.6 3.100000 1.5 0.2 setosa
5.0 -3.744405 1.4 0.2 setosa
5.4 3.900000 1.7 0.4 setosa
Find outliers by random forest regressions and replace them by predictive mean matching
(out <- outForest(irisWithOutliers, allow_predictions = TRUE))
Plot the number of outliers per numeric variable
plot(out)
Information on outliers
head(outliers(out))
row col observed predicted rmse score threshold replacement
5 Sepal.Width -3.744405 3.298493 0.7810172 -9.017596 3 2.8
20 Sepal.Length 10.164017 5.141093 0.6750468 7.440852 3 5.4
138 Petal.Width 4.721186 2.113464 0.3712539 7.024092 3 2.1
68 Petal.Width -1.188913 1.305339 0.3712539 -6.718452 3 1.2
137 Sepal.Width 8.054524 2.861445 0.7810172 6.649122 3 2.9
15 Petal.Length 6.885277 1.875646 0.7767877 6.449163 3 1.3
Resulting data set with replaced outliers
head(Data(out))
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
5.1 3.5 1.4 0.2 setosa
4.9 3.0 1.4 0.2 setosa
4.7 3.2 1.3 0.2 setosa
4.6 3.1 1.5 0.2 setosa
5.0 2.8 1.4 0.2 setosa
5.4 3.9 1.7 0.4 setosa
Out-of-sample application
iris1 <- iris[1, ] iris1$Sepal.Length <- -1 pred <- predict(out, newdata = iris1)
Did we find the outlier?
outliers(pred)
row col observed predicted rmse score threshold replacement
1 Sepal.Length -1 4.960069 0.6750468 -8.82912 3 6.4
Fixed data
Data(pred)
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
6.4 3.5 1.4 0.2 setosa
```
Owner
- Name: Michael Mayer
- Login: mayer79
- Kind: user
- Repositories: 12
- Profile: https://github.com/mayer79
Responsible statistics | ML
GitHub Events
Total
- Issues event: 1
- Delete event: 1
- Push event: 3
- Pull request event: 2
- Create event: 1
Last Year
- Issues event: 1
- Delete event: 1
- Push event: 3
- Pull request event: 2
- Create event: 1
Issues and Pull Requests
Last synced: 7 months ago
All Time
- Total issues: 6
- Total pull requests: 11
- Average time to close issues: about 1 month
- Average time to close pull requests: about 10 hours
- Total issue authors: 3
- Total pull request authors: 1
- Average comments per issue: 3.5
- Average comments per pull request: 0.09
- Merged pull requests: 11
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 1
- Pull requests: 2
- Average time to close issues: N/A
- Average time to close pull requests: 17 minutes
- Issue authors: 1
- Pull request authors: 1
- Average comments per issue: 0.0
- Average comments per pull request: 0.0
- Merged pull requests: 2
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- mayer79 (4)
- fanavarro (1)
- Deleetdk (1)
Pull Request Authors
- mayer79 (13)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 183 last-month
- Total dependent packages: 0
- Total dependent repositories: 1
- Total versions: 6
- Total maintainers: 1
cran.r-project.org: outForest
Multivariate Outlier Detection and Replacement
- Homepage: https://github.com/mayer79/outForest
- Documentation: http://cran.r-project.org/web/packages/outForest/outForest.pdf
- License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
-
Latest release: 1.0.1
published almost 3 years ago
Rankings
Maintainers (1)
Dependencies
- R >= 3.5.0 depends
- FNN * imports
- graphics * imports
- missRanger >= 2.1.0 imports
- ranger * imports
- stats * imports
- dplyr * suggests
- knitr * suggests
- rmarkdown * suggests