benchopt / benchopt/benchmark_lasso
what does lightning do with intercept?
- Dominant language
- Python
- Stars
- 14
- Forks
- 24
- PR merge metrics
- No merged PRs in 30d
Description
We comment saying that lightning always fits an intercept:
https://github.com/benchopt/benchmark_lasso/blob/main/solvers/lightning.py#L10
and indeed it has an attribute `intercept_` after fitting.
but if I fit with a constant `y`, I don't get the solution I'd expect with an intercept:
```python
import numpy as np
from numpy.linalg import norm
from lightning.regression import CDRegressor
from sklearn.linear_model import Lasso
np.random.seed(0)
X = np.random.randn(20, 50)
y = 12 * np.ones(X.shape[0])
alpha = norm(X.T @ y, ord=np.inf) / 10
clf = CDRegressor(C=0.5, alpha=alpha, penalty='l1',
tol=1-30, random_state=0, permute=False,
shrinking=False).fit(X, y)
las = Lasso(fit_intercept=True, alpha=alpha/len(y), max_iter=100_000,
tol=1e-10).fit(X, y)
print("intercepts:")
print(las.intercept_) # 12
print(clf.intercept_) # not 12, 0
print("coef norm:")
print(norm(las.coef_)) # is 0 as expected
print(norm(clf.coef_)) # not zero
```
output:
```
intercepts:
12.0 # sklearn
[0.]
coef norm:
0.0 # sklearn
8.548795604837427
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.