Closed
Description
Describe the bug
Please remove the checks to allow sparse matrices in Lasso and ElasticNet since it actually is already supported.
raise ValueError(
"Sample weights do not (yet) support sparse matrices."
)
Relevant files are:
ElasticNet.fit(...):
l.956 sklearn/linear_model/_coordinate_descent.py
Steps/Code to Reproduce
import sklearn.linear_model as lm
import scipy.sparse as sp
import numpy as np
N = 5
NN = 3
X = sp.csc_matrix((range(NN), (range(NN), range(NN))), shape=(N,N))
W = np.ones(N).reshape(-1)
y = np.array(range(N)).reshape(-1)
mdl = lm.Lasso(.1) # Same for lm.ElasticNet()
mdl.fit(X, y, W)
mdl.coef_
Expected Results
array([ 0. , -0.625, -0. , 0. , 0. ])
Actual Results
ValueError: Sample weights do not (yet) support sparse matrices.
Versions
System:
python: 3.7.4 (default, Aug 9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)]
executable: C:\Python\conda\python.exe
machine: Windows-10-10.0.19041-SP0
Python dependencies:
pip: 19.2.3
setuptools: 41.4.0
sklearn: 1.0.1
numpy: 1.21.4
scipy: 1.7.2
Cython: 0.29.13
pandas: 1.3.4
matplotlib: 3.1.1
joblib: 0.13.2
threadpoolctl: 3.0.0
Built with OpenMP: True
Metadata
Metadata
Assignees
Labels
No labels