Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

CDClassifier : error for penalty="l1" and penalty="l2", but no error for penalty="l1/l2" #202

Open
Sandy4321 opened this issue Jul 31, 2023 · 5 comments

Comments

@Sandy4321
Copy link

CDClassifier : error for penalty="l1" and penalty="l2", but no error for penalty="l1/l2"

from lightning.classification import CDClassifier #Estimator for learning linear classifiers by (block) coordinate descent
clf = CDClassifier(loss="squared_hinge",
penalty="l2",
#penalty="l1/l2", #
multiclass=False,
max_iter=20,
alpha=1e-4,
C=1.0 / X_train_vectorised.shape[0],
tol=1e-3,
n_jobs =5)
#
clf.fit(X_train_vectorised, y_train)

clf.fit(X_train_vectorised, y_train)
File "c:\my_py_environments\py310_env_apr2023\lib\site-packages\lightning\impl\primal_cd.py", line 258, in fit
y, n_classes, n_vectors = self._set_label_transformers(y,
File "c:\my_py_environments\py310_env_apr2023\lib\site-packages\lightning\impl\base.py", line 78, in _set_label_transformers
y = y.astype(np.int32)

builtins.AttributeError: 'list' object has no attribute 'astype'

@Sandy4321
Copy link
Author

X_train_vectorised
<1177x4883 sparse matrix of type '<class 'numpy.float64'>'
with 87732 stored elements in Compressed Sparse Row format>
y_train
['0\n', '1\n', '0\n', '1\n', '1\n']

same error for reformating y_train = [int(x) for x in y_train]

@DhruvSanghvi2002
Copy link

I want to solve this issue , @Sandy4321

@mblondel
Copy link
Member

@Sandy4321 y needs to be a numpy array of integers, you used a list of strings.

@Sandy4321
Copy link
Author

thanks

@Sandy4321
Copy link
Author

by the way is it possible to predict with probability like scikit learn
https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html
predict_proba(X) Probability estimates.
image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants