Skip to content
Advertisement

Cannot get L1 ratio in LogisticRegressionCV object

I am trying to fit an elastic net model using LogisticRegressionCV. I want to see what L1 ratio LogisticRegressionCV chooses after cross validation. I read from its documentation that after fitting we can access it by its attribute l1_ratio_. But when I tried this, it failed.

The code is:

from sklearn.linear_model import LogisticRegressionCV
from sklearn.datasets import load_iris
X, y = load_iris(return_X_y=True)
clf = LogisticRegressionCV(Cs=10,cv=3,penalty='elasticnet',refit=True, n_jobs=-1,solver='saga',max_iter=1000).fit(X, y)
clf.l1_ratio_

It returns :

AttributeError: ‘LogisticRegressionCV’ object has no attribute ‘l1_ratio_’

Sklearn version: 0.19.2

Advertisement

Answer

The ElasticNet penalty, and thus l1_ratios, l1_ratios_, and l1_ratio_ didn’t exist in sklearn v0.19.2. You can view the past documentation for v0.20; the parameters appear in 0.21 documentation.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement