How to interpret the outputs from a LASSO regularization technique in R




1.While trying to learn about regularization techniques I am trying to use the Lasso fitting algorithm via:


# Set sample:
set.seed(321); i.train <- sample(1:97, 67)
x.train <- prostate[i.train, 1:8]; y.train <- prostate[i.train, 9]
x.test <- prostate[-i.train, 1:8]; y.test <- prostate[-i.train, 9]

fit.lasso <- lars(as.matrix(x.train), y.train, type="lasso")
plot(fit.lasso, breaks=F, xvar="norm")

The last command generates a plot:

In the resource that I am using it is given that the last command plots the co-efficient paths for the fit.
I wanted to know how to interpret the above figure and what exactly does a co-efficient path mean?

  1. Next to select the optimal value of the coefficient vector a along these paths,we use cross validation as:

    cv.lasso <- cv.lars(as.matrix(x.train), y.train, type=“lasso”)
    which generates:

    How do I interpret this graph??
    Can somebody please help me with these questions,I am stuck for a long time on these!!


hi plz use this it will give you the best step , or by graph you see which step is near to ‘0’

select a step with a minimum error

best_step <- fit.lasso$df[which.min(fit$RSS)]