Need Help in understanding the Code



I was trying to solve Big Mart Sales problem and found below in one of the blog.I am unable to understand if below is the syntax for Lasso Regression

my_control = trainControl(method=“cv”, number=5)
Grid = expand.grid(alpha = 0, lambda = seq(0.001,0.1,by = 0.0002))

lasso_linear_reg_mod3 = train(x = Train[, -c(1,2)], y = Train$Item_Outlet_Sales,
method=‘glmnet’, trControl= my_control, tuneGrid = Grid)


This is Ridge Regression because the parameter alpha = 0. For Lasso alpha is kept as 1.


Thanks pjoshi in helping me by segregating two syntax using alpha value but I guess I need to be more clear with my question.
if I have to use the lasso regression then train(c,y,method,trcontrol,tunegrid) is the syntax ?
as I read at most places that this train function is for training and syntax is something else.


@v.vicky000 this train() function is from the caret package. I’d suggest you to go through the below course as it has implementation of both Ridge and Lasso Regression in R.


Thank you So Much… Though I had already gone through this case but your mention of Caret package helped me lot.