Question: [ 1 0 points ] Problem 1 - K Means Clustering In [ 4 1 ] : def k _ means _ clustering ( centroids

[10 points] Problem 1- K Means Clustering In [41]: def k_means_clustering(centroids, dataset):
# Description: Perform k means clustering for 2 iterations given as input the dataset and centroids.
# Input:
# 1. centroids - A list of lists containing the initial centroids for each cluster.
# 2. dataset - A list of lists denoting points in the space.
# Output:
# 1. results - A dictionary where the key is iteration number and store the cluster assignments i
# appropriate clusters. Also, update the centroids list after each iteration.
result
'1': { 'cluster1': [], 'cluster2': [], 'cluster3': [], 'centroids': []},
'2': { 'cluster1': [], 'cluster2': [], 'cluster3': [], 'centroids': []}
}
centroid1, centroid2, centroid3= centroids[0], centroids[1], centroids[2]
for iteration in range(2):
# your code here
return result
A sample dataset has been provided to you in the './data/sample_dataset_kmeans.pickle' path. The centroids are in './data/sample_centroids_kmeans.pickle'
and the sample result is in './data/sample_result_kmeans.pickle' path. You can use these to test your code.
Here are the attributes for the dataset. Use this dataset to test your functions.
Dataset should load the points in the form of a list of lists where each list item represents a point in the space.
An example dataset will have the following structure. If there are 3 points in the dataset, this would appear as follows in the list of lists.
dataset =[
[5,6],
[3,5],
[2,8]
]
Note:
A sample dataset to test your code has been provided in the location "data/sample_dataset_kmeans.pickle". Please maintain this as it would be necessary
while grading.
Do not change the variable names of the returned values.
After calculating each of those values, assign them to the corresponding value that is being returned.
[ 1 0 points ] Problem 1 - K Means Clustering In

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 Programming Questions!