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 &quot;cluster label&quot; to each...

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.

Cluster Assignment
Exercise 3 (1 point): Write a function that acts on the p' order distance matrix to assign a &quot;cluster label&quot; to each point using the minimum distance to find the
&quot;most similar&quot; 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], # --&gt; cluster 2
[0.1, 0.5], # --&gt; cluster 1
[0.4, 0.2] ] ) # --&gt; cluster 2
y_test1 = assign_cluster_labels(S_test1)
print(&quot;You found:&quot;, y_test1)
# Debugging assert
assert (y_test1 == np. array( [2, 1, 2] ) ) .all( )

### 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