Stucked in Q4

Excuse me, I have launched the code:

from sklearn.experimental import enable_hist_gradient_boosting
from sklearn.ensemble import HistGradientBoostingClassifier
from sklearn.preprocessing import StandardScaler
from sklearn.impute import SimpleImputer

hist_model = make_pipeline(StandardScaler(), SimpleImputer(strategy="constant", fill_value="missing"), HistGradientBoostingClassifier(
    max_iter=1000, early_stopping=True, random_state=0
))
cv_results_hist_model = cross_validate(
    hist_model, data, target, cv=cv,
    scoring="neg_mean_absolute_error",
    return_estimator=True, return_train_score=True)
errors = -cv_results_hist_model["test_score"]
print(f"MAE on test sets:\n {errors}\n",
      f"mean +/- std: {errors.mean():.3f} +/- {errors.std():.3f} Watts")

And the result after is:

MAE on test sets:
 [nan nan nan nan]
 mean +/- std: nan +/- nan Watts

I do not know why “nan”.
Can you please help me? Thanks

To debug and get the traceback, try to pass error_score="raise" in cross_validate. It will give you the error.

But I can see something wrong with:

You are imputing with the string missing while HistGradientBoostingClassifier will expect only numerical data.

Also you are using a classifier while the the problem is a regression problem.

Thank you, the issue was to use a regressor, perfect.