Skip to content
C

Problem 4: Manual Euclidean Distance Calculator

Easypython

Problem Description

Write a Python program that manually calculates the Euclidean distance between a new point and each point in a small training set (without using Scikit-learn), then identifies the single nearest neighbor.

Input

A list of training points and one new point.

Output

The distances to each training point, and the nearest neighbor.

Constraints

  • Each point has exactly 2 features.

Example Input

text
training_points=[[1,2],[4,6],[7,8]], new_point=[3,3]

Example Output

text
Distances: [2.24, 3.16, 6.40] Nearest neighbor: [1, 2]

Concepts Covered

Manual distance formula, loops, min().

Input (stdin)

Output

Run your code to see output here...