0

I'm new in R. I want to calculate mean square error for my classifier (randomForest)

forest <- randomForest::randomForest(class ~ ., data = trainData, importance = TRUE, na.action = na.omit)
predForest = predict(forest, testData, type="class")
mse<-mse(testData$class, predForest)

The problem is that my function returns NA. Despite the fact that later I am adding this part:

as.numeric(as.vector(testData$class))
as.numeric(as.vector(predForest))

Do you have any guesses why it returns NA?

dataset is Iris (80:20)

EDIT

trainData is 80% of iris data. testData is 20% of iris data.

  • Can you provide [MCVE](http://stackoverflow.com/help/mcve). – m0nhawk Apr 22 '17 at 16:21
  • What do you mean? I mean what should I add here? –  Apr 22 '17 at 17:00
  • What is `trainData` and `testData`. – m0nhawk Apr 22 '17 at 17:03
  • @Klaus012 Are you trying to run a classification problem or regression problem, i may be wrong but mse is metric usually used for regression problem, but the example you have shown seems to be a classification problem, I have deleted my answer since I got also confused. Please elaborate your problem little bit more, I am unable to make out what is the problem you are trying to solve. I am also unable to replicate your problem also. Thanks – PKumar Apr 22 '17 at 17:05
  • trainData is 80% of iris data. testData is 20% of iris data This is ordinal regression problem. In other words this is the classification task for the ordinal data. –  Apr 22 '17 at 19:16

0 Answers0