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

Info iconThis 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
Background image of page 1

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

View Full DocumentRight 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.
Background 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
Background image of page 3

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

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

This note was uploaded on 08/20/2011 for the course STATS 202 taught by Professor Taylor during the Summer '09 term at Stanford.

Page1 / 8

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

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online