randomForest - classifier switch

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

randomForest - classifier switch

Stephen Choularton
Hi
 
I am trying to use randomForest for classification. I am using this
code:
 
> set.seed(71)
> rf.model <- randomForest(similarity ~ ., data=set1[1:100,],
importance=TRUE, proximity=TRUE)
Warning message:
The response has five or fewer unique values.  Are you sure you want to
do regression? in: randomForest.default(m, y, ...)
> rf.model
 
Call:
 randomForest(x = similarity ~ ., data = set1[1:100, ], importance =
TRUE,      proximity = TRUE)
               Type of random forest: regression
                     Number of trees: 500
No. of variables tried at each split: 10
 
          Mean of squared residuals: 0.1159130
                    % Var explained: 50.8
>
 
As you can see I get a regression model.  How can I make sure I get a
classification model?
 
Thanks .
 
Stephen

--



2/01/2006
 

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: randomForest - classifier switch

Liaw, Andy
From: Stephen Choularton

>
> Hi
>  
> I am trying to use randomForest for classification. I am using this
> code:
>  
> > set.seed(71)
> > rf.model <- randomForest(similarity ~ ., data=set1[1:100,],
> importance=TRUE, proximity=TRUE)
> Warning message:
> The response has five or fewer unique values.  Are you sure
> you want to
> do regression? in: randomForest.default(m, y, ...)
> > rf.model
>  
> Call:
>  randomForest(x = similarity ~ ., data = set1[1:100, ], importance =
> TRUE,      proximity = TRUE)
>                Type of random forest: regression
>                      Number of trees: 500
> No. of variables tried at each split: 10
>  
>           Mean of squared residuals: 0.1159130
>                     % Var explained: 50.8
> >
>  
> As you can see I get a regression model.  How can I make sure I get a
> classification model?

By making sure your response variable is a factor, e.g.,

  set1$similarity <- as.factor(set1$similarity)

Andy

 

> Thanks .
>  
> Stephen
>
> --
>
>
>
> 2/01/2006
>  
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html