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

Uploaded Python 3

File details

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

File metadata

  • Download URL: outlier_toolkit-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 b42a6367fd8a3887a9453d420ef7c90785a6432bbeaa63c1a4691ea5fea74a06
MD5 e48fd3db00076e05c325c17d65d414b0
BLAKE2b-256 273cd25768799218a44c254b15b26fcaae974e61a7e49b4e196d724e8226be1e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for outlier_toolkit-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e5437b82ba896cece5a014fb0db1ca8688348b4d5df981383fbcb1ef96dc01c4
MD5 3ba183d4fcb1b1e2f9c4bdfdefa8fee8
BLAKE2b-256 df31e703806a308cc0794f0e2246ad1340e085bf7c70c588111caa3f52223b49

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