Dear Changbin, Please provide a self-contained, minimal example, meaning the whole code should run and create the plot as it is now, without having to load your dataset (which we don't have). Otherwise it's impossible to see what's going on and help you.
Cheers Joris On Wed, Jun 2, 2010 at 2:21 AM, Changbin Du <changb...@gmail.com> wrote: > 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@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. > > -- Joris Meys Statistical Consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control Coupure Links 653 B-9000 Gent tel : +32 9 264 59 87 joris.m...@ugent.be ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php [[alternative HTML version deleted]] ______________________________________________ R-help@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.