Quantco / metalearners

MetaLearners for CATE estimation
https://metalearners.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
34 stars 4 forks source link

Fix LIME example numpy - pandas conversion #57

Closed FrancescMartiEscofetQC closed 4 months ago

FrancescMartiEscofetQC commented 4 months ago

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

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

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

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