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, 2019 in Data Analytics by ch
• 3,450 points
13,251 views

1 answer to this question.

+1 vote

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, 2019 by Cherukuri
• 33,030 points
You saved my life
THANK YOU SO MUCH!!

Related Questions In Data Analytics

+5 votes
0 answers
0 votes
0 answers

Error in xy.coords(x, y, xlabel, ylabel, log) : argument "x" is missing, with no default

Hi, my code is showing this, what's ...READ MORE

Sep 7, 2020 in Data Analytics by Nurdiana
• 120 points

recategorized Sep 7, 2020 by Gitika 1,955 views
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 Sahiti
• 6,370 points
3,831 views
0 votes
1 answer

How to sample random rows in dataframe?

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

answered Jul 3, 2018 in Data Analytics by Sahiti
• 6,370 points
861 views
0 votes
1 answer

How to display randomforest object?

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

answered Oct 29, 2019 in Data Analytics by Cherukuri
• 33,030 points
736 views
+1 vote
1 answer

RandomForest Error

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

answered Oct 14, 2019 in Data Analytics by Cherukuri
• 33,030 points
667 views
+10 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 29, 2019 in Data Analytics by Cherukuri
• 33,030 points
2,939 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
2,250 views
+2 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP