cpath
Explaining black-box models through counterfactual paths and conditional permutations
Science Score: 23.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
✓Academic publication links
Links to: arxiv.org -
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.0%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Explaining black-box models through counterfactual paths and conditional permutations
Basic Info
- Host: GitHub
- Owner: pievos101
- License: mit
- Language: R
- Default Branch: main
- Homepage: https://arxiv.org/abs/2307.07764
- Size: 1.23 MB
Statistics
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
- Releases: 0
Topics
Metadata Files
README.md
cpath
Explaining and visualizing black-box models through counterfactual paths
Paper: https://arxiv.org/abs/2307.07764.
Software documentation: https://github.com/pievos101/cpath/blob/main/cpath_documentation.pdf.
Installation
The {cpath} R-package can be installed using {devtools}.
```r install.packages("devtools") library(devtools)
devtools::install_github("pievos101/cpath") library(cpath)
```
Usage
Lets apply {cpath} on a random forest model.
```r library(caret) library(cpath)
Generate simulated data
res = sim() data = res$data target = as.factor(res$target)
Train-test split
80% of the sample size
smp_size <- floor(0.80 * nrow(data))
trainind <- sample(seqlen(nrow(data)), size = smp_size)
train <- data[trainind, ] test <- data[-trainind, ]
targettrain = as.factor(target[trainind]) targettest = as.factor(target[-trainind])
TRAIN = as.data.frame(cbind(train, targettrain)) TRAIN$targettrain = as.factor(TRAIN$target_train)
10 folds repeat 3 times
control <- trainControl(method='repeatedcv', number=10, repeats=3)
Metric compare model is Accuracy
metric <- "Accuracy" set.seed(123)
Number randomly variable selected is mtry
mtry <- sqrt(ncol(train)) tunegrid <- expand.grid(.mtry=mtry) model <- train(target_train~., data=TRAIN, method='rf', metric='Accuracy', tuneGrid=tunegrid, trControl=control) print(model)
Get the counterfactual paths
P = cpath::cpaths(model, test, k=4, n_paths = 1000)
P = cpath::cpathsmc(model, test, k=4, npaths = 1000) #multi-core
Build transition matrix
T = cpath::transition(P)
Get global feature importances
IMP = cpath::importance(T) print(IMP)
Get summary of the counterfactual paths
cpathsummary = getcpath_summary(P)
Plot the paths
plotpaths(cpathsummary)
```
Citation
If you find {cpath} useful please cite our paper:
@article{pfeifer2023explaining,
title = {Explaining and visualizing black-box models through counterfactual paths},
author = {Bastian Pfeifer and Mateusz Krzyzinski and Hubert Baniecki and
Anna Saranti and Andreas Holzinger and Przemyslaw Biecek},
year = {2023},
journal = {arXiv preprint, arXiv:2307.07764}
}
Owner
- Name: Bastian Pfeifer
- Login: pievos101
- Kind: user
- Location: Graz, Austria
- Company: Medical University of Graz
- Repositories: 18
- Profile: https://github.com/pievos101
Bioinformatics, Machine Learning
GitHub Events
Total
- Push event: 20
Last Year
- Push event: 20
Committers
Last synced: over 2 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| pievos101 | b****r@g****m | 66 |
| krzyzinskim | m****i@w****l | 12 |
| Bastian Pfeifer | 3****1 | 7 |
| Hubert Baniecki | h****i@g****m | 6 |
Committer Domains (Top 20 + Academic)
Packages
- Total packages: 1
-
Total downloads:
- pypi 18 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 2
- Total maintainers: 1
pypi.org: cpath
Explainable AI with counterfactual paths
- Homepage: https://github.com/pievos101/cpath
- Documentation: https://cpath.readthedocs.io/
- License: MIT
-
Latest release: 0.0.1
published over 2 years ago