Skip to Content
Advanced Machine Learning with R
book

Advanced Machine Learning with R

by Cory Lesmeister, Dr. Sunil Kumar Chinnamgari
May 2019
Intermediate to advanced
664 pages
15h 41m
English
Packt Publishing
Content preview from Advanced Machine Learning with R

Model training

Training the model is quite interesting, I believe. We will pass the model to the fit() function, having specified the features, response, number of epochs, and validation percentage at each epoch. Here, I have gone with 100 epochs, and 20% of the training data for validation:

> epochs <- 100> # Fit the model and store training stats> history <- model %>% fit(    trainT,    train_logy,    epochs = epochs,    validation_split = 0.2,    verbose = 0)

You can examine the history object on your own, but what is very powerful is to plot the training and validation error for each epoch:

> plot(history, metrics = "mean_absolute_error", smooth = FALSE) 

The output of the preceding code is as follows:

Notice how much the error differs between training ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Machine Learning Using R

Machine Learning Using R

Karthik Ramasubramanian, Abhishek Singh
Machine Learning with R Cookbook - Second Edition

Machine Learning with R Cookbook - Second Edition

AshishSingh Bhatia, Yu-Wei, Chiu (David Chiu)
Practical Machine Learning in R

Practical Machine Learning in R

Fred Nwanganga, Mike Chapple

Publisher Resources

ISBN: 9781838641771Supplemental Content