Learn R Programming

quickOutlier (version 0.1.0)

detect_density: Detect Density-Based Anomalies (LOF)

Description

Uses the Local Outlier Factor (LOF) algorithm to identify anomalies based on local density. It is useful for detecting outliers in multi-dimensional data that Z-score misses.

Usage

detect_density(data, k = 5, threshold = 1.5)

Value

A data frame with the outliers and their LOF score.

Arguments

data

A data frame (only numeric columns will be used).

k

Integer. The number of neighbors to consider. Defaults to 5.

threshold

Numeric. The LOF score cutoff. Values > 1 indicate potential outliers. Defaults to 1.5.

Examples

Run this code
df <- data.frame(x = c(rnorm(50), 5), y = c(rnorm(50), 5))
detect_density(df, k = 5)

Run the code above in your browser using DataLab