Answered step by step
Verified Expert Solution
Link Copied!

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.

image text in transcribed

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 result

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced MySQL 8 Discover The Full Potential Of MySQL And Ensure High Performance Of Your Database

Authors: Eric Vanier ,Birju Shah ,Tejaswi Malepati

1st Edition

1788834445, 978-1788834445

More Books

Students also viewed these Databases questions

Question

Distinguish between intrinsic and extrinsic rewards.

Answered: 1 week ago

Question

Question What is an educational benefit trust and how is it used?

Answered: 1 week ago

Question

Question How are VEBA assets allocated when a plan terminates?

Answered: 1 week ago

Question

Question May a taxpayer roll over money from an IRA to an HSA?

Answered: 1 week ago