DALEX icon indicating copy to clipboard operation
DALEX copied to clipboard

Multi class Feature Importance

Open PhilipNell opened this issue 3 years ago • 5 comments

Multi class feature importance is returning NaN for all variables. Does Dalex in Python support multi class? Jupyter NB and datafile is attached Archive.zip

PhilipNell avatar Oct 09 '20 10:10 PhilipNell

Hi, Python dalex doesn't support multiclass overall.

For it to work (in Feature Importance) you have to pass a custom predict_function to the Explainer and a custom loss_function to the model_parts method. Moreover, the form of y parameter should be taken into account in the loss_function.

multiclass.zip

Now, the predict_function doesn't return a (1d) np.array so other methods may fail. Also, dx.Explainer pointed out an error in residual_function (should probably be custom as well).

Multiclass in this package is not a priority as all (or most) of the methods would need to be customised EDIT: e.g. for predict_parts it would be plotting one plot per class and for model/predict_profile plotting one line per class. It can now be achieved by producing k times Explainer object, each predicting other class (custom predict_function), and plotting them together.

In the long run, it is something we definitely want to add.

hbaniecki avatar Oct 09 '20 11:10 hbaniecki

Awesome, thanks for the swift reply. Will have a look at it.

PhilipNell avatar Oct 09 '20 11:10 PhilipNell

@hbaniecki would an additional argument like predict_function_target_column be a help here? then for multiclass object dalex can turn the classification into a binary classification model one-vs-all_others

pbiecek avatar Jan 15 '22 23:01 pbiecek

Sure, I just don't like the parameter name of predidct_function_target_column and am unsure about how to update all the yhat functions to utilize that.

hbaniecki avatar Mar 12 '22 10:03 hbaniecki

Example https://dalex.drwhy.ai/python-dalex-multioutput added in https://github.com/ModelOriented/DALEX-docs/commit/47378806fa9d32b612fb84adb46640638956ede7.

hbaniecki avatar Apr 17 '22 14:04 hbaniecki