Random Forest Error : Error in y - ymean : non-numeric argument to binary operator

0 votes
Please help! Error with RandomForest using the diabetics dataset.

Code -

random_forest = randomForest(Class.variable~.,data = train,ntree = 10,importance = T)

Error -
Error in y - ymean : non-numeric argument to binary operator
In addition: Warning messages:
1: In randomForest.default(m, y, ...) :
  The response has five or fewer unique values.  Are you sure you want to do regression?
2: In mean.default(y) : argument is not numeric or logical: returning NA
Oct 7 in Data Analytics by ch
• 2,430 points
57 views

1 answer to this question.

0 votes

Hey,

Convert the Class.variable to factor then it might work.

random_forest = randomForest(as.factor(Class.variable)~.,data = train,ntree = 10,importance = T)
answered Oct 9 by Cherukuri
• 28,280 points

Related Questions In Data Analytics

+5 votes
0 answers
0 votes
1 answer

How to change y axis max in time series using R?

The axis limits are being set using ...READ MORE

answered Apr 3, 2018 in Data Analytics by darklord
• 6,170 points
135 views
0 votes
1 answer

How to sample random rows in dataframe?

Create data frame and then implement as ...READ MORE

answered Jul 2, 2018 in Data Analytics by darklord
• 6,170 points
51 views
0 votes
1 answer

How to sample n random rows per group in a dataframe?

You can assign a random ID to ...READ MORE

answered Jul 2, 2018 in Data Analytics by darklord
• 6,170 points
265 views
0 votes
0 answers

How to display randomforest object?

How to display random forest object? I created ...READ MORE

Oct 1 in Data Analytics by ch
• 2,430 points
10 views
0 votes
1 answer

RandomForest Error

If the classifying variable data type is ...READ MORE

answered Oct 13 in Data Analytics by Cherukuri
• 28,280 points
13 views
0 votes
1 answer

By using dpylr package sum of multiple columns

Basically here we are making an equation ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
106 views
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
138 views