0

I am doing prediction in R using

model<- train(Label~., data = training, trControl=train_control, method="rf")
Predict_RF <-predict(model, newdata = testing)

How can I do the prediction for all samples? I mean, if I want to do the prediction not only for the test set (doing it even for the samples inside the training set), how I can do that?

Appreciate.

Ester Silva
  • 670
  • 6
  • 24
  • It would be helpful if you could provide us with a reproducible [minimal working example](https://en.wikipedia.org/wiki/Minimal_working_example) that we can copy and paste to better understand the issue and test possible solutions. You can share datasets with `dput(YOUR_DATASET)` or smaller samples with `dput(head(YOUR_DATASET))`. (See [this answer](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example#5963610) for some great advice.) – ktiu Jun 10 '21 at 11:06
  • 1
    `predict(model, newdata = testing)` followed by `predict(model, newdata = training)`. Sometimes life is easy when kept simple and seperate. Or if you have a full dataset, lets call it `df`, then `predict(model, newdata = df)`. – Oliver Jun 10 '21 at 11:08

0 Answers0