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.1.tar.gz (33.7 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.1-py3-none-any.whl (37.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: driftimpact-1.0.1.tar.gz
  • Upload date:
  • Size: 33.7 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.1.tar.gz
Algorithm Hash digest
SHA256 888091f0a2ec362186db050a0d844cb4fa54d6b71a6db7f539d35f09829719f8
MD5 71b40a080ee4db190cd14cdbfbae1c03
BLAKE2b-256 22823e5ef7ffa50d18d04efa061eaf282944e5813ee4196e9008012ac436eafd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: driftimpact-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3cb05e21b251c14f453ad2208bec1e0b39a64de3b1e6ed7bafe52a507aabec01
MD5 e08fd9864c5016508b0f99f3a5b92581
BLAKE2b-256 f850945358b2d165cb9ca46472ac80703c6b8dd0f7ba4ad94c6af0caf20de175

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