causalml icon indicating copy to clipboard operation
causalml copied to clipboard

ValueError: Unknown label type: 'continuous'

Open ya-stack opened this issue 3 years ago • 6 comments
trafficstars

Can you please tell how shall I use BaseSClassifier to fit and find feature importance. I have converted data type of label into "object" still I am getting the error - ValueError: Unknown label type: 'continuous' Waiting for your reply. Thanks!

image

Snippet of Dataset looks like: image

ya-stack avatar Apr 19 '22 13:04 ya-stack

Thanks for reaching out, @ya-stack

Do you mind providing a complete error msg/ log for the ValueError? that would be helpful

paullo0106 avatar Apr 23 '22 19:04 paullo0106

if the error comes from that estimate_ate() line, let me know how the below works (one possible cause is this):

slearner.estimate_ate(X, w_multi, y.astype('int'))

and I would want to double-check below as well

from sklearn.utils.multiclass import type_of_target
print(type_of_target(y))

paullo0106 avatar Apr 23 '22 20:04 paullo0106

Hi Paul, thanks for the reply. I am getting the value error while finding feature importance using "get_importance" method. I have changed the dtype of y_train to category and tried to fit RandomForestClassifier() to find feature importance using Shap values. Please find below the snippets for your reference.

Waiting for your response. Thanks in advance!

image

image

ya-stack avatar Apr 26 '22 18:04 ya-stack

hmm so it seems fit_predict() worked fine, can you click on the "5 frames" to expand the error msg for me? and have you tried passing in with y_train.astype('int')? thanks

paullo0106 avatar Apr 27 '22 22:04 paullo0106

Hi Paul, Yes fit_predict is working fine. I am getting an error while finding features importance. Also, I have changed the type of y_train to 'int'. Please find attached the snippets for an additional reference. Thanks!

image image

ya-stack avatar Apr 28 '22 06:04 ya-stack

Hi @ya-stack, the model_tau_feature should be regressor because it predicts the treatment effect, τ, which is continuous regardless the type of the outcome, y. Please try:

model_tau_feature = RandomForestRegressor()

jeongyoonlee avatar Jun 14 '22 07:06 jeongyoonlee