Skip to main content

A comprehensive library for data and concept drift detection with performance impact analysis

Project description

DriftImpact Library

DriftImpact Banner

A comprehensive Python library for detecting Data Drift and Concept Drift, and analyzing their impact on Model Performance.

🧠 Methodology

The library analyzes changes in datasets across three main layers:

1. Data Drift

Compares feature distributions between training data (Train) and scoring data (Score).

  • Numerical Variables: Uses KS Test for distribution differences, Mann-Whitney U for central tendency shifts, and Levene Test for variance changes.
  • Categorical Variables: Frequency distribution changes are measured using the Chi-Square test.
  • P-Value Standardization: All test results are standardized according to the selected threshold. Metrics with detected drift are reported in red, and those without in green.

2. Concept Drift

Analyzes how the relationship between features and the target variable changes over time.

  • Fisher Z-Test: Detects significant changes in the correlation of numerical features with the target variable.
  • Cramer's V: Measures changes in the strength of association between categorical features and the target variable.
  • Temporal Analysis: Finds the point where the relationship begins to deteriorate (First Drift Point) by dividing data into time windows.

3. Performance Impact Analysis

Analyzes whether drift is just a statistical deviation or if it actually degrades model performance.

  • Calculates a "Weighted Drift Score" using model feature importances.
  • Compares the drift score with model performance metrics (Accuracy, F1, RMSE, etc.) across time periods.
  • Visualizes whether performance drops as drift increases, helping you determine the right time for intervention.

✨ Key Features

  • Interactive HTML Report: A modern dashboard with drag-and-drop support and modal zooming.
  • P-Value Color Coding: Immediate visual feedback based on drift status.
  • Automated Dashboards: Detailed visual analyses and summary tables with a single command.
  • Flexible Integration: Works directly with scikit-learn compatible models.

🚀 Installation

To install the library locally:

pip install .

🛠 Usage

1. Full Drift Analysis and Reporting

from driftimpact import DriftAnalyzer
import pandas as pd

# Initialize Analyzer
analyzer = DriftAnalyzer(target_col='churn', threshold=0.05)

# Load data
train_df = pd.read_csv('train.csv')
score_df = pd.read_csv('score.csv')

# Run all analyses (Data Drift + Concept Drift + Temporal)
results = analyzer.full_analysis(train_df, score_df, time_col='date')

# Create Interactive HTML Report
analyzer.generate_html_report(results, save_dir='./reports')

2. Model Performance Impact Analysis

To measure your model's resilience against drift:

# Run analysis by providing the model, score data, and actual labels
impact_df = analyzer.analyze_performance_impact(
    model=my_trained_model,
    score_df=score_df,        # Features + Time column
    y_true=score_df['label'], # Realized labels
    time_col='date',
    drift_results=results.get('temporal_drift')
)

# Visualize the relationship between Drift and Performance
analyzer.visualize_performance_impact(impact_df, metric_name='accuracy', save_dir='./reports')

📁 Project Structure

  • driftimpact/: Core library code.
  • reports/: Generated HTML reports and PNG charts.
  • test.py: Testing the entire flow using an example Churn model.

📄 License

MIT License

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

driftimpact-1.0.0.tar.gz (33.6 kB view details)

Uploaded Source

Built Distribution

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

driftimpact-1.0.0-py3-none-any.whl (37.3 kB view details)

Uploaded Python 3

File details

Details for the file driftimpact-1.0.0.tar.gz.

File metadata

  • Download URL: driftimpact-1.0.0.tar.gz
  • Upload date:
  • Size: 33.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for driftimpact-1.0.0.tar.gz
Algorithm Hash digest
SHA256 14929917a9478eb4d9ca8856932d9cf976815ef8ae9a45f315347f5e62ba6007
MD5 6f7dc0aeb376436ee7313af9a9a1ddbc
BLAKE2b-256 3b3b934d8d86bdcf9322d0fc8dce66a307fd320cd77e865d96fdc8e882fe3d9d

See more details on using hashes here.

File details

Details for the file driftimpact-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: driftimpact-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 37.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for driftimpact-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93fb67623680fe4e39a45da3b5308b4b4a16b07ff5ae284483c6b070a26ced6d
MD5 1faebfe1e03c2781b452eef1ef0ab4eb
BLAKE2b-256 5d9d9876136ae355d60e9881aa5fda9bc65c223bf86e53caad1d6865f200bb0e

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