Skip to main content

A Python library for identifying and handling outliers

Project description

🧰 Outlier Toolkit 🛠️

A standalone Python library for detecting, handling, and transforming outliers in numeric and categorical data.
No external dependencies required.


📜 License

This project is licensed under the Apache License 2.0. See the LICENSE file for more details.

License


📊 Features

1. Outlier Detection

  • Z-score Detection: Identify extreme values based on standard deviation.
  • IQR Detection: Detect outliers using the interquartile range (Q1, Q3).

2. Outlier Handling Techniques

  • Remove Outliers: Drop outlier values from datasets.
  • Replace Outliers: Replace outliers with mean, median, or most frequent values.

3. Winsorization

  • Standard Winsorization: Cap extreme values at a fixed percentile.
  • Adaptive Quartiles: Replace low/high outliers using Q1 and Q3.
  • Adaptive Inliers: Replace low/high outliers using nearest inlier values (custom method).

4. Binning

  • Equal Width Binning: Divide numeric range into equal-width intervals.
  • Equal Frequency Binning: Divide data so each bin has approximately the same number of values.
  • Auto Binning (Outlier-based): Automatically separate low/high outliers and inliers using IQR.

🔧 Installation

pip install outlier-toolkit

No external libraries required. Compatible with Python 3.7+.


🧮 Usage


from outlier.i_outlier.Zscore import detect_outliers_zscore
from outlier.i_outlier.IQR import detect_outliers_iqr
from outlier.outlierTech.remove import remove_outliers
from outlier.outlierTech.replace import replace_outliers
from outlier.outlierTech.winsorization.standard import winsorize_standard
from outlier.outlierTech.winsorization.adaptive import winsorize_quartiles
from outlier.outlierTech.winsorization.adaptive import winsorize_inliers
from outlier.outlierGroup.binning import eq_width_bin
from outlier.outlierGroup.binning import eq_freq_bin
from outlier.outlierGroup.binning import custom_binning



# Sample Test data
numeric_data = [1, 2, 85, 95, 65, 75, 53, 67, 87, 89, 93, 1001, 1027, 3018]
categorical_data = ["Male", "Female", "Male", "Male", "Unknown", "Unknown", "Other"]

#Detection
print("=== Zscore Detection ===")
print(detect_outliers_zscore(numeric_data))

print("\n=== IQR Detection ===")
print(detect_outliers_iqr(numeric_data))

#Handling
print("\n=== Remove Outliers ===")
print(remove_outliers(numeric_data, method="IQR"))

print("\n=== Replace Outliers (auto-detect) ===")
print(replace_outliers(numeric_data, method="IQR"))
print(replace_outliers(categorical_data, method="IQR"))

#Winsorization
print("\n=== Winsorization (Standard 5%) ===")
print(winsorize_standard(numeric_data[:]))

print("\n=== Winsorization (Adaptive Quartiles) ===")
print(winsorize_quartiles(numeric_data[:]))

print("\n=== Winsorization (Adaptive Inliers) ===")
print(winsorize_inliers(numeric_data[:]))

#Binning
print("\n=== Binning (Equal Width Binning) ===")
print(eq_width_bin(numeric_data[:]))

print("\n=== Binning (Equal Width Binning) ===")
print(eq_freq_bin(numeric_data[:]))

print("\n=== Binning (Equal Width Binning) ===")
print(custom_binning(numeric_data[:]))

📝 Notes

  • Works for numeric and categorical data.
  • All functions are standalone and do not require external libraries.
  • Custom winsorization allows mapping outliers to nearest inliers for more controlled transformations.

👩‍💻 Author

Irene Betsy D


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

outlier_toolkit-0.1.3.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

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

outlier_toolkit-0.1.3-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file outlier_toolkit-0.1.3.tar.gz.

File metadata

  • Download URL: outlier_toolkit-0.1.3.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.4

File hashes

Hashes for outlier_toolkit-0.1.3.tar.gz
Algorithm Hash digest
SHA256 fc3a8c1a3c5a37024c07b4671f44d24a548bcdeb610c0f8de436b9b04b1ef992
MD5 a8313e7cf314f1eee8203e3b7311dc2c
BLAKE2b-256 0c6fb366ddbc280e2114b80c61b15539950ce7ae7b7f5ac71bb0520484f3fcb8

See more details on using hashes here.

File details

Details for the file outlier_toolkit-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for outlier_toolkit-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 16be88334b1e0f535295451443ba5c385d679edc68b3855132b5694d797fc8f1
MD5 8cd85992ba1cd4ba8a1e42d1ce7e9171
BLAKE2b-256 f71519b9aba6948dc886f574ce35dbe0415d635863cac12725ebb9f834821f03

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