Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started