diff --git a/daal4py/sklearn/linear_model/logistic_path.py b/daal4py/sklearn/linear_model/logistic_path.py index 650696cad4..d9b5a16537 100755 --- a/daal4py/sklearn/linear_model/logistic_path.py +++ b/daal4py/sklearn/linear_model/logistic_path.py @@ -102,7 +102,7 @@ def __logistic_regression_path( # Comment 2025-08-04: this file might have dead code paths from unsupported solvers. # It appears to have initially been a copy-paste of scikit-learn with a few additions - # for varying levels of offloading to oneDAL, but later on the check above was added that + # for varying levels of offloading to oneDAL, but later on a check was added that # calls 'lr_path_original' early on when it won't end up offloading anything to oneDAL. # Some parts of the file have been selectively updated since the initial copy-paste # to reflect newer additions to sklearn, but they are not synch. The rest of the file @@ -469,6 +469,16 @@ def logistic_regression_path(*args, **kwargs): (not sparse.issparse(args[0]), "X is sparse. Sparse input is not supported."), (kwargs["sample_weight"] is None, "Sample weights are not supported."), (kwargs["class_weight"] is None, "Class weights are not supported."), + ( + kwargs["penalty"] + in (["l2", "deprecated"] if sklearn_check_version("1.8") else ["l2"]), + "Penalties other than l2 are not supported.", + ), + (not kwargs["l1_ratio"], "L1 regularization is not supported."), + ( + not (kwargs["solver"] == "newton-cg" and not kwargs["fit_intercept"]), + "'newton-cg' solver without intercept is not supported.", + ), ] ) if not _dal_ready: diff --git a/doc/sources/algorithms.rst b/doc/sources/algorithms.rst index ba7b24d4be..d287ec56f8 100755 --- a/doc/sources/algorithms.rst +++ b/doc/sources/algorithms.rst @@ -74,9 +74,11 @@ Classification - All parameters are supported except: - ``solver`` not in [``'lbfgs'``, ``'newton-cg'``] - - ``penalty`` in [``'l1'``, ``'elasticnet'``] + - ``l1_ratio`` != ``0`` + - ``dual`` = ``True`` - ``sample_weight`` != ``None`` - ``class_weight`` != ``None`` + - Solver ``'newton-cg'`` with ``fit_intercept`` = ``False`` is not supported - Sparse data is not supported. Regression @@ -323,12 +325,10 @@ Classification - ``solver`` != `'newton-cg'` - ``class_weight`` != `None` - ``sample_weight`` != `None` - - ``penalty`` != `'l2'` - - ``dual`` = `True` + - ``dual`` = ``True`` - ``intercept_scaling`` != `1` - - ``multi_class`` = `'multinomial'` - - ``warm_start`` = `True` - - ``l1_ratio`` != 0 and ``l1_ratio`` != ``None`` + - ``warm_start`` = ``True`` + - ``l1_ratio`` != ``0`` - Only binary classification is supported - No limitations @@ -525,12 +525,10 @@ Classification - ``solver`` != `'newton-cg'` - ``class_weight`` != `None` - ``sample_weight`` != `None` - - ``penalty`` != `'l2'` - - ``dual`` = `True` + - ``dual`` = ``True`` - ``intercept_scaling`` != `1` - - ``multi_class`` != `'multinomial'` - - ``warm_start`` = `True` - - ``l1_ratio`` != `None` + - ``warm_start`` = ``True`` + - ``l1_ratio`` != ``0`` - Only binary classification is supported - No limitations diff --git a/sklearnex/linear_model/logistic_regression.py b/sklearnex/linear_model/logistic_regression.py index 8a0b8233e7..c90e64aea1 100644 --- a/sklearnex/linear_model/logistic_regression.py +++ b/sklearnex/linear_model/logistic_regression.py @@ -15,7 +15,6 @@ # =============================================================================== import logging -from abc import ABC from daal4py.sklearn._utils import daal_check_version from daal4py.sklearn.linear_model.logistic_path import ( @@ -28,7 +27,7 @@ from sklearn.linear_model import LogisticRegression as _sklearn_LogisticRegression from sklearn.metrics import accuracy_score from sklearn.utils.multiclass import type_of_target - from sklearn.utils.validation import check_array, check_is_fitted, check_X_y + from sklearn.utils.validation import check_is_fitted from daal4py.sklearn._n_jobs_support import control_n_jobs from daal4py.sklearn._utils import sklearn_check_version @@ -66,11 +65,12 @@ class LogisticRegression(oneDALEstimator, _sklearn_LogisticRegression): def __init__( self, - penalty="l2", + penalty="deprecated", *, + C=1.0, + l1_ratio=0.0, dual=False, tol=1e-4, - C=1.0, fit_intercept=True, intercept_scaling=1, class_weight=None, @@ -80,7 +80,6 @@ def __init__( verbose=0, warm_start=False, n_jobs=None, - l1_ratio=None, ): super().__init__( penalty=penalty, @@ -256,7 +255,15 @@ def _onedal_gpu_fit_supported(self, method_name, *data): ) patching_status.and_conditions( [ - (self.penalty == "l2", "Only l2 penalty is supported."), + ( + self.penalty + in ( + ["l2", "deprecated"] + if sklearn_check_version("1.8") + else ["l2"] + ), + "Only l2 penalty is supported.", + ), (self.dual == False, "dual=True is not supported."), ( self.intercept_scaling == 1, @@ -271,7 +278,7 @@ def _onedal_gpu_fit_supported(self, method_name, *data): ), ( not self.l1_ratio, - "l1 ratio is not supported.", + "l1 penalty is not supported.", ), (sample_weight is None, "Sample weight is not supported."), (