The Clinic Report

Machine Learning in CodeMedium+10 XP+10

The Clinic Report

A doctor does not want an R² alone. They want to know how far out the model usually is, and whether that is any better than simply guessing the average.

Write clinic_report(columns).

  • Load the data with load_diabetes(return_X_y=True, as_frame=True) and split it with train_test_split(X, y, test_size=0.25, random_state=0).
  • Keep only the columns named in columns.
  • Fit make_pipeline(StandardScaler(), LinearRegression()) on the training rows and predict the test rows.
  • Also make a lazy baseline: predict the mean of the training answers for every test row.

Return a dict, with every number a plain float:

  • "r2": the model's test R², rounded to 3 places.
  • "rmse": the model's test RMSE (square root of the mean squared error), rounded to 1 place.
  • "mae": the model's test mean absolute error, rounded to 1 place.
  • "baseline_rmse": the lazy baseline's test RMSE, rounded to 1 place.

Examples

columns = ['bmi']
returns {'r2': 0.158, 'rmse': 64.7, 'mae': 53.3, 'baseline_rmse': 70.5}
columns = ['age', 'sex', 'bmi', 'bp', 's1', 's2', 's3', 's4', 's5', 's6']
returns {'r2': 0.359, 'rmse': 56.4, 'mae': 45.1, 'baseline_rmse': 70.5}

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