Skip to learning content

DATA SCIENCE PYTHON PLAYGROUND

Machine Learning · Learn / Refresh

← ML Foundations lessonsQUESTIONS · MODELS · EVIDENCE
Learning from examples · ML-F-R1 · 15–20 MIN

Foundations retrieval

Retrieval 1

Exercises within this concept

  1. Retrieval 1Retrieve and applyCurrent exercise
  2. Retrieval 2Retrieve and apply
  3. Retrieval 3Retrieve and apply
Retrieval 1 · LINE12_REVIEW

Retrieve without the worked example: Create X with distance and y with duration.

Use the new retrieval population shown here.

Retrieve earlier concepts before combining them.

This practice: Retrieve earlier concepts before combining them. Next: Retrieval 2 · Foundations retrieval.

Given data · LINE12_REVIEW

12 observations. Deterministic teaching observations; values illustrate the concept rather than a real population claim. The dataframe df is supplied afresh for each Run.

LINE12_REVIEW · all rows
distanceduration
0.8404837.56117
2.1135311.7333
1.9443213.4821
3.0431713.9131
4.0490920.9425
4.7159621.6036
5.0731523.0636
5.8590325.3493
6.8184731.1129
8.1628533.1802
8.7646834.4287
9.7681841.2942

Column meanings and units

Column names describe the supplied features and target. Keep the stated units and row identities when making comparisons.

Synthetic data are deliberately small and reproducible. Their patterns illustrate an idea; they are not evidence about a real population.

Input schema
ColumnStored type
distancefloat64
durationfloat64

Supporting concepts: Measuring prediction error →

Remember the idea

Use the inputs and evidence to recover the method. Hints and explained solutions remain collapsed; exact phrasing is not graded.

Retrieve earlier concepts before combining them.Candidate ACandidate BFitValidateCostCompare matching evidence; smaller error can cost more.
Schematic · Retrieve earlier concepts before combining them.Scroll the diagram horizontally if needed.
Hint 1 — Think

Recall which object must remain a two-dimensional table even for one predictor.

Hint 2 — Tools

Dataframe column selection and aligned target Series.

Hint 3 — Approach

Separate the permitted predictor from its outcome without reordering rows.

Explained solution
X=df[['distance']]
y=df['duration']

The new population changes the values, but the X/y contract still separates inputs from the outcome to be learned.

Helpful prior knowledge: Measuring prediction error These links are guidance, not locks.

Sources and API context

Examples run with this Playground’s scikit-learn 1.4.2 / Pyodide 0.26.4 runtime.

Your task · Retrieval 1

Retrieve without the worked example: Create X with distance and y with duration. Use the new retrieval population shown here.

Xy

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.