-
-
Notifications
You must be signed in to change notification settings - Fork 26.2k
Description
I am currently attempting to fit a Non Negative Least Square with an l2 penalization without having to reimplement it.
The solution I have adopted is to use ElasticNet(positive=True, l1_ratio=0)
, but this yields confusing warning messages.
Description
I am using ElasticNet with the parameter l1_ratio=0
and positive=True
. It yields a confusing warning message, as the warning message refers to a parameter called alpha
, supposedly set to 0
, but the only alpha
parameter the user has access to is not set to 0
In [8]: %run test_elasticnet_as_ridge.py
/home/nelle/.envs/goldwrap/lib/python3.5/site-packages/sklearn/linear_model/coordinate_descent.py:470: UserWarning: Coordinate descent with alpha=0 may lead to unexpected results and is discouraged.
positive)
In [9]: est.alpha
Out[9]: 1.0
My assumption is that ElasticNet is not meant to be used with l1_ratio=0
, which should be explictily mentioned, though this is as well unclear as the documentation mentions the following: Currently, l1_ratio <= 0.01 is not reliable, unless you supply your own sequence of alpha.
and alpha
is a float, set by default to 1.
Steps/Code to Reproduce
from sklearn import linear_model
import numpy as np
n = 1000
X = np.random.randn(n, 3)
beta = np.array([2, 3, 2])
Y = np.dot(X, beta) + np.random.randn(n)
est = linear_model.ElasticNet(positive=True, l1_ratio=0)
est.fit(X, Y)