Bird
0
0

You have two sets of points:

hard📝 Application Q15 of 15
SciPy - Clustering and Distance
You have two sets of points:
pointsA = [[0, 0], [3, 4], [6, 8]]
pointsB = [[0, 0], [0, 5]]

You want to find which point in pointsA is closest to any point in pointsB. Which approach using scipy.spatial.distance_matrix is correct?
ACompute the distance matrix, then find the minimum distance in each row
BCompute the distance matrix, then sum all distances and pick the smallest sum
CCompute the distance matrix, then find the maximum distance in each column
DCompute the distance matrix, then average all distances and pick the largest average
Step-by-Step Solution
Solution:
  1. Step 1: Compute distance matrix between pointsA and pointsB

    This gives distances from each point in pointsA to each point in pointsB.
  2. Step 2: Find minimum distance per point in pointsA

    For each row (point in pointsA), find the smallest distance to any point in pointsB to identify closest point.
  3. Final Answer:

    Compute the distance matrix, then find the minimum distance in each row -> Option A
  4. Quick Check:

    Closest point = min distance per row [OK]
Quick Trick: Minimum distance per row shows closest point [OK]
Common Mistakes:
  • Using sum or average instead of minimum distance
  • Finding maximum distance which is farthest, not closest
  • Confusing rows and columns in the matrix

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes