predict | R Documentation |
Predict values of random forest model response variables from new data.
predict(
model,
new_data,
idx = NULL,
type = c("response", "prob", "votes"),
...
)
## S4 method for signature 'RandomForest,AnalysisData'
predict(
model,
new_data,
idx = NULL,
type = c("response", "prob", "votes"),
...
)
model |
S4 object of class |
new_data |
S4 object of class |
idx |
sample information column to use for sample names. If |
type |
one of |
... |
arguments to pass to |
The features contained within new_data
should match those of the features used to train model
.
The features()
method can be used to check this.
The argument returnModels = TRUE
should also be used when training the RandomForest-class
object used for argument model
.
library(metaboData)
## Prepare some data
x <- analysisData(abr1$neg[,200:300],abr1$fact) %>%
occupancyMaximum(cls = 'day') %>%
transformTICnorm()
## Extract data from which to train a random forest model
training_data <- x %>%
keepClasses(cls = 'day',
classes = c('H','1'))
## Extract data for which response values will be predicted
test_data <- x %>%
keepClasses(cls = 'day',
classes = c('2','3'))
rf <- randomForest(training_data,
cls = 'day',
returnModels = TRUE)
predict(rf,
test_data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.