scikit-learn-contrib / hiclass

A python library for hierarchical classification compatible with scikit-learn
BSD 3-Clause "New" or "Revised" License
113 stars 20 forks source link

Explainer API for Local Classifier per parent node #minor #106

Closed ashishpatel16 closed 5 months ago

ashishpatel16 commented 6 months ago

Hi @mirand863, this PR aims to present the first iteration of the LCPPN explainer class that enables the calculation of Shapley values for explaining predictions.

codecov-commenter commented 6 months ago

Codecov Report

Attention: Patch coverage is 94.16058% with 8 lines in your changes are missing coverage. Please review.

Project coverage is 96.56%. Comparing base (c7979b2) to head (3c93a98). Report is 1 commits behind head on main.

Files Patch % Lines
hiclass/Explainer.py 90.58% 8 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #106 +/- ## ========================================== - Coverage 96.86% 96.56% -0.31% ========================================== Files 11 12 +1 Lines 1086 1222 +136 ========================================== + Hits 1052 1180 +128 - Misses 34 42 +8 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

ashishpatel16 commented 6 months ago

Here you can find a Colab notebook to test the api using a dummy hierarchical dataset!

mirand863 commented 6 months ago

Here you can find a Colab notebook to test the api using a dummy hierarchical dataset!

@ashishpatel16 the notebook is not working anymore. Can you please update it?

mirand863 commented 6 months ago

Codecov Report

Attention: 66 lines in your changes are missing coverage. Please review.

Comparison is base (c7979b2) 96.86% compared to head (9658c4a) 91.58%.

Files Patch % Lines hiclass/Explainer.py 21.68% 65 Missing ⚠️ hiclass/LocalClassifierPerParentNode.py 94.11% 1 Missing ⚠️ Additional details and impacted files

☔ View full report in Codecov by Sentry. 📢 Have feedback on the report? Share it here.

@ashishpatel16 The test coverage is lower because shap and xarray are not being installed in the github actions. Can you please add them there? It would be nice to keep test coverage high if possible.

mirand863 commented 6 months ago

@ashishpatel16 it would be great to have some documentation so the user can understand how the explainer works, how to use it and what is the expected output. For example, here we explain how the local classifier per node works https://hiclass.readthedocs.io/en/latest/algorithms/local_classifier_per_node.html and in the gallery of examples we show how to use the library https://hiclass.readthedocs.io/en/latest/auto_examples/plot_pipeline.html#sphx-glr-auto-examples-plot-pipeline-py. I guess in this PR you can already include some documentation about the explainer for the local classifier per parent node and an example in the gallery on how to use it, showing expected input, output and perhaps how to interpret it.

ashishpatel16 commented 5 months ago

Hi @mirand863, this PR addresses following changes -