Retrieve without the worked example: Expand distance and weight to degree two; report feature names.
Use the new retrieval population shown here.
Retrieve earlier concepts before combining them.
This practice: Retrieve earlier concepts before combining them. Next: Retrieval 2 · Flexibility retrieval.
Given data · MIX60_REVIEW
60 observations. Deterministic teaching observations; values illustrate the concept rather than a real population claim. The dataframe df is supplied afresh for each Run.
| distance | weight | service | weekend | duration |
|---|---|---|---|---|
| 15.4106 | 6.72438 | standard | 0 | 59.8192 |
| 9.54834 | 4.7947 | express | 1 | 36.569 |
| 17.2105 | 5.70745 | economy | 0 | 59.5671 |
| 14.3297 | 7.80743 | standard | 1 | 56.8985 |
| 2.88002 | 6.18273 | express | 0 | 19.4598 |
| 19.0123 | 5.64716 | economy | 1 | 76.7485 |
| 15.5967 | 5.59089 | standard | 0 | 57.2908 |
| 15.6749 | 3.15065 | express | 1 | 53.9559 |
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.
| Column | Stored type |
|---|---|
| distance | float64 |
| weight | float64 |
| service | str |
| weekend | int64 |
| duration | float64 |
Supporting concepts: Validate polynomial flexibility → · Control tree complexity →
Remember the idea
Use the inputs and evidence to recover the method. Hints and explained solutions remain collapsed; exact phrasing is not graded.
Hint 1 — Think
Recall that two-input expansion creates interactions as well as powers.
Hint 2 — Tools
PolynomialFeatures and fitted feature names.
Hint 3 — Approach
Fit the requested expansion to the declared schema and inspect its generated names.
Explained solution
from sklearn.preprocessing import PolynomialFeatures
expander=PolynomialFeatures(degree=2,include_bias=False).fit(df[['distance','weight']])
answer=list(expander.get_feature_names_out())
The named representation makes all degree-two terms visible without assuming expansion means only squaring each column.
Helpful prior knowledge: Validate polynomial flexibility · Control tree complexity 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.