rikhuijzer / SIRUS.jl

Interpretable Machine Learning via Rule Extraction
https://sirus.jl.huijzer.xyz/
MIT License
30 stars 2 forks source link

Provide more intuitive `feature_importance` #77

Closed rikhuijzer closed 9 months ago

rikhuijzer commented 9 months ago

Given multiple models such as

StableRules model with 8 rules:
 if X[i, :nodes] < 7.0 then 0.238 else 0.046 +
 if X[i, :nodes] < 2.0 then 0.183 else 0.055 +
 if X[i, :age] ≥ 62.0 & X[i, :year] < 1959.0 then 0.0 else 0.001 +
 if X[i, :year] < 1959.0 & X[i, :nodes] ≥ 2.0 then 0.0 else 0.006 +
 if X[i, :nodes] ≥ 7.0 & X[i, :age] ≥ 62.0 then 0.0 else 0.008 +
 if X[i, :year] < 1959.0 & X[i, :nodes] ≥ 7.0 then 0.0 else 0.003 +
 if X[i, :year] ≥ 1966.0 & X[i, :age] < 42.0 then 0.0 else 0.008 +
 if X[i, :nodes] ≥ 7.0 & X[i, :age] ≥ 42.0 then 0.014 else 0.045
and 2 classes: [0, 1]. 
Note: showing only the probability for class 1 since class 0 has probability 1 - p.

It is currently unclear which variable has "significant" impact on predictive performance and which one not. The only thing that the current feature_importance provides is whether A has higher impact on B, but not whether A has a "significant" impact on the prediction.

To solve this, maybe add a function that determines the percentage that some feature affects the outcome? So basically feature_importance of some feature X as percentage of the sum of all feature_importances.

rikhuijzer commented 9 months ago

Maybe just a nice plot would work? This is from scikit learn:

image

rikhuijzer commented 9 months ago

Works well on my data and on the example here. Also easy to defend against sklearn and many others use the same method. Added an example to the plot in https://github.com/rikhuijzer/SIRUS.jl/commit/d3b879496d6a839ff28bdd43502de412ea3d40f3.