Progress Bar for Model Training in Shiny R

陌路散爱 提交于 2020-01-05 08:45:13

问题


I am making a Shiny App in which, at the click of the actionButton, a model is trained using the caret package. As this training takes time - approximately 4-5 minutes - I wanted to display a progress bar which progresses as the model is trained.

Thanks


回答1:


To display progress bar in shiny app, you need to use withProgress function in server as below:

withProgress(message = "Model is Training", value = 1.0, {             
   ## Your code
})

So, you put your code inside this function and it will display the message "Model is training" while your code is running. value in the function is a progress indicator in the app (1.0 is 100%). This you can set depending on computation. For example, you can set value = min + (max - min) * 0.1. It needs not to be exactly like this. Anything that works for you which depend on the code. Setting value = 1.0 wouldn't hurt because it display the progress bar with its meaningful and relevant message in your case "Model is Training".

To get more info, visit this link: https://shiny.rstudio.com/reference/shiny/latest/withProgress.html



来源:https://stackoverflow.com/questions/46700360/progress-bar-for-model-training-in-shiny-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!