# "trainingData" "resample" "resampledCM" "perfNames" # "metric" "control" "finalModel" "preProcess" # "method" "modelInfo" "modelType" "results" Here you see that the object caret creates has class train and that it has 23 attributes: lm1 <- train(annual_pm~., data = air, method = "lm")Ĭlass(lm1) # "train" "train.formula" attributes(lm1) # $names Running the train() function creates a train object, essentially a list, with a ton of useful results. The train() function accepts several caret-specific arguments and you can also provide arguments that get fed to the underlying modeling package/function. The beauty of having caret provide the vehicle to run these models is that you can use exactly the same function, train(), to run all of the models. Streamlined and consistent syntax for more than 200 different models This enables you to build and compare models with very little overhead. #How to use the forest mods 2017 codeBehind the scenes caret takes these lines of code and automatically resamples the models and conducts parameter tuning (more on this later). Rf1 <- train(annual_pm~., data = air, method = "rf")īut this is only a taste of the power of the caret package, created by Max Kuhn who now works for RStudio. Lm1 <- train(annual_pm~., data = air, method = "lm") # and use all other variables as predictors Means use annual_pm as the model response One tiny syntax change and you run an entirely new type of model. In the second line method = "rf" tells caret to run a random forest model using the same data. In the first, method = "lm" tells caret to run a traditional linear regression model. Caret allows you to test out different models with very little change to your code and throws in near-automatic cross validation-bootstrapping and parameter tuning for free.įor example, below we show two nearly identical lines of code. The R caret package will make your modeling life easier – guaranteed. Powerful and simplified modeling with caret
0 Comments
Leave a Reply. |
AuthorKen ArchivesCategories |