Outputs you create
scaled_mm- Requested result described in the task and deliverables.
answer- The requested result, with the values, labels and row order described by this task.
length_mm | width_cm |
|---|---|
| 10 | 1 |
| 20 | 3 |
| 30 | 2 |
| 40 | 4 |
- Standardise each of the two equivalent unit representations using its declared discovery population.
- Store them in
scaled_mmandanswer. - Verify that the prepared geometry agrees.
scaled_mmanswerHints
Think: The numeric unit change changes the relative feature contribution to raw distance and can change merges, not just the label. The merge-height magnitudes also use different coordinate scales. Use consistent units and a common scientifically justified representation before comparing algorithms or cuts; standardisation can make this declared unit conversion equivalent.
Tools: Hierarchy retrieval: use the supplied length_mm, width_cm columns and the pandas or model operations introduced in this lesson.
Approach: Compute scaled_mm, answer from the supplied evidence. Preserve the requested labels and row order, then inspect the values before checking.
Explained solution
from sklearn.preprocessing import StandardScaler
scaled_mm = StandardScaler().fit_transform(df)
converted = df.rename(columns={'length_mm':'length_cm'}).copy()
converted['length_cm'] = converted['length_cm'] / 10
answer = StandardScaler().fit_transform(converted)
print(scaled_mm)
print(answer)
The numeric unit change changes the relative feature contribution to raw distance and can change merges, not just the label. The merge-height magnitudes also use different coordinate scales. Use consistent units and a common scientifically justified representation before comparing algorithms or cuts; standardisation can make this declared unit conversion equivalent.