{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

HW6_Sol

# HW6_Sol - Homework 6 Solutions 1 Read Chapter 8(Sections...

This preview shows pages 1–4. Sign up to view the full content.

Homework 6 Solutions 1) Read Chapter 8 (Sections 8.1 and 8.2), Chapter 10 (all) and Chapter 2 (Section 2.4). 2) data<-read.csv("sonar_test.csv",header=FALSE) x<-data[,1:2] plot(x,pch=19,xlab=expression(x[1]),ylab=expression(x[2])) fit<-kmeans(x, 2) points(fit\$centers,pch=19,col="blue",cex=2) library(class) knnfit<-knn(fit\$centers,x,as.factor(c(-1,1))) points(x,col=1+1*as.numeric(knnfit),pch=19) 0.00 0.02 0.04 0.06 0.08 0.10 0.12 0.00 0.05 0.10 0.15 0.20 x 1 x 2

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
3) y<-data[,61] sum(knnfit==y)/length(y) You get 47% misclassification error. 4) x<-data[,1:60] fit<-kmeans(x, 2) library(class) knnfit<-knn(fit\$centers,x,as.factor(c(-1,1))) sum(knnfit==y)/length(y) You get 44% misclassification error.
5) Center1=1 Center2=2 Cluser1=1 so mean = 1 Cluster2=2,2.5,3,3.5,4,4.5,5,7,8,8.5,9,9.5,10 so mean = 5.884615 Center1=1 Center2=5.884615 Cluser1=1,2,2.5,3 so mean = 2.125 Cluster2=3.5,4,4.5,5,7,8,8.5,9,9.5,10 so mean = 6.9 Center1=2.125 Center2=6.9 Cluser1=1,2,2.5,3,3.5,4,4.5 so mean = 2.928571 Cluster2=5,7,8,8.5,9,9.5,10 so mean = 8.142857 Center1=2.928571 Center2=8.142857 Cluser1=1,2,2.5,3,3.5,4,4.5,5 so mean = 3.1875 Cluster2=7,8,8.5,9,9.5,10 so mean = 8.666667 Center1=3.1875 Center2=8.666667 Cluser1=1,2,2.5,3,3.5,4,4.5,5 so mean = 3.1875 Cluster2=7,8,8.5,9,9.5,10 so mean = 8.666667

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern