A running club's buddy-matching app describes each member by a few measured features, one row per member in X, with their names in names. A newcomer, query, has the same features in the same order.
The app wants to know who is most like the newcomer: the member with the smallest straight-line distance to them. It also wants to see whether scaling changes the answer.
.std() as in the lesson) from the members in X only, not the newcomer. Use those same values to scale every member's row and the newcomer's row. Then measure the distances.Task: write most_alike(names, X, query) returning a dict {"raw": ..., "scaled": ...}, holding the name of the nearest member each way. If two members are exactly as near, pick the one that comes first in names.
No column of X has a spread of 0.