@@ -437,13 +437,13 @@ def _check_solver(solver, penalty, dual):
437
437
raise ValueError ("Logistic Regression supports only solvers in %s, got"
438
438
" %s." % (all_solvers , solver ))
439
439
440
- all_penalties = ['l1' , 'l2' , 'elasticnet' , 'none' ]
440
+ all_penalties = ['l1' , 'l2' , 'elasticnet' ]
441
441
if penalty not in all_penalties :
442
442
raise ValueError ("Logistic Regression supports only penalties in %s,"
443
443
" got %s." % (all_penalties , penalty ))
444
444
445
- if solver not in ['liblinear' , 'saga' ] and penalty not in ( 'l2' , 'none' ) :
446
- raise ValueError ("Solver %s supports only 'l2' or 'none' penalties, "
445
+ if solver not in ['liblinear' , 'saga' ] and penalty != 'l2' :
446
+ raise ValueError ("Solver %s supports only l2 penalties, "
447
447
"got %s penalty." % (solver , penalty ))
448
448
if solver != 'liblinear' and dual :
449
449
raise ValueError ("Solver %s supports only "
@@ -452,12 +452,6 @@ def _check_solver(solver, penalty, dual):
452
452
if penalty == 'elasticnet' and solver != 'saga' :
453
453
raise ValueError ("Only 'saga' solver supports elasticnet penalty,"
454
454
" got solver={}." .format (solver ))
455
-
456
- if solver == 'liblinear' and penalty == 'none' :
457
- raise ValueError (
458
- "penalty='none' is not supported for the liblinear solver"
459
- )
460
-
461
455
return solver
462
456
463
457
@@ -1211,27 +1205,24 @@ class LogisticRegression(BaseEstimator, LinearClassifierMixin,
1211
1205
'sag', 'saga' and 'newton-cg' solvers.)
1212
1206
1213
1207
This class implements regularized logistic regression using the
1214
- 'liblinear' library, 'newton-cg', 'sag', 'saga' and 'lbfgs' solvers. **Note
1215
- that regularization is applied by default**. It can handle both dense
1216
- and sparse input. Use C-ordered arrays or CSR matrices containing 64-bit
1217
- floats for optimal performance; any other input format will be converted
1218
- (and copied).
1208
+ 'liblinear' library, 'newton-cg', 'sag', 'saga' and 'lbfgs' solvers. It can
1209
+ handle both dense and sparse input. Use C-ordered arrays or CSR matrices
1210
+ containing 64-bit floats for optimal performance; any other input format
1211
+ will be converted (and copied).
1219
1212
1220
1213
The 'newton-cg', 'sag', and 'lbfgs' solvers support only L2 regularization
1221
- with primal formulation, or no regularization. The 'liblinear' solver
1222
- supports both L1 and L2 regularization, with a dual formulation only for
1223
- the L2 penalty. The Elastic-Net regularization is only supported by the
1224
- 'saga' solver.
1214
+ with primal formulation. The 'liblinear' solver supports both L1 and L2
1215
+ regularization, with a dual formulation only for the L2 penalty. The
1216
+ Elastic-Net regularization is only supported by the 'saga' solver.
1225
1217
1226
1218
Read more in the :ref:`User Guide <logistic_regression>`.
1227
1219
1228
1220
Parameters
1229
1221
----------
1230
- penalty : str, 'l1', 'l2', 'elasticnet' or 'none ', optional (default='l2')
1222
+ penalty : str, 'l1', 'l2', or 'elasticnet ', optional (default='l2')
1231
1223
Used to specify the norm used in the penalization. The 'newton-cg',
1232
1224
'sag' and 'lbfgs' solvers support only l2 penalties. 'elasticnet' is
1233
- only supported by the 'saga' solver. If 'none' (not supported by the
1234
- liblinear solver), no regularization is applied.
1225
+ only supported by the 'saga' solver.
1235
1226
1236
1227
.. versionadded:: 0.19
1237
1228
l1 penalty with SAGA solver (allowing 'multinomial' + L1)
@@ -1298,10 +1289,8 @@ class LogisticRegression(BaseEstimator, LinearClassifierMixin,
1298
1289
- For multiclass problems, only 'newton-cg', 'sag', 'saga' and 'lbfgs'
1299
1290
handle multinomial loss; 'liblinear' is limited to one-versus-rest
1300
1291
schemes.
1301
- - 'newton-cg', 'lbfgs', 'sag' and 'saga' handle L2 or no penalty
1302
- - 'liblinear' and 'saga' also handle L1 penalty
1303
- - 'saga' also supports 'elasticnet' penalty
1304
- - 'liblinear' does not handle no penalty
1292
+ - 'newton-cg', 'lbfgs' and 'sag' only handle L2 penalty, whereas
1293
+ 'liblinear' and 'saga' handle L1 penalty.
1305
1294
1306
1295
Note that 'sag' and 'saga' fast convergence is only guaranteed on
1307
1296
features with approximately the same scale. You can
@@ -1502,18 +1491,6 @@ def fit(self, X, y, sample_weight=None):
1502
1491
warnings .warn ("l1_ratio parameter is only used when penalty is "
1503
1492
"'elasticnet'. Got "
1504
1493
"(penalty={})" .format (self .penalty ))
1505
- if self .penalty == 'none' :
1506
- if self .C != 1.0 : # default values
1507
- warnings .warn (
1508
- "Setting penalty='none' will ignore the C and l1_ratio "
1509
- "parameters"
1510
- )
1511
- # Note that check for l1_ratio is done right above
1512
- C_ = np .inf
1513
- penalty = 'l2'
1514
- else :
1515
- C_ = self .C
1516
- penalty = self .penalty
1517
1494
if not isinstance (self .max_iter , numbers .Number ) or self .max_iter < 0 :
1518
1495
raise ValueError ("Maximum number of iteration must be positive;"
1519
1496
" got (max_iter=%r)" % self .max_iter )
@@ -1593,13 +1570,13 @@ def fit(self, X, y, sample_weight=None):
1593
1570
prefer = 'processes'
1594
1571
fold_coefs_ = Parallel (n_jobs = self .n_jobs , verbose = self .verbose ,
1595
1572
** _joblib_parallel_args (prefer = prefer ))(
1596
- path_func (X , y , pos_class = class_ , Cs = [C_ ],
1573
+ path_func (X , y , pos_class = class_ , Cs = [self . C ],
1597
1574
l1_ratio = self .l1_ratio , fit_intercept = self .fit_intercept ,
1598
1575
tol = self .tol , verbose = self .verbose , solver = solver ,
1599
1576
multi_class = multi_class , max_iter = self .max_iter ,
1600
1577
class_weight = self .class_weight , check_input = False ,
1601
1578
random_state = self .random_state , coef = warm_start_coef_ ,
1602
- penalty = penalty , max_squared_sum = max_squared_sum ,
1579
+ penalty = self . penalty , max_squared_sum = max_squared_sum ,
1603
1580
sample_weight = sample_weight )
1604
1581
for class_ , warm_start_coef_ in zip (classes_ , warm_start_coef ))
1605
1582
@@ -1991,12 +1968,6 @@ def fit(self, X, y, sample_weight=None):
1991
1968
1992
1969
l1_ratios_ = [None ]
1993
1970
1994
- if self .penalty == 'none' :
1995
- raise ValueError (
1996
- "penalty='none' is not useful and not supported by "
1997
- "LogisticRegressionCV."
1998
- )
1999
-
2000
1971
X , y = check_X_y (X , y , accept_sparse = 'csr' , dtype = np .float64 ,
2001
1972
order = "C" ,
2002
1973
accept_large_sparse = solver != 'liblinear' )
0 commit comments