# 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, nsets=60, nbest=5)
# NOTE: nsets=60 is not enough, because the prediction performance of the resulting
# ordinal forest will be suboptimal!! In practice, nsets=1000 (default value) or a
# number should be used.
preds <- predict(ordforres, newdata=datatest)
perfm_equal(ytest=datatest$Class, ytestpred=preds$ypred)
perfm_irrespective(ytest=datatest$Class, ytestpred=preds$ypred)
perfm_onecateg(ytest=datatest$Class, ytestpred=preds$ypred, categ="1")
perfm_onecateg(ytest=datatest$Class, ytestpred=preds$ypred, categ="2")
perfm_onecateg(ytest=datatest$Class, ytestpred=preds$ypred, categ="3")
perfm_onecateg(ytest=datatest$Class, ytestpred=preds$ypred, categ="4")
perfm_onecateg(ytest=datatest$Class, ytestpred=preds$ypred, categ="5")
perfm_custom(ytest=datatest$Class, ytestpred=preds$ypred, categweights=c(1,2,1,1,1))
# perfm_equal(), perfm_irrespective(), and perfm_onecateg() are special cases of perfm_custom():
perfm_custom(ytest=datatest$Class, ytestpred=preds$ypred, categweights=c(1,1,1,1,1))
perfm_equal(ytest=datatest$Class, ytestpred=preds$ypred)
perfm_custom(ytest=datatest$Class, ytestpred=preds$ypred, categweights=table(datatest$Class))
perfm_irrespective(ytest=datatest$Class, ytestpred=preds$ypred)
perfm_custom(ytest=datatest$Class, ytestpred=preds$ypred, categweights=c(0,2,0,0,0))
perfm_onecateg(ytest=datatest$Class, ytestpred=preds$ypred, categ="2")
# }
Run the code above in your browser using DataLab