eli5 icon indicating copy to clipboard operation
eli5 copied to clipboard

RuntimeWarning: invalid value encountered in double_scalars when computing weights

Open InterferencePattern opened this issue 5 years ago • 2 comments

Hi, I'm experiencing an error in eli5.show_weights(), I believe it's where the colors are being computed. I've followed the simplest tutorial (https://eli5.readthedocs.io/en/latest/blackbox/permutation_importance.html) and it's not working with my dataset and model.

I'm using eli5 version 0.10.1

Here is the relevant code: def permutation_importance(X_test, y_test, clf): import eli5 from eli5.sklearn import PermutationImportance perm = PermutationImportance(clf).fit(X_test, y_test) eli5.show_weights(perm)

permutation_importance(X_test_dummified,y_test,rf_clf_imbalanced)

Here is the entire error log:

~/anaconda3/envs/aif360/lib/python3.7/site-packages/eli5/formatters/html.py:235: RuntimeWarning: invalid value encountered in double_scalars rel_weight = (abs(weight) / weight_range) ** 0.7

The error is probably with weight or weight_range, but the error log does not specify where these are generated.

Can anyone help me trace this error back? Thanks!

InterferencePattern avatar Mar 17 '20 21:03 InterferencePattern

Additional information: I've now found that eli5.explain_weights(perm) results in all weights of zero, and I also realized that this model predicts the negative class for all data points. This would be the source of all zeros in the weights.

In any case, maybe it would be beneficial to users to catch this edge case.

InterferencePattern avatar Mar 17 '20 21:03 InterferencePattern

I encountered the same issue. Can anyone help on this issue?

Thanks a lot!

XinQi7788 avatar Jun 29 '21 22:06 XinQi7788