Skip to main content

A Python package for anomaly detection using various techniques.

Project description

Provides various methods for anomaly detection.
1. Traditional Statistical Methods:
- Boxplot Anomaly Detection: Identifies anomalies based on the interquartile range (IQR) method.
- Gaussian Anomaly Detection: Detects anomalies based on deviations from the mean using standard deviation.
- Grubbs Test: Identifies outliers using the Grubbs test.
- Dixon's Q Test: Identifies outliers using Dixon's Q test.
- Percentile Thresholding: Detects anomalies based on a specified percentile threshold.

2. Histogram-Based Methods:
- Histogram Anomaly Detection: Detects anomalies based on histogram peaks, indicating multimodal distributions.
- Histogram-Based Outlier Score: Identifies anomalies based on the density of data points in the histogram.

3. Model-Based Methods:
- Gaussian Mixture Model: Uses Gaussian mixture models to identify anomalies.
- Kernel Density Estimation: Estimates the probability density function of the data using kernel density estimation.
- Exponential Distribution: Detects anomalies based on extreme values using exponential distribution.

4. Nearest Neighbors and Clustering:
- K Nearest Neighbors (KNN): Identifies anomalies based on distances to nearest neighbors.
- Local Outlier Factor (LOF): Computes the local density deviation of a given data point with respect to its neighbors.
- Isolation Forest: Constructs an ensemble of isolation trees for anomaly detection.
- One-Class SVM: Identifies anomalies by separating data points from the origin in a high-dimensional space.

5. Clustering-Based Methods:
- KMeans: Uses KMeans clustering to identify anomalies based on centroid distances.
- DBSCAN: Density-based spatial clustering of applications with noise (DBSCAN) for anomaly detection.

6. Additional Techniques:
- Z-Score Anomaly Detection: Detects anomalies based on z-scores.
- Quantile Regression: Identifies anomalies based on quantiles of the data distribution.
- Anderson-Darling Test: A non-parametric test to assess whether a sample comes from a specified distribution.


Sample Usage

import numpy as np
from detect_anomalies_package.detect_anomalies import DetectAnomalies

# Sample data
data = np.random.normal(loc=0, scale=1, size=100)

# Initialize DetectAnomalies object
anomaly_detector = DetectAnomalies(data)

# Detect anomalies using various methods
anomalies = anomaly_detector.detect_anomalies()

# Print anomalies detected by each method
for method, result in anomalies.items():
if result[0] is not None:
print(f"Anomalies detected by {method}: {result[0]}")
else:
print(f"No anomalies detected by {method}: {result[1]}")

import pandas as pd

# Assuming df is your pandas DataFrame
data = df['column_name'].values # Replace 'column_name' with the actual column containing your data
anomaly_detector = DetectAnomalies(data)
anomalies = anomaly_detector.detect_anomalies()

import pandas as pd

# Assuming df is your pandas DataFrame
anomalies_by_column = {}

for column in df.columns:
data = df[column].values
anomaly_detector = DetectAnomalies(data)
anomalies = anomaly_detector.detect_anomalies()
anomalies_by_column[column] = anomalies

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

detect_anomalies_package-0.0.2.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

detect_anomalies_package-0.0.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file detect_anomalies_package-0.0.2.tar.gz.

File metadata

File hashes

Hashes for detect_anomalies_package-0.0.2.tar.gz
Algorithm Hash digest
SHA256 1cc539dcf4a1734f3f99fda73f3968a0e70d4be203a5cdd141cf6ec68ccfe46f
MD5 27af1775d1a0e619354889c78dbba083
BLAKE2b-256 0a462a5386987ac8788d794104ceabd9c6d900a1a6e504562ea7f29ef735beb5

See more details on using hashes here.

File details

Details for the file detect_anomalies_package-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for detect_anomalies_package-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 32bf41dc33cdd9094fd902e273aa1bf1fe17cc9adfd0bd003760b076ab023ec7
MD5 1cfe02574f52b23384a10f99131c5a01
BLAKE2b-256 26193da9c685a307939af6672f4ac7bc611d0b921b4db8f9c66fc761252dfd43

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page