View the step-by-step solution to:

Cluster Assignment Exercise 3 (1 point): Write a function that acts on the p' order distance matrix to assign a "cluster label" to each...

q1.png


Please help in solving this. I need to develop a function that would take the shown matrix (3 points) and assign them to a cluster based on the distance matrix.

q1.png

Cluster Assignment
Exercise 3 (1 point): Write a function that acts on the p' order distance matrix to assign a "cluster label" to each point using the minimum distance to find the
"most similar" medoid.
That is, consider the m x k, p'h power distance matrix S .
For each point, indicated by row index i , if sjj is the minimum distance for point i , then the index j + 1 is i's cluster label.
In other words, your function should return a one-dimensional array, y, of length m such that
yi = argmin sij+ 1
je[0,...,k-1]
In [ ]: def assign_cluster_labels(S) :
# Cluster Labels:
1
2
S_test1 = np . array([[0.3, 0.2], # --> cluster 2
[0.1, 0.5], # --> cluster 1
[0.4, 0.2] ] ) # --> cluster 2
y_test1 = assign_cluster_labels(S_test1)
print("You found:", y_test1)
# Debugging assert
assert (y_test1 == np. array( [2, 1, 2] ) ) .all( )

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question