Skip to main content

drift-detect

drift-detect is a Python package that helps detect distributional drift between two datasets.

It provides functionality for drift detection using univariate statistical tests for both numerical and categorical features. The package also tracks if the distribution of NULL values has changed. Multiple hypothesis testing is handled via Bonferroni and False Discovery Rate (FDR) corrections.

✅ Identify Which Features Have Drifted

drift-detect now also identifies which specific features (numerical or categorical) are statistically different across datasets — allowing for more targeted diagnostics and root-cause analysis of data drift.

📌 Key Features

🔍 Non-Parametric Univariate Statistical Tests:

  • Detects drift in numerical features using the Kolmogorov–Smirnov Test (KS Test)
  • Detects drift in categorical features using the Chi-squared Test of Independence
  • Detects changes in missingness using Fisher’s Exact Test

✅ Multiple Hypothesis Correction:

  • Bonferroni Correction: Controls the family-wise error rate by adjusting significance thresholds.
  • False Discovery Rate (FDR): Uses Benjamini–Hochberg procedure to control the proportion of false positives.

🧠 Feature-Level Drift Insights:

  • Returns a summary table of test statistics, p-values, and corrected p-values
  • Clearly indicates which features show significant distributional drift
  • Helps in interpreting what has changed, not just that something has

🚀 Installation

pip install drift-detect

Usage/Examples

import pandas as pd
from detectdrift import DetectDrift

# Create Sample Datasets
sample_size = 1000
categories = ['A', 'B', 'C']
probabilities = [0.5, 0.3, 0.2]  
data1 = pd.DataFrame({
            'numerical_feature': np.random.normal(0, 1, 1000), 
            'categorical_feature' :  np.random.choice(categories, size=sample_size, p=probabilities)
        })
data2 = pd.DataFrame({
    'numerical_feature': np.random.normal(0, 1, 1000),  
     'categorical_feature' :  np.random.choice(categories, size=sample_size, p=probabilities)
    })

# List columns to be tested
numerical_cols = ['numerical_feature']
categorical_cols = ['categorical_feature']

# Initialize DetectDrift with the data and feature columns
drift_detector = DetectDrift(data1, data2, numerical_cols, categorical_cols)

# Perform drift detection
drift_detected = drift_detector.detect_drift()

# Output the result
if drift_detected:
    print("Distribution Drift Detected!")
else:
    print("No Drift Detected.")

Metadata

Release files for drift-detect 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for drift-detect 0.1.2
File Size Uploaded Provenance
drift_detect-0.1.2.tar.gz 4.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for drift-detect 0.1.2
File Interpreter ABI Platform
drift_detect-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 10.4 kB

Release files / drift_detect-0.1.2.tar.gz

Download URL drift_detect-0.1.2.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7409ebca051ec36b59b1c7f994b73c8fe9dd789e521f1f172604fc2f8cd86efb
BLAKE2b-256 checksum
How to use checksums
cabcd0173ca1b92f720d24f3ead5e5e3ba488dc6081e1928d3cc48f9308ea890
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.16

Release files / drift_detect-0.1.2-py3-none-any.whl

Download URL drift_detect-0.1.2-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9f4b41a4328f8d55780b9bba7e02a3d6bfb9c253e16051f20a21f7f053af307
BLAKE2b-256 checksum
How to use checksums
323e0194c7ae92b3b23755a2b4086f11a6092a84d3d07ba9c44ed0e21acd71a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.16

Security for drift-detect 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page