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.
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
incomingtable.
- Finds required names missing from the
list- Turns the missing-name set into a list; its order does not affect this check.
Outputs you create
answer- The requested result, with the values, labels and row order described by this task.
distance | duration |
|---|---|
| 1 | 5.30501 |
| 1.47826 | 11.2361 |
| 1.95652 | 11.8488 |
| 2.43478 | 14.809 |
| 2.91304 | 10.7589 |
| 3.3913 | 19.4972 |
| 3.86957 | 17.89 |
| 4.34783 | 15.531 |
- A fitted workflow needs
distanceand weight. - The
incomingtable hasdistanceonly. - Store the missing feature names in a list named
answer.
answerHints
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.