Understand the idea
In discovery, fitting a scale on the declared population is part of describing that population. If PCA or clustering features later enter a supervised workflow, fit those transformations inside its training folds.
Illustrative data
Click the highlighted code to change the result.
scaler = StandardScaler().fit(example_X)
answer = | length (km) | time (min) |
|---|---|
| 10 | 2 |
| 20 | 4 |
| 30 | 6 |
| length z | time z |
|---|---|
| -1.225 | -1.225 |
| 0 | 0 |
| 1.225 | 1.225 |
Subtract the fitting mean, then divide by its SD. Means: 20 km and 4 min. SDs: 8.165 km and 1.633 min.
Outputs you create
answer- The requested result, with the values, labels and row order described by this task.
length_mm | width_cm |
|---|---|
| 1106.65 | 6.36006 |
| 1262.66 | 13.292 |
| 317.138 | 5.44237 |
| 1044.74 | 8.89315 |
| 994.12 | 7.01435 |
| 1307.79 | 12.7223 |
| 1023.11 | 13.9453 |
| 1163.63 | 6.99248 |
- Standardise CLUSTER36’s unequal-unit measurements.
answerHints
Think: A large numerical unit can dominate distances without being substantively more important.
Tools: StandardScaler.fit_transform.
Approach: Learn a standardised representation of the declared discovery population.
Explained solution
from sklearn.preprocessing import StandardScaler
scaler=StandardScaler()
answer=scaler.fit_transform(df)
For this descriptive task the supplied population defines the scale; later supervised use would require a different fitting boundary.