Menu
CoddyTech

Recap: Climbing Partners

Part of the Statistics for ML section of Coddy's Machine Learning journey. Lesson 51 of 64.

challenge icon

Challenge

Medium

A climbing gym pairs each newcomer with the most similar member. Each row of members is a member, named in names: height (cm), arm span (cm) and dead hang (minutes on a bar). The program reads the newcomer's measurements.

  1. Find the nearest member in the raw table.
  2. Standardize with a StandardScaler fitted on the members; print the newcomer scaled.
  3. Find the nearest member again, on the scaled tables.

Round to 2 decimals. Another gym, with three members:

Another gym as a table: a newcomer and three members, Kim, Lou and Max, with height, span and hang. Beside them each member's distance to the newcomer: raw, Kim is nearest at 4.56; scaled, Lou is nearest at 1.09

Its output:

Nearest before scaling: Kim (4.56)
Newcomer scaled: [[-0.38 -0.54  0.98]]
Nearest after scaling: Lou (1.09)

Try it yourself

import numpy as np
from sklearn.preprocessing import StandardScaler

names = ["Iris", "Jon", "Kai", "Lena", "Max", "Nora"]
# One row per member: height in cm, arm span in cm, dead hang in minutes
members = np.array([[166, 169, 1.6],
                    [182, 188, 1.1],
                    [171, 170, 2.3],
                    [176, 181, 1.4],
                    [188, 191, 2.0],
                    [160, 163, 0.9]])
# The newcomer
height = float(input())
span = float(input())
hang = float(input())

# Write your code below

All lessons in Statistics for ML

Practice on your own: Online Python compiler