Memorised or Learned?

Machine Learning in CodeMedium+10 XP+10

Memorised or Learned?

A model can look perfect on the rows it studied and still stumble on new ones. Comparing the two scores tells you whether it memorised or learned.

Task: write train_and_test_scores(name, seed). name is "iris" or "wine".

  • Load the dataset as X and y, and split it with train_test_split(X, y, test_size=0.25, random_state=seed).
  • Train a DecisionTreeClassifier(random_state=0) on the training rows.
  • Return [training score, test score], each rounded to 3 decimal places. The training score is the score on the rows it learned from.

Examples

name = "wine"
seed = 1
returns [1.0, 0.956]
name = "iris"
seed = 8
returns [1.0, 0.895]

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