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
• 3,290 points
168 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
• 32,260 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,190 points
219 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,190 points
61 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,190 points
456 views
0 votes
1 answer

How to display randomforest object?

Refer to this article here, https://stats.stackexchange.com/questio ...READ MORE

answered Oct 28 in Data Analytics by Cherukuri
• 32,260 points
19 views
0 votes
1 answer

RandomForest Error

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

answered Oct 13 in Data Analytics by Cherukuri
• 32,260 points
22 views
0 votes
1 answer

Will random forest algorithm work if rows have a few duplicate values?

I have no idea about RandomForest, but ...READ MORE

answered Oct 28 in Data Analytics by Cherukuri
• 32,260 points
47 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
124 views