Open gaosq0604 opened 4 years ago
anyone...???
Hitting a similar issue here - I recently switched from one-hot encoding to proper Pandas categorical variables and now I can't use show_prediction() to introspect on specific predictions.
@cdrouin , I recently came across this problem too using Pandas categorical, and I happen to find a possible solution based on this thread. When you call on explain_prediction
and specify the row of the PD Dataframe, you need to do double square brackets (ie df.iloc[[0]]
and not df.iloc[0]
).
https://github.com/TeamHG-Memex/eli5/issues/214#issuecomment-453872558
I had the same problem and above did not solve it for me. What worked for me was using `X.iloc[[1]]` instead of `X.iloc[1]`. The latter form automatically converts a row to a series, which converts the datatypes in the row to "object" type if they differ.
_Originally posted by @agnesvanbelle in https://github.com/TeamHG-Memex/eli5/issues/214#issuecomment-453872558_
When previous model is lightgbm, using sklearn API with LGBMRegressor or LGBMClassifier with several category columns, then directly input
perm = PermutationImportance(model, random_state = 42).fit(X_test, y_test)
will cause erroronly if first astype int for all categorical columns and then write
categorical_feature = ...
in fit function, you can continue calculating. Should be fixed THX