Skip to main content

A machine learning decision intelligence framework that helps practitioners understand how feature changes influence model behavior, performance and business decisions

Project description

Mini-Causal

logo

Mini-Causal is machine learning decision intelligence framework that helps practitioners understand how feature changes influence model behavior, performance, and business decisions.

Key features

  • Causality tools: compare models using causal metrics and tests.
  • Counterfactuals: generate and evaluate counterfactual explanations.
  • Partial counterfactuals: run targeted counterfactual analyses on subsets of features.
  • Batteries of examples: runnable Jupyter notebooks demonstrating common workflows.

Getting Started with mini-causal in a notebook

  • Create and activate a virtual environment (PowerShell example):
python -m venv .venv
.\.venv\Scripts\Activate.ps1
  • Install the package:
pip install mini-causal

**Quick after you loaded the data with X and y sets:

import pandas as pd
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from mini_causal.partial_counter import PartialCounterfactualClassifier

X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.2,random_state=42)

model=LogisticRegression(solver="liblinear")
model.fit(X_train,y_train)

counter_classifier=PartialCounterfactualClassifier(model=model,X=X_train,y=y_train)

## get the individual causal effects:
ind_causal_effect_age=counter_classifier.individual_causal_effects(X=X_train,feature="age")

##accuracy effect by the exclusion of the feature
age_acc_effect=counter_classifier.causal_effect_metric(X=X_train,
                                                       y=y_train,
                                                       metric="accuracy",
                                                       feature="age")

## recall effect
age_recall_effect=counter_classifier.causal_effect_metric(X=X_train,
                                                          y=y_train,
                                                          metric="recall",
                                                           feature="age")

##log-loss effect
age_log_loss_eff=counter_classifier.causal_effect_probs_metric(X=X_train,
                                                               y=y_train,
                                                               metric="log-loss",
                                                               feature="age")

## hamming-loss effect
age_hamming_loss_eff=counter_classifier.causal_effect_loss_metricX_train,y_train,metric="hamming-loss",feature="age")


## true negative effect
age_tn_effect=counter_classifier.causal_effect_confusion(X_train,y_train,metric="tn",
                                                                feature="age")

##true positive effect
age_tp_effect=counter_classifier.causal_effect_confusion(X_train,y_train,metric="tp",
                                                                feature="age")

##summarized tabular dataframe
tab_metrics_df=counter_classifier.causal_effect_metric_tab(X_train,
                                                           y_train,
                                                           feature="age"
)

Examples

This folder contains runnable Jupyter notebooks demonstrating mini_causal features.

Notebooks included

  • mini_causal_partial_regression — demonstrates the library in a regression workflow.
  • mini_causal_partial_classification — demonstrates the library in a classification workflow.

Citing mini-causal

If you use mini-causal in your research, please cite it:

@software{mini-causal,
  title = {mini-causal: A Decision Intelligence Framework for machine learning},
  author = {Masemene Matlakana Benny},
  year = {2026},
  url = {https://github.com/MasemeneMatlakanaBenny/Mini-Causal},
  doi = {10.5281/zenodo.19646175},
  license = {MIT},
}

See CITATION.cff for the full citation metadata.

Contributing

See CONTRIBUTING.md for guidelines on reporting issues, opening pull requests, code style, and testing.

License

This project is released under the terms of the 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

mini_causal-0.4.21.tar.gz (47.5 kB view details)

Uploaded Source

Built Distribution

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

mini_causal-0.4.21-py3-none-any.whl (39.4 kB view details)

Uploaded Python 3

File details

Details for the file mini_causal-0.4.21.tar.gz.

File metadata

  • Download URL: mini_causal-0.4.21.tar.gz
  • Upload date:
  • Size: 47.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mini_causal-0.4.21.tar.gz
Algorithm Hash digest
SHA256 42a99d09457516a6dec1a23c748aba837f953f89d10ba77019c2cc66ebaca89b
MD5 80f5a3ea3d90a44c1c8f64de3fc6dbe5
BLAKE2b-256 fc0d322a62b354484bb0ac7b72e28d3d1c0ddcae8b6beb61602894adef055687

See more details on using hashes here.

File details

Details for the file mini_causal-0.4.21-py3-none-any.whl.

File metadata

  • Download URL: mini_causal-0.4.21-py3-none-any.whl
  • Upload date:
  • Size: 39.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mini_causal-0.4.21-py3-none-any.whl
Algorithm Hash digest
SHA256 cd2d45bf8982e0d337aaae9167f10fcca21bbc94d9a4b49adca59eddc2b4a4ad
MD5 a7319f49c932443e8ca0279753f87ee3
BLAKE2b-256 8a5d5b0d9ff5b3c664ccab3493792c65fc9b81ec92ff59dbd08afab347e1cfeb

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