Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion daal4py/sklearn/linear_model/logistic_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
20 changes: 9 additions & 11 deletions doc/sources/algorithms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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``
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- ``warm_start`` = ``True``
- ``warm_start`` = `True`

Most other boolean values mentioned in these docs use single ticks - is double preferred? If so I guess we should update for all of these, otherwise let's stick with single

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double backtick is guaranteed to render as code. Single backtick is up to configuration. I don't know why they had single ticks.

- ``l1_ratio`` != ``0``
- Only binary classification is supported
- No limitations

Expand Down
21 changes: 14 additions & 7 deletions sklearnex/linear_model/logistic_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -80,7 +80,6 @@ def __init__(
verbose=0,
warm_start=False,
n_jobs=None,
l1_ratio=None,
):
super().__init__(
penalty=penalty,
Expand Down Expand Up @@ -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,
Expand All @@ -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."),
(
Expand Down
Loading