Skip to content

Commit 0c4ca60

Browse files
MAINT: Update signature for logistic regression path in newer sklearn (#3189)
* update signature for logistic path * skip tests on callbacks
1 parent 2b433a2 commit 0c4ca60

2 files changed

Lines changed: 109 additions & 2 deletions

File tree

daal4py/sklearn/linear_model/logistic_path.py

Lines changed: 106 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,10 @@ def daal4py_fit(self, X, y, sample_weight=None):
456456
# 'control_n_jobs', which acts on the sklearnex side before calling these
457457
# daal4py functions for logistic regression, so setting 'n_jobs' in the estimator
458458
# objects at this point will have no effect on the value passed to oneDAL.
459+
# Note: as of 2026-05-25, the 'version' attribute in sklearn is already set
460+
# as '1.10.dev0', but this argument hasn't been removed.
459461
# TODO: remove this once scikit-learn1.8 and 1.9 are no longer supported.
460-
if (not sklearn_check_version("1.10")) and sklearn_check_version("1.8"):
462+
if sklearn_check_version("1.8"):
461463
n_jobs = self.n_jobs
462464
if self.n_jobs is not None:
463465
self.n_jobs = None
@@ -591,7 +593,109 @@ def daal4py_predict(self, X, resultsToEvaluate):
591593
return LogisticRegression_original.predict_log_proba(self, X)
592594

593595

594-
if sklearn_check_version("1.8"):
596+
if sklearn_check_version("1.9"):
597+
598+
def logistic_regression_path(
599+
X,
600+
y,
601+
*,
602+
classes,
603+
Cs=10,
604+
fit_intercept=True,
605+
max_iter=100,
606+
tol=1e-4,
607+
verbose=0,
608+
solver="lbfgs",
609+
coef=None,
610+
class_weight=None,
611+
dual=False,
612+
penalty="l2",
613+
intercept_scaling=1.0,
614+
random_state=None,
615+
check_input=True,
616+
max_squared_sum=None,
617+
sample_weight=None,
618+
l1_ratio=None,
619+
n_threads=1,
620+
callback_ctx=None, # Not supported
621+
estimator=None, # Only used by 'callback_ctx'
622+
):
623+
return logistic_regression_path_dispatcher(
624+
"sklearn.linear_model.LogisticRegression.fit",
625+
X,
626+
y,
627+
classes=classes,
628+
pos_class=None,
629+
Cs=Cs,
630+
fit_intercept=fit_intercept,
631+
max_iter=max_iter,
632+
tol=tol,
633+
verbose=verbose,
634+
solver=solver,
635+
coef=coef,
636+
class_weight=class_weight,
637+
dual=dual,
638+
penalty=penalty,
639+
intercept_scaling=intercept_scaling,
640+
random_state=random_state,
641+
check_input=check_input,
642+
max_squared_sum=max_squared_sum,
643+
sample_weight=sample_weight,
644+
l1_ratio=l1_ratio,
645+
n_threads=n_threads,
646+
)
647+
648+
def logistic_regression_path_cv(
649+
X,
650+
y,
651+
*,
652+
classes,
653+
Cs=10,
654+
fit_intercept=True,
655+
max_iter=100,
656+
tol=1e-4,
657+
verbose=0,
658+
solver="lbfgs",
659+
coef=None,
660+
class_weight=None,
661+
dual=False,
662+
penalty="l2",
663+
intercept_scaling=1.0,
664+
random_state=None,
665+
check_input=True,
666+
max_squared_sum=None,
667+
sample_weight=None,
668+
l1_ratio=None,
669+
n_threads=1,
670+
callback_ctx=None,
671+
estimator=None,
672+
):
673+
return logistic_regression_path_dispatcher(
674+
"sklearn.linear_model.LogisticRegressionCV.fit",
675+
X,
676+
y,
677+
classes=classes,
678+
pos_class=None,
679+
Cs=Cs,
680+
fit_intercept=fit_intercept,
681+
max_iter=max_iter,
682+
tol=tol,
683+
verbose=verbose,
684+
solver=solver,
685+
coef=coef,
686+
class_weight=class_weight,
687+
dual=dual,
688+
penalty=penalty,
689+
intercept_scaling=intercept_scaling,
690+
random_state=random_state,
691+
check_input=check_input,
692+
max_squared_sum=max_squared_sum,
693+
sample_weight=sample_weight,
694+
l1_ratio=l1_ratio,
695+
n_threads=n_threads,
696+
)
697+
698+
elif sklearn_check_version("1.8"):
595699

596700
def logistic_regression_path(
597701
X,

deselected_tests.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,9 @@ deselected_tests:
480480
# but sklearnex does use the parameter regardless.
481481
- linear_model/tests/test_logistic.py::test_logisticregression_warns_with_n_jobs
482482

483+
# Unsupported features in sklearnex
484+
- linear_model/tests/test_logistic.py::test_logistic_regression_callback_support
485+
483486
# --------------------------------------------------------
484487
# No need to test daal4py patching
485488
reduced_tests:

0 commit comments

Comments
 (0)