View source: R/predict.ordfor.R
predict.ordfor | R Documentation |
Prediction of test data using ordinal forest.
## S3 method for class 'ordfor' predict(object, newdata, ...)
object |
object of class |
newdata |
data.frame. Data frame containing new data. |
... |
further arguments passed to or from other methods. |
predict.ordfor
returns an object of class ordforpred
.
An object of class "ordforpred
" is a list containing the following components:
ypred |
vector of length |
classprobs |
predicted class probabilities. Only provided, if the performance function based on the ranked probability score was used, while training the ordinal forest (see |
Hornung R. (2020) Ordinal Forests. Journal of Classification 37, 4–17. <doi: 10.1007/s00357-018-9302-x>.
## Not run: data(hearth) set.seed(123) trainind <- sort(sample(1:nrow(hearth), size=floor(nrow(hearth)*(1/2)))) testind <- sort(sample(setdiff(1:nrow(hearth), trainind), size=20)) datatrain <- hearth[trainind,] datatest <- hearth[testind,] ordforres <- ordfor(depvar="Class", data=datatrain, perffunction = "probability", nsets=50, nbest=5, ntreeperdiv=100, ntreefinal=1000) # NOTE: nsets=50 is not enough, because the prediction performance of the resulting # ordinal forest will be suboptimal!! In practice, nsets=1000 (default value) or a larger # number should be used. preds <- predict(ordforres, newdata=datatest) preds table(data.frame(true_values=datatest$Class, predictions=preds$ypred)) head(preds$classprobs) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.