giuseppec / giuseppec/iml

Feature - Display distance from actual predicted observation on ICE plots

Open
#186 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
R
Stars
503
Forks
87
PR merge metrics
No merged PRs in 30d

Description

It would be nice to have option(s) that highlight the specific location of a point for an individual curve when plotting ICE. The downside with `geom_rug()` in this case is can't trace an observation to an individual curve.

### Add points to ICE plots

Coudl use `geom_point()` instead to see where the actual point is for each curve on the plot. For example, I think it would be nice if setting `show.data = TRUE` (when method = "ice") would do this. E.g.

```r
library("mlr")
library("ggplot2")
# data(cervical)
cervical <- readr::read_csv("https://raw.githubusercontent.com/christophM/interpretable-ml-book/master/data/cervical.csv")
set.seed(43)
cervical_subset_index = sample(1:nrow(cervical), size = 300)
cervical_subset = cervical[cervical_subset_index, ]
cervical.task = makeClassifTask(data = cervical, target = "Biopsy")
mod = mlr::train(mlr::makeLearner(cl = 'classif.randomForest', id = 'cervical-rf', predict.type = 'prob'), cervical.task)
pred.cervical = Predictor$new(mod, cervical_subset, class = "Cancer")
FeatureEffect$new(pred.cervical, "Age", method = "ice")$plot(show.data = TRUE)
```

(Partial inspiration comes from 14:37 of [Model Agnostic Interpretability by Ricky Tharrington](https://youtu.be/5ZAms6UaUjk?t=877).)

### Adjust alpha of plots

An alternative approach would be to have an additional option that changed the alpha (e.g. `adj_alpha`) depending on how far a line was from the actual value of an observation, e.g. so that each line would appear fainter the further it is away from the actual value for an observation (as you slide away from location of point line appears fainter).

An advantage with this approach (over adding points) is that it wouldn't clog-up the chart with a bunch of points in cases there are many lines, but would still get across for each one where it is more or less trust worthy. This also might produce a somewhat nice aggregate effect (however figuring-out most appropriate way to modulate alpha may be non-trivial... but even a decent heuristic may be helpful).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.