我正在创建机器学习模型,为了对我的模型的性能进行评分,我正在研究的一个方面是模型运行所需的时间。
我有以下代码:
start_time <- Sys.time()
predictions <- class.tree.predictions(traindata, testdata)
end_time <- Sys.time()
run_time <- end_time - start_time当存在秒时差时,输出为“时差0.23204秒”,而当时差以分钟为单位时,输出为“时间差1.05204分钟”。
我只需要输出几秒钟,或者我需要一个if语句,当时差是分钟,所以它可以乘以60,但我不知道如何去做。
发布于 2022-11-14 03:39:20
difftime有一个units选项
difftime(end_time, start_time, units="secs")https://stackoverflow.com/questions/74426586
复制相似问题