简体   繁体   English

如何使用插入包构建模型时跟踪进度?

[英]How to track a progress while building model with the caret package?

I am trying to build model using train function from caret package: 我正在尝试使用插入包中的列车功能来构建模型:

 model <- train(training$class ~ .,data=training, method = "nb")

Training set contains about 20K observations, each observation has above 100 variables. 训练集包含大约20K的观测值,每个观测值都有100个以上的变量。 I would like to know if building a model from that dataset will take hours or days. 我想知道从该数据集构建模型是否需要数小时或数天。

How to estimate time needed to train model from data? 如何估算从数据中训练模型所需的时间? How track a progress of training process when using functions from caret package? 使用插入包中的功能时如何跟踪培训过程的进度?

Assuming that you are training the model with 假设你正在训练模型

  • an expanded grid of tuning parameters (all combinations of the tuning parameters) 扩展的调整参数网格(调整参数的所有组合)
  • and a resampling technique of your choice (cross validation, bootstrap etc) 和您选择的重采样技术(交叉验证,引导程序等)

You could set 你可以设置

trainctrl <- trainControl(verboseIter = TRUE)

and set it in the trControl argument of the train function to track the training progress 并将其设置在列车功能的trControl参数中以跟踪培训进度

model <- train(training$class ~ .,data=training, method = 'nb', trControl = trainctrl)

This prints out the progress out to the console at each resampling stage, and allows you to gauge the progress of the training/parameter tuning. 这会在每个重新采样阶段打印出控制台的进度,并允许您衡量培训/参数调整的进度。

To estimate the total running time, you could run the model once to see how long it runs, and estimate the total time by multiplying accordingly based on your resampling scheme and number of parameter combinations. 要估计总运行时间,您可以运行模型一次以查看其运行时间,并根据重新采样方案和参数组合数量相应地相乘,估算总时间。 This can be done by setting the trainControl again, and setting the tuneLength to 1: 这可以通过再次设置trainControl并将tuneLength设置为1来完成:

trainctrl <- trainControl(method = 'none')
model <- train(training$class ~ ., data = training, method = 'nb', trControl = trainctrl, tuneLength = 1)

Hope this helps! 希望这可以帮助! :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM