ModelOriented / treeshap

Compute SHAP values for your tree-based models using the TreeSHAP algorithm
https://modeloriented.github.io/treeshap/
GNU General Public License v3.0
78 stars 23 forks source link

Feature: ranger_surv.unify(type = "survival") #24

Closed kapsner closed 1 year ago

kapsner commented 1 year ago

Hello @pbiecek,

I am currently trying to add a functionality to treeshap that allows to compute SHAP values depending on the survival time. My goal is to provide SHAP values computed with treeshap that allow to be further used with the survex R package in order to compute SurvSHAP(t) values, as the current computation using kernelshap seems to be rather slow for ranger (https://github.com/ModelOriented/survex/blob/main/R/surv_shap.R#L148).

The current state of implementation is located here in my fork: https://github.com/kapsner/treeshap/commit/ead7d157fc901e79f330ab5e6b78e7d42d431f59

Before I open a PR here, I want to make sure that there are no major issues.

At one of the unit tests, I encountered some irregularities when comparing "unified" to "original" predictions: https://github.com/kapsner/treeshap/blob/master/tests/testthat/test_ranger_surv.R#L142

Somehow, the difference between unified and original predictions increases with greater death_times, leading to a failing of the original comparison (expect_true(all(abs((from_unified - original) / original) < 10**(-14)))).

Does that somehow make sense? If this seems errorneous, would you have an idea, where the error might be located?

Thanks a lot in advance. Best, Lorenz

kapsner commented 1 year ago

I guess this can be closed as #26 has already been merged.