[R] how to label the som notes by the majority vote

From: Changbin Du <changbind_at_gmail.com>
Date: Tue, 01 Jun 2010 17:21:51 -0700


HI, Dear R community,

I am using the following codes to do the som. I tried to label the notes by the majority vote. either through mapping or prediction. I attached my output, the left one dont have any labels in the note, the right one has more than one label in each note. I need to have only one label for each note either by majority vote or prediction.

Can anyone give some suggestions or advice? Thanks so much!

alex<-read.table("/home/cdu/operon/alex2.txt", , sep="\t", skip=0, header=T, fill=T)
alex1<-alex[,c(1:257)]
levels(alex1$Label)

alex1$outcome<-as.numeric(alex1$Label)
alex1$outcome[1:20]

#self-organizing maps(unsupervised learning)
library("kohonen")

#SOM, the supervised learning, train the map using outcome as the class
variable.
set.seed(13)
final.xyf<- xyf(data=as.matrix(alex1[,c(1:256)]), Y=classvec2classmat(alex1$outcome), xweight = 0.99, grid=somgrid(20, 30, "hexagonal"))

outcome.xyf <- predict(final.xyf)$unit.prediction#get prediction outcome.predict<- as.numeric(classmat2classvec(outcome.xyf)) #change matrix to vectors.

outcome.label<-LETTERS[outcome.predict] #conver the numeric value to letters.

plot(final.xyf, type="property", property=outcome.predict, labels=outcome.label, palette.name =rainbow, main="Prediction ")

cl <- colors()
bgcols <- cl[2:14]
plot(final.xyf, type="mapping", labels=outcome.label, col="black", bgcol=bgcols[as.integer(outcome.predict)],

          main="Mapping plot")

-- 
Sincerely,
Changbin
--

______________________________________________ R-help_at_r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.

Received on Wed 02 Jun 2010 - 00:28:34 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 02 Jun 2010 - 01:00:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive