A Score With an Error Bar

Machine Learning in CodeEasy+10 XP+10

A Score With an Error Bar

One train/test split gives one opinion. Cross-validation gives several, and their spread tells you how much to trust the average.

Task: write cv_mean_and_spread(n_folds).

  1. Load the data with load_breast_cancer(return_X_y=True, as_frame=True).
  2. Build make_pipeline(StandardScaler(), LogisticRegression(max_iter=1000)).
  3. Score it with cross_val_score on all the rows, using cv=n_folds.

Return [mean, spread]: the mean of the fold scores and their standard deviation (NumPy's .std()), each rounded to 3 decimal places.

Examples

n_folds = 5
returns [0.981, 0.007]
n_folds = 8
returns [0.981, 0.012]

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run