Hello,
I am new to machine learning. I built a random forest model to train and test my data as shown below
rf_classifier <- randomForest(x= training_set[,-20],
y = as.factor(training_set$Class.ASD),
ntree= 10)
I then used to predict the test set as below,
y_pred_rf <- predict(rf_classifier, newdata = test_set[,-20])
head(y_pred_rf)
>
1 2 4 7 9 12
NO NO NO YES YES NO
Levels: NO YES
>
I want to build a Recall-Precision curve, I did this:
rf_prediction<- prediction(y_pred_rf, test_set$Class.ASD)*
RP.perf <- performance(rf.train, "prec", "rec")
The previous gives a result;
Error: Format of predictions is invalid. It couldn't be coerced to a list.
I then used the following to check the type of structure the y_pred_rf is
sapply(c(is.vector, is.matrix, is.list, is.data.frame), do.call, list(y_pred_rf))
It shows
[1] FALSE FALSE FALSE FALSE
sapply(c(is.vector, is.matrix, is.list, is.data.frame), do.call, list(test_set$Class.ASD))
While this shows
[1] TRUE FALSE FALSE FALSE
How do I correct this in order to build the curve?