Chap 3, more clarification for Never5Classifier(BaseEstimator)
from sklearn.base import BaseEstimator
class Never5Classifier(BaseEstimator):
def fit(self, X, y=None):
pass
def predict(self, X):
return np.zeros((len(X), 1), dtype=bool)
I don't understand how this being created. I thought it would predict not-5 class is true, but whereas y_train[1] == 0 , never_5_clf.predict(X_train) is still False for the [1] ?
plz explain how this classifier work. Which code represent it can predict the not-5?

Thanks for your question.
The Never5Classifier always predicts False, no matter what you give it as input. The goal is to point out that even such a dumb classifier gets over 90% accuracy, and that's just because the dataset is skewed: only 10% of the instances are 5s, so 90% of them are not 5s.
The instance X_train[1] represents a zero (as you can see because y_train[1] == 0). So it's not a 5. Therefore the Never5Classifier is correct when it predicts False, meaning "this is not a 5". Despite being so dumb, the classifier will get it right roughly 90% of the time.
Hope this helps.
Thanks for your question.
The
Never5Classifieralways predictsFalse, no matter what you give it as input. The goal is to point out that even such a dumb classifier gets over 90% accuracy, and that's just because the dataset is skewed: only 10% of the instances are 5s, so 90% of them are not 5s.The instance X_train[1] represents a zero (as you can see because
y_train[1] == 0). So it's not a 5. Therefore the Never5Classifier is correct when it predictsFalse, meaning "this is not a 5". Despite being so dumb, the classifier will get it right roughly 90% of the time.Hope this helps.
@ageron thank you so much, I understand your idea.