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_library

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.0.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.0.3-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: outlier_toolkit-0.0.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.0.3.tar.gz
Algorithm Hash digest
SHA256 fb8b2030203f80ed045351b5894cfe5d3583d7d862dfab40068ca4ab3b69bfa2
MD5 bbeb5155ac6c1b53bb7aa07f3397ac9f
BLAKE2b-256 71beb0e0131f002993fd65672f2856803c2464411c8f19e008e5a99f6f9e0dc5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for outlier_toolkit-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 40df182e3480799b5da35a4126242f899d0407300f37d03fb62b9a2e6af0a987
MD5 e53095474159a6230a8fd01f317765e1
BLAKE2b-256 35a1408efe7ea4ad8aa1037dc573e3a134340c5775a9560160d1b2a8e892be3d

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