As described in #1277, I was surprised that training a linear regression model was much slower with caret than directly calling the function stats::lm. Diving deeper into this issue, the reason for that is the use of the function system.time to measure the execution time for training the final model. Replacing this with two calls to proc.time seems to solve the issue. You can find two benchmarks (with and without the changes) below.
As described in #1277, I was surprised that training a linear regression model was much slower with caret than directly calling the function
stats::lm
. Diving deeper into this issue, the reason for that is the use of the functionsystem.time
to measure the execution time for training the final model. Replacing this with two calls toproc.time
seems to solve the issue. You can find two benchmarks (with and without the changes) below.Old version
New version
The only difference between
caret_lm
andcaret_lm2
is thatcaret_lm2
skips the call togetModelInfo
.