Search code examples
pythonglmnet

glmnet.ElastiNet:lambda_path argument


I am learning from:

https://github.com/JWarmenhoven/ISLR-python/blob/master/Notebooks/Chapter%206.ipynb

and have issues with following code:

grid = 10**np.linspace(10,-2,100)

ridge3 = gln.ElasticNet(alpha=0, lambda_path=grid)
ridge3.fit(X, y)

What does lambda_path argument mean? I am using Python.


Solution

  • What does lambda_path argument mean? I am using Python.

    Here lambda has nothing to do with Python.

    In Python, lambda is a function, which comes from lambda calculus.

    In lasso and elastic-net regularization, lambda is a regularization penalty coefficient. In other words, it is a number. And lambda_path is a sequence of numbers. In the code example you given, the sequences is generated automatically. And ridge3.fit will performance training for every number of the lambda sequence.

    P.S. In Mathematics, to keep formula short so humans can write formula quickly, Mathematics uses single letter variable name a lot without namespace prefix. However, there are not so many letters, so conflicts occur. Here both lambda calculus and regularization choose the Greek letter λ, which may cause your confusion.