SauceCat / PDPbox

python partial dependence plot toolbox
http://pdpbox.readthedocs.io/en/latest/
MIT License
840 stars 129 forks source link

one-hot encoding feature should contain more than 1 element #56

Closed mjjun1 closed 3 years ago

mjjun1 commented 5 years ago

Hi, I ran multiclass XGB with one target column, and execute the following pdp_isolate code. I got an error: "ValueError: one-hot encoding feature should contain more than 1 element". How I can fix it? Thank you in advance.

pdp_xgb = pdp.pdp_isolate( model=xgb1, dataset=data, model_features=features, feature=['dis_suwK'] )

doctorperceptron commented 4 years ago

The list you supply for the feature parameter should be the one-hot encoded columns, i.e. if you have a feature colour=['red', 'green', 'blue'] you need to convert this to one-hot encoding so that you have columns 'red', 'green', and 'blue' that take on values of zero and one, then set feature=['red', 'green', 'blue'] when calling pdp_isolate.