
Prediction of test data using ordinal forest.
# S3 method for ordfor
predict(object, newdata, ...)
object of class ordfor
. See function ordfor
.
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:
vector of length nrow(newdata)
. Factor-valued test data predictions.
vector of length nrow(newdata)
. Numeric test data predictions: Result of applying the regression forest forestfinal
returned by ordfor
.
# NOT RUN {
data(hearth)
set.seed(123)
trainind <- sort(sample(1:nrow(hearth), size=floor(nrow(hearth)*(1/2))))
testind <- setdiff(1:nrow(hearth), trainind)
datatrain <- hearth[trainind,]
datatest <- hearth[testind,]
ordforres <- ordfor(depvar="Class", data=datatrain, ndiv=80, nbest=5)
# NOTE: ndiv=80 is not enough!! In practice, ndiv=1000 (default value) or a higher
# number should be used.
preds <- predict(ordforres, newdata=datatest)
preds
table(data.frame(true_values=datatest$Class, predictions=preds$ypred))
par(mfrow=c(1,2))
plot(preds$yforestpredmetric, as.numeric(preds$ypred))
plot(pnorm(preds$yforestpredmetric), as.numeric(preds$ypred), xlim=c(0,1))
par(mfrow=c(1,1))
# }
Run the code above in your browser using DataLab