Error in y - ymean: non-numeric argument for binary operator randomForest R

I have a matrix about 37k x 1024 in size consisting of 1s and 0s as categorical variables indicating the existence or absence of a feature vector. I ran this matrix through the randomForest package in R as follows:

rfr <- randomForest(X_train,Y_train)

Where X_train is a matrix containing categorical variables, and Y__train is a vector consisting of labels for each row in the matrix. When I run this, I get the following error:

Error in y - ymean : non-numeric argument to binary operator
In addition: Warning message:
In mean.default(y) : argument is not numeric or logical: returning NA

I checked for any null values ​​or missing data, but could not find them.

I even did it all in data.frame and tried the following

rfr <- randomForest(labels ~ ., data = featureDF)

All the same mistakes.

I would be grateful for any help with this, thanks!

+4
1

, labels , randomForest , . , :

featureDF$labels = factor(featureDF$labels) 

randomForest , , :

y  A response vector. If a factor, classification is assumed, otherwise   
   regression is assumed. If omitted, randomForest will run in unsupervised mode.

, iris:

Species . Species :

iris$Species = as.character(iris$Species)
rf <- randomForest(Species ~ ., data=iris)
Error in y - ymean : non-numeric argument to binary operator

Species randomForest .

iris$Species = factor(iris$Species)
rf <- randomForest(Species ~ ., data=iris)
+6

Source: https://habr.com/ru/post/1653609/


All Articles