Back to questions
JuniorTheoryCommon
What does this program print?
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import cross_val_score
X, y = load_iris(return_X_y=True)
scores = cross_val_score(LogisticRegression(max_iter=1000), X, y, cv=4)
print(scores.shape)(4,)
- Expecting
(), one averaged score:cross_val_scorereturns one score per fold, socv=4gives an array of 4 values; the mean is taken with.mean(). - Expecting
(150,), a score per row: the held-out rows of a fold are scored together as one accuracy, so the array has one value per fold, not per sample.
- How would you report these four scores in one line, and why does their spread matter?
- Why are the class shares the same in every fold when
cv=4is passed for a classifier?