JMark
2010-Apr-08 17:18 UTC
[R] RandomForest how to identify two classes when only one is present
I'm trying to do: randomForest(f, data = moths.train) But I get this error: Error in randomForest.default(m, y, ...) : Need at least two classes to do classification. When I look at the data for this, I realize there are no positive cases of this item: [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [38] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [75] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [112] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [149] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Levels: 0 Is there a way to show RandomForest that both 0 and 1 are possible and run randomForest? Thanks -- View this message in context: http://n4.nabble.com/RandomForest-how-to-identify-two-classes-when-only-one-is-present-tp1774388p1774388.html Sent from the R help mailing list archive at Nabble.com.
Steve Lianoglou
2010-Apr-08 21:45 UTC
[R] RandomForest how to identify two classes when only one is present
Hi, On Thu, Apr 8, 2010 at 1:18 PM, JMark <bjmethari at gmail.com> wrote:> > I'm trying to do: > randomForest(f, data = moths.train) > > But I get this error: > Error in randomForest.default(m, y, ...) : > ?Need at least two classes to do classification. > > When I look at the data for this, I realize there are no positive cases of > this item: > ?[1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 > 0 0 > ?[38] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 > 0 0 > ?[75] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 > 0 0 > [112] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 > 0 0 > [149] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 > 0 > Levels: 0 > > Is there a way to show RandomForest that both 0 and 1 are possible and run > randomForest?Even if both 0 and 1 are "possible," you are not giving it any examples of the opposite class ... what do you expect it to learn? -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact