O'Reilly logo

R Statistical Application Development by Example Beginner's Guide by Prabhanjan Narayanachar Tattar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – selecting lambda iteratively and other topics

Iterative selection of the penalty parameter for ridge regression will be covered in this section. The useful framework of train + validate + test will also be considered for the German credit data problem.

  1. For the sake of simplicity, we will remove the character variable of the dataset by using Gasoline <- Gasoline[,-12].
  2. Set the random seed by using set.seed(1234567). This step is to ensure that the user can validate the results of the program.
  3. Randomize the observations to enable the splitting part:
    data_part_label = c("Train","Validate","Test")
    indv_label=sample(data_part_label,size=nrow(Gasoline),replace=TRUE ,prob=c(0.6,0.2,0.2))
  4. Now, split the gasoline dataset:
    G_Train <- Gasoline[indv_label=="Train",] ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required