causalml
causalml copied to clipboard
ValueError: Unknown label type: 'continuous'
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!
Snippet of Dataset looks like:

Thanks for reaching out, @ya-stack
Do you mind providing a complete error msg/ log for the ValueError? that would be helpful
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))
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!


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
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!
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()