- load("D:\\Desktop\\试验.Rdata")
- ui=fluidPage(
- tags$head(
- tags$style(HTML("
- .shiny-input-container {
- font-size: 17px; /* 修改 numericInput 的字体大小 */
- }
- .shiny-input-container input{
- font-size: 17px;
- }
- "))
- ),
- titlePanel("随机森林预测模型"),
- sidebarLayout(
- sidebarPanel(
- numericInput("SBP","平均SBP",50,min=1,max=500),
- numericInput("DBPCV","DBPCV",0.001,min=0,max=0.1),
- selectInput("动脉瘤位置","动脉瘤位置",c("MCA", "ICA" ,"ACA", "PC" ),multiple=F),
- actionButton("predict", "预测")
- ),#######################
- mainPanel(
- HTML("<b><span style='font-size: 32px;'>预测结果</span></b>"), tags$br(),
- htmlOutput("text_output"),tags$br(),tags$br(),
- plotOutput("warm",width = "100%",height = "450px"),
- plotOutput("warmm",width = "100%",height = "450px")
- )
- )
- )
- server=function(input,output,session){
- input_data=reactive({
- data.frame(
- 平均SBP=input$SBP,
- DBPCV=input$DBPCV,
- 动脉瘤位置=input$动脉瘤位置)
- }) ##############
- observeEvent(input$predict,{
- prob=predict(model,input_data())$predictions[2]
- output$text_output=renderUI({
- HTML(paste("<span style='color: red; font-size:25px;'>","此病人患病的概率为:",round(prob,3), "</span>"))
- })
- output$warm=renderPlot(sv_importance(shv) + theme(axis.text = element_text(size = 16)) + theme(axis.title = element_text(size = 16)))
- output$warmm=renderPlot(sv_importance(shv, kind = "beeswarm")+ theme(axis.text = element_text(size = 16)) + theme(axis.title = element_text(size = 16)))
- })
- }
- shinyApp(ui,server)
问题来了集美集帅们怎么做?针对自己的数据要改哪些代码?
- #########第15-16括号中根据自己需要进行增加及减少
- numericInput("SBP","平均SBP",50,min=1,max=500) #连续性变量
- selectInput("动脉瘤位置","动脉瘤位置",c("MCA", "ICA" ,"ACA", "PC" ),multiple=F)#分类变量
- #########相应的后端也需要修改,用于传输输入的数据32-36行
- 平均SBP=input$SBP
- 动脉瘤位置=input$动脉瘤位置
效果图:
又是一个不眠之夜睡觉!!!



雷达卡




京公网安备 11010802022788号







