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

Uploaded Python 3

File details

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

File metadata

  • Download URL: mini_causal-0.4.2.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.2.tar.gz
Algorithm Hash digest
SHA256 d43d448b0cb63e144254f7894755e7f0644ed1db967ba14acfb197f6df9b2136
MD5 3f019249944b8b3a76009c2a0db36bee
BLAKE2b-256 1afad6202b59d6c29b0994cbb767add39a11462911d1e88468b9547c85b1f55c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mini_causal-0.4.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 79fe68b2aa090c8887d8b403adcdce1af38fc2fefc716a82ea2721069d8419c5
MD5 3e747e7c518bdd96018534f5460a3f56
BLAKE2b-256 a0ddddaf94ec7ec7f1a1bca7507057269f04436f984c646188eba21622783c49

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