Back to questions
JuniorTheoryCommon
What does this program print?
import numpy as np
from sklearn.dummy import DummyClassifier
X_train = np.zeros((10, 1))
y_train = np.array([0, 0, 0, 0, 0, 0, 0, 1, 1, 1])
X_test = np.zeros((4, 1))
y_test = np.array([1, 1, 1, 0])
model = DummyClassifier()
model.fit(X_train, y_train)
print(model.score(X_test, y_test))0.25
- Expecting
0.75: the class is picked once, atfit, fromy_train, where0is the most frequent; the test set's own majority1plays no part. - Expecting
0.7, the share of0iny_train:scorecompares the constant answer0withy_test, where only one label of four is0.
- Why train and report a baseline like this before any real model?
- On a dataset with 95% negatives, what accuracy does this baseline reach, and which metric would expose it?