A library for finding influential instances in ML models
Project description
Influential Analysis
📌 Overview
Influential Analysis is a Python library for identifying and analyzing influential instances in machine learning models. It helps assess model accuracy and fairness by detecting data points that significantly impact predictions. This is especially useful for bias detection and fairness auditing.
🔥 Features
- Identify influential instances that impact model fairness & accuracy
- Supports classification models (e.g., Decision Trees, Random Forests, etc.)
- Uses Fairlearn for fairness assessment
- Provides visualization of influential data points
📦 Installation
Install the package using:
pip install influential-analysis
🚀 Usage
1. Import the Library
!pip install influential-analysis==0.1.1
from influential_analysis.influential_analysis import InfluentialInstanceAnalyzer
2. Train Your Model
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
import pandas as pd
# Load Data
df = pd.read_csv("your_dataset.csv")
X = df.drop(columns=["target_column"])
y = df["target_column"]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Train Model
model = DecisionTreeClassifier()
model.fit(X_train, y_train)
3. Analyze Influential Instances
sensitive_features = ["gender", "race"] # Adjust based on dataset
analyzer = InfluentialInstanceAnalyzer(model, sensitive_features, deletion_percentage=10)
# Run analysis
analyzer.fit(X_train, y_train, X_test, y_test)
influential_instances, scores, acc_changes, fairness_changes = analyzer.run_analysis(showGraph=True)
4. Remove Influential Instances & Retrain
X_filtered = X.drop(index=influential_instances, errors='ignore')
y_filtered = y.drop(index=influential_instances, errors='ignore')
X_train_f, X_test_f, y_train_f, y_test_f = train_test_split(X_filtered, y_filtered, test_size=0.2, random_state=42)
model.fit(X_train_f, y_train_f)
📊 Visualization
The library supports visualizing influential instances using Seaborn:
analyzer.run_analysis(showGraph=True)
🛠 Dependencies
- NumPy
- Pandas
- Seaborn
- Matplotlib
- Scikit-learn
- Fairlearn
📝 License
This project is licensed under the MIT License.
🤝 Contributing
Contributions are welcome! Feel free to submit issues or pull requests on GitHub.
📧 Contact
Author: Blazhe Manev
GitHub: BlazheManev
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file influential_analysis-0.1.2.tar.gz.
File metadata
- Download URL: influential_analysis-0.1.2.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a740bed910e59e4778585ad874de82ec5ed55828addca4b9503442ed4000336f
|
|
| MD5 |
8f3dad4394a9e81fa0d8fb2c28f5039a
|
|
| BLAKE2b-256 |
6fc003cda3476bac680137b616e34397506a69cd2a1e24ad894b66d4fb437668
|
File details
Details for the file influential_analysis-0.1.2-py3-none-any.whl.
File metadata
- Download URL: influential_analysis-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
279fe7751fe6ac508c5bc10599f9706500c0aa28552b6323ff491d40e56a8a7b
|
|
| MD5 |
d8ed25167fcc49e6f01d34160daa4914
|
|
| BLAKE2b-256 |
09ddf50de9e4f1d70f46a52b4ca8aac14eb873990c0e2c5c6e5ce177e6df5280
|