Answered step by step
Verified Expert Solution
Question
1 Approved Answer
No dataset provided. Based on the question asked you should still be able to fill in the correct code, where it says #your code here.
No dataset provided. Based on the question asked you should still be able to fill in the correct code, where it says #your code here. In python please
; import argparse import pandas as pd import numpy as np import pickle from pathlib import Path from collections import defaultdiet [10 points] Problem 1 - K Means Clustering 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. def k_means_clustering(centroids, dataset): Deseription: 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 in the appropriate clusters. Also, update the centroids list after each iteration. result - 'l': { 'clusterl': 0, "eluster2': [], "eluster3': 0, 'centroids': []}, '2': { 'clusterl': 0, 'cluster2': [], "cluster3': 0, 'centroids': O} > centroidi, centroid2, centroid3 - centroids (O), centroids[1], centroids [2] for iteration in range(2) : your code here return resultStep 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