获得3个预测模型并使用预测来使用每个模型预测来组成矩阵以填充列。
predictions.rda
target;ctree;gbm;svm
a;a;a;b
b;b;b;c
c;a;c;c
保存为 rda 文件,我尝试使用闪亮加载一些混淆矩阵。用户必须选择其中一个模型,页面必须从加载的模型矩阵中呈现输出。
library(shiny)
shinyUI(fluidPage(
titlePanel("MODELS"),
sidebarLayout(
sidebarPanel(
selectInput(inputId = "model",
label = "choose Model:",
choices = c("Conditional Inference Tree" = "predictions$ctree",
"Gradient Boosting Machine" = "predictions$gbm",
"Suppor Vector Machine" = "predictions$svm"
),
selected = "predictions$ctree")
),
mainPanel(
textOutput("matrix")
)
)
))
shinyServer(function(input, output) {
require(caret)
load(predictions.rda)
output$matrix <- renderPrint({
# this line worked fine
# confusionMatrix(predictions$target,predictions$ctree)
#this line does not work
confusionMatrix(predictions$target,input$model)
})
})
输出结果为:
错误:数据的级别不能超过参考值。