[R] create picture (k -the nearest neighbours)
Grzesiek
gregorio99 at gmail.com
Tue Mar 9 14:01:19 CET 2010
Hi
I want to create a nice picture about my result of k -the nearest neighbours
algorithm. Here is my easy code:
#################################
library(klaR)
library(ipred)
library(mlbench)
data(PimaIndiansDiabetes2)
dane=na.omit(PimaIndiansDiabetes2)[,c(2,5,9)]
dane[,2]=log(dane[,2])
dane[,1:2]=scale(dane[,1:2])
zbior.uczacy=sample(1:nrow(dane),nrow(dane)/2,F)
KNN=ipredknn(diabetes~glucose+insulin,data=dane,subset=zbior.uczacy,k=3)
KNN=ipredknn(diabetes~glucose+insulin,data=dane,subset=zbior.uczacy,k=3)
b= ifelse((a==1),'red','blue' )
a=as.numeric(KNN$learn$y)
plot(KNN$learn$X[,1], KNN$learn$X[,2],pch=a,col = ifelse((a==1),'red','blue'
))
#################################
and my problem is (it's difficult for me to explain it in english):
What I should do if I want to get in my picture area (in different colors)
which will be show my "clasters". Like in picture (dark blue and bright
blue).
http://n4.nabble.com/file/n1585911/dec.jpg
--
View this message in context: http://n4.nabble.com/create-picture-k-the-nearest-neighbours-tp1585911p1585911.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list