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
1,452 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, 2019 by Cherukuri
• 32,490 points

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 in Data Analytics by Nurdiana
• 120 points

recategorized Sep 7 by Gitika 26 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,320 points
885 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 Sahiti
• 6,320 points
186 views
0 votes
1 answer

How to display randomforest object?

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

answered Oct 28, 2019 in Data Analytics by Cherukuri
• 32,490 points
73 views
+1 vote
1 answer

RandomForest Error

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

answered Oct 13, 2019 in Data Analytics by Cherukuri
• 32,490 points
64 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 28, 2019 in Data Analytics by Cherukuri
• 32,490 points
530 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
823 views
+2 votes
1 answer
0 votes
1 answer