Shiny R中模型训练的进度条 [英] Progress Bar for Model Training in Shiny R
问题描述
我正在制作一个Shiny App,在其中,单击actionButton时,可以使用插入符号包对模型进行训练.由于此培训需要时间-大约4-5分钟-我想显示一个进度条,该进度条会在模型训练时进行.
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.
谢谢
推荐答案
要在闪亮的应用程序中显示进度栏,您需要在 server
中使用 withProgress
函数,如下所示:
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
})
因此,您将代码放入此函数中,并且在代码运行时,它将显示消息模型正在训练".函数中的 value
是应用程序中的进度指示器(1.0是100%).您可以根据计算进行设置.例如,您可以设置 value = min +(max-min)* 0.1
.它不必完全像这样.任何适合您的代码都取决于您.设置 value = 1.0
不会有任何问题,因为在您的案例"Model is Training"中,它会显示进度条及其有意义且相关的消息.
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".
要获取更多信息,请访问以下链接: https://shiny.rstudio.com/reference/shiny/latest/withProgress.html
To get more info, visit this link: https://shiny.rstudio.com/reference/shiny/latest/withProgress.html
这篇关于Shiny R中模型训练的进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!