{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

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

View Full Document Right Arrow Icon
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
Image of page 1

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

View Full Document Right Arrow Icon
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.
Image of page 2
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
Image of page 3

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

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern