Back to questions
JuniorTheoryCommon
What does this program print?
import numpy as np
from sklearn.ensemble import HistGradientBoostingClassifier
X = np.array([[1.0], [np.nan], [3.0], [4.0]] * 10)
y = np.array([0, 0, 1, 1] * 10)
model = HistGradientBoostingClassifier(random_state=0).fit(X, y)
print(model.predict(np.array([[np.nan]]))[0])0
- Expecting
ValueError, as fromLogisticRegression:HistGradientBoostingClassifieracceptsnp.nanand learns at each split which side the rows with a missing value go to. - Expecting
nan:predictreturns a class label, and a sample withnp.nanfollows the side its training rows took, here together withx = 1.0and class0.
- Where would a sample with
np.nango if the training data had no missing values in this feature? - When is filling the gaps with
SimpleImputerstill worth doing before boosting?