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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file detect_anomalies_package-0.0.2.tar.gz.
File metadata
- Download URL: detect_anomalies_package-0.0.2.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cc539dcf4a1734f3f99fda73f3968a0e70d4be203a5cdd141cf6ec68ccfe46f
|
|
| MD5 |
27af1775d1a0e619354889c78dbba083
|
|
| BLAKE2b-256 |
0a462a5386987ac8788d794104ceabd9c6d900a1a6e504562ea7f29ef735beb5
|
File details
Details for the file detect_anomalies_package-0.0.2-py3-none-any.whl.
File metadata
- Download URL: detect_anomalies_package-0.0.2-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32bf41dc33cdd9094fd902e273aa1bf1fe17cc9adfd0bd003760b076ab023ec7
|
|
| MD5 |
1cfe02574f52b23384a10f99131c5a01
|
|
| BLAKE2b-256 |
26193da9c685a307939af6672f4ac7bc611d0b921b4db8f9c66fc761252dfd43
|