How can I use result of randomForest call in R to predict labels on some unlabled data (e.g. real world input to be classified)?
Code:
train_data = read.csv("train.csv")
input_data = read.csv("input.csv")
result_forest = randomForest(Label ~ ., data=train_data)
labeled_input = result_forest.predict(input_data) # I need something like this
train.csv:
a;b;c;label;
1;1;1;a;
2;2;2;b;
1;2;1;c;
input.csv:
a;b;c;
1;1;1;
2;1;2;
I need to get something like this
a;b;c;label;
1;1;1;a;
2;1;2;b;
predict(result_forest, newdata=input_data).predict, so I'd guess this question is probably a duplicate. No need for me to add an answer. The key thing to remember for future reference is that just about every modeling function is R has apredict"method", meaning that if you runpredicton the model object, it will return predictions for the training data by default, or predictions for new data if you use thenewdataargument.