knitr::opts_chunk$set( collapse = TRUE, comment = "#>", warning = FALSE, message = FALSE, fig.width = 6, fig.height = 4, fig.align = "center" )
{outqrf} is an R package used for outlier detection. Each numeric variable is regressed onto all other variables using a quantile random forest [@Meinshausen]. We use {ranger} package [@wright] to perform the fitting and prediction of quantile regression forests. Next, we will compute the rank of the observed values in the predicted results' quantiles. If the rank of the observed value exceeds the threshold, the observed value is considered an outlier.
Since the same predicted value might be distributed across multiple quantiles in the predicted quantile results, this affects our location finding for the observed value. Therefore, we also used a method similar to the outForest package to compare the observed value with the 50% quantile value again to determine the final quantile result.
# Development version devtools::install_github("flystar233/outqrf")
library(outqrf) #Generate data with outliers in numeric columns irisWithOutliers <- generateOutliers(iris, p = 0.05,seed =2024) # Find outliers by quantile random forest regressions out <- outqrf(irisWithOutliers,quantiles_type=400) out$outliers
library(outqrf) irisWithOutliers <- generateOutliers(iris, p = 0.05,seed =2024) qrf <- outqrf(irisWithOutliers,quantiles_type=400) evaluateOutliers(iris,irisWithOutliers,qrf$outliers)
plot(qrf)
library(outqrf) irisWithOutliers <- generateOutliers(iris, p = 0.05,seed =2024) qrf <- outqrf(irisWithOutliers,quantiles_type=400) plot(qrf)
library(outqrf) library(ggplot2) library(dplyr) data <- diamonds|>select(price,carat,cut,color,clarity) data2 <- outqrf::generateOutliers(data, p = 0.001,seed =2024) # 108 qrf <- outqrf(data2,num.threads=8,quantiles_type=400) #The process can be slow because it needs to predict the value at 400|1000 quantiles for each observation. evaluateOutliers(data,data2,qrf$outliers)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.