Question: Sample Output: def calculate_centroid_pos (data): (5 pts) function receives a 2D numpy array data (N x M dimensions) and calculates the new updated centroid position

 Sample Output: def calculate_centroid_pos (data): (5 pts) function receives a 2D

Sample Output:

numpy array "data" (N x M dimensions) and calculates the new "updated"

def calculate_centroid_pos (data): (5 pts) function receives a 2D numpy array "data" (N x M dimensions) and calculates the new "updated" centroid position for these data Note: assume all the the examples given in "data" belong to one cluster function should return a numpy array with 1xM dimensions (centroid position). Parameters: data: 2D numpy array (N X M dim) with continuous numerical values. Returns: The numpy array with 1xM dimensions of the centroid: one centroid position in M dimensions. In [15]: mydata np.array( [ [1, 2], [3, 4], [5, 6] ]) In [16]: hw.calculate_centroid_pos(mydata) Out[16]: array([3., 4. ]) In [17]: # Now testing higher dimensions In [18]: mydata = np.array([ [ 1, 2, 3], [4, 5, 6], [7, 8, 9] 1) In [19]: hw.calculate_centroid_pos (mydata) Out[19]: array([4., 5., 6.])

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!