Skip to learning content

DATA SCIENCE PYTHON PLAYGROUND

Machine Learning · Learn / Refresh

← Choose and Explain Models lessons
Compare fairly · ML-M02 · 12–18 MIN

Compare candidates on common evidence

Use matching evaluation designs and practical constraints.

  1. FollowRead and run the PythonCurrent exercise
  2. ChangeCompute and inspect the evidence
  3. TransferCompute and inspect the evidence

Understand the idea

Comparisons need the same population, outcome definition, split and folds when the aim is a paired predictive comparison. Nominate before the final test. Discovery and PCA use different evidence and must not be ranked by supervised accuracy.

Use matching evaluation designs and practical constraints.Candidate recipes: same question and available inputsCompare on the same training folds and metricJudge validation quality, cost and interpretation
Use matching evaluation designs and practical constraints.Scroll the diagram horizontally if needed.

What the syntax does

fold_errors['tree'] - fold_errors['line']
  • Subtracts errors on matching folds.
  • A negative value favours the tree on that fold.

Outputs you create

answer
  1. The requested result, with the values, labels and row order described by this task.
LINE24 · first 8 rows
distanceduration
15.30501
1.4782611.2361
1.9565211.8488
2.4347814.809
2.9130410.7589
3.391319.4972
3.8695717.89
4.3478315.531
Your task
  1. Across five matching folds, line RMSE is [4.0, 5.0, 4.5, 5.5, 4.0] and tree RMSE is [3.5, 4.8, 5.0, 4.9, 3.8].
  2. Store tree minus line RMSE for each fold in answer.
answer
Hints

Think: Compare aligned fold-score columns before summarising candidate performance.

Tools: Use fold_errors['tree'] - fold_errors['line']. Read the visible syntax meanings before editing.

Approach: Across five matching folds, line RMSE is [4.0, 5.0, 4.5, 5.5, 4.0] and tree RMSE is [3.5, 4.8, 5.0, 4.9, 3.8]. Store tree minus line RMSE for each fold in answer. Keep the supplied row order and inspect the named output after running.

Explained solution
fold_errors = pd.DataFrame({'line': [4.0, 5.0, 4.5, 5.5, 4.0], 'tree': [3.5, 4.8, 5.0, 4.9, 3.8]})
answer = fold_errors['tree'] - fold_errors['line']

The tree has smaller RMSE in four of these illustrative folds but larger error in one. Pairing the evidence preserves the common evaluation population. The mean difference alone is not a universal ranking or proof of statistical significance.

Ctrl/⌘+Enter: Run · Tab: indent · Esc then Tab: leave editor

Python loads when you run. Code and results stay in this activity only.

Run your code to inspect its output. Check uses that same run.