Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 2. K-means Programming (10 points) Our objective in this question is to verify the effect of choosing the initial number of clusters, given by

Problem 2. K-means Programming (10 points)

Our objective in this question is to verify the effect of choosing the initial number of clusters, given by parameter K, in the K-means algorithm. For this, first implement the K-means algorithm. To verify the effect of K, download the crime data set available on Canvas. Each data instance has four attributes: murder, assault, urban population and rape, and an integer label between 1 and 4. The name of the state is just an identifier, and can be ignored for clustering purposes. Make sure you store the crime dataset csv file in your submission folder. Your program should load the dataset from this locally stored csv file.

The k-values you should use are: k = 2, 3, 4, 5, and 6.

Your program should output the values of k, the distortion value and the number of iterations taken to run. A sample output is below:

K = 2, distortion = ..., iterations = ...

K = 3, distortion = ..., iterations = ...

This is the dataset.csv

crime$cluster,Murder,Assault,UrbanPop,Rape Alabama,4,13.2,236,58,21.2 Alaska,4,10,263,48,44.5 Arizona,4,8.1,294,80,31 Arkansas,3,8.8,190,50,19.5 California,4,9,276,91,40.6 Colorado,3,7.9,204,78,38.7 Connecticut,2,3.3,110,77,11.1 Delaware,4,5.9,238,72,15.8 Florida,4,15.4,335,80,31.9 Georgia,3,17.4,211,60,25.8 Hawaii,1,5.3,46,83,20.2 Idaho,2,2.6,120,54,14.2 Illinois,4,10.4,249,83,24 Indiana,2,7.2,113,65,21 Iowa,1,2.2,56,57,11.3 Kansas,2,6,115,66,18 Kentucky,2,9.7,109,52,16.3 Louisiana,4,15.4,249,66,22.2 Maine,1,2.1,83,51,7.8 Maryland,4,11.3,300,67,27.8 Massachusetts,3,4.4,149,85,16.3 Michigan,4,12.1,255,74,35.1 Minnesota,1,2.7,72,66,14.9 Mississippi,4,16.1,259,44,17.1 Missouri,3,9,178,70,28.2 Montana,2,6,109,53,16.4 Nebraska,2,4.3,102,62,16.5 Nevada,4,12.2,252,81,46 New Hampshire,1,2.1,57,56,9.5 New Jersey,3,7.4,159,89,18.8 New Mexico,4,11.4,285,70,32.1
New York,4,11.1,254,86,26.1 North Carolina,4,13,337,45,16.1 North Dakota,1,0.8,45,44,7.3 Ohio,2,7.3,120,75,21.4 Oklahoma,3,6.6,151,68,20 Oregon,3,4.9,159,67,29.3 Pennsylvania,2,6.3,106,72,14.9 Rhode Island,3,3.4,174,87,8.3 South Carolina,4,14.4,279,48,22.5 South Dakota,1,3.8,86,45,12.8 Tennessee,3,13.2,188,59,26.9 Texas,3,12.7,201,80,25.5 Utah,2,3.2,120,80,22.9 Vermont,1,2.2,48,32,11.2 Virginia,3,8.5,156,63,20.7 Washington,3,4,145,73,26.2 West Virginia,1,5.7,81,39,9.3 Wisconsin,1,2.6,53,66,10.8 Wyoming,3,6.8,161,60,15.6

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