Skip to learning content

DATA SCIENCE PYTHON PLAYGROUND

Machine Learning · Learn / Refresh

← Choose and Explain Models lessons
Communicate evidence · ML-M04 · 12–18 MIN

What changes outside this dataset?

Identify evidence needed for a changed use context.

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

Understand the idea

Population shift, group structure and changed feature availability can break apparent validation success. State the intended use and the new evidence needed rather than promising transportability.

Identify evidence needed for a changed use context.Original settingProposed new settingSame variable definitions and availability?Comparable population, horizon and costs?Seek validation evidence for the intended use.
Identify evidence needed for a changed use context.Scroll the diagram horizontally if needed.

What the syntax does

set(incoming.columns)
  • Collects the available feature names into a set.
required - set(incoming.columns)
  • Finds required names missing from the incoming table.
list
  • Turns the missing-name set into a list; its order does not affect this check.

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. A fitted workflow needs distance and weight.
  2. The incoming table has distance only.
  3. Store the missing feature names in a list named answer.
answer
Hints

Think: Use sets to check an incoming schema before calling predict().

Tools: Use set(incoming.columns), required - set(incoming.columns), list. Read the visible syntax meanings before editing.

Approach: A fitted workflow needs distance and weight. The incoming table has distance only. Store the missing feature names in a list named answer. Keep the supplied row order and inspect the named output after running.

Explained solution
required = {'distance', 'weight'}
incoming = pd.DataFrame({'distance': [4, 7]})
answer = list(required - set(incoming.columns))

The incoming table is missing weight, so it cannot support this two-feature workflow as specified. Matching names is only the first check: units, availability at prediction time and the population must also match the intended use.

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.