Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LIME example numpy - pandas conversion #57

Merged
merged 2 commits into from
Jul 10, 2024

Conversation

FrancescMartiEscofetQC
Copy link
Contributor

@FrancescMartiEscofetQC FrancescMartiEscofetQC commented Jul 9, 2024

This PR fixes an error in the LIME example in case the SLearner was used. Inside the SLearner we convert to numpy arrays to pandas if the base model supports categoricals variables, this raised an error as the categorical variables were not set properly (at train there was the treatment and other categorical variables and at prediction only the treatment was categorical).
For this I changed the tutorial to handle this case. Now instead of manually encoding the categorical codes in the numpy array, in the modified predict function we reconvert to a dataframe with the correct categorical variables.

Rendered version

Checklist

  • Added a CHANGELOG.rst entry

@FrancescMartiEscofetQC FrancescMartiEscofetQC marked this pull request as ready for review July 9, 2024 12:30
Copy link

codecov bot commented Jul 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.94%. Comparing base (1580c96) to head (bbbfe28).
Report is 31 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #57   +/-   ##
=======================================
  Coverage   94.94%   94.94%           
=======================================
  Files          15       15           
  Lines        1485     1485           
=======================================
  Hits         1410     1410           
  Misses         75       75           

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

Copy link
Collaborator

@kklein kklein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch!

docs/examples/example_lime.ipynb Show resolved Hide resolved
Copy link
Collaborator

@kklein kklein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! :)

@FrancescMartiEscofetQC FrancescMartiEscofetQC merged commit f7a64e6 into main Jul 10, 2024
16 checks passed
@FrancescMartiEscofetQC FrancescMartiEscofetQC deleted the fix_lime_example branch July 10, 2024 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants