From 42883204fe138a6f54ffc5a2aeb0b1aec46f4df9 Mon Sep 17 00:00:00 2001 From: ChristopherMancuso Date: Mon, 17 Aug 2026 15:55:57 -0400 Subject: [PATCH 1/3] fix to remove future warning about log reg arguments --- geneplexus/_config/config.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/geneplexus/_config/config.py b/geneplexus/_config/config.py index 7e0e614..be7efc7 100644 --- a/geneplexus/_config/config.py +++ b/geneplexus/_config/config.py @@ -1,6 +1,7 @@ """Global variables used by the GenePlexus library.""" import os.path as osp import pathlib +import re from typing import Any from typing import Dict from typing import List @@ -10,6 +11,7 @@ from typing import Union import numpy as np +import sklearn MAX_RETRY = 10 # maximum number of retries for downloading @@ -118,9 +120,20 @@ DEFAULT_LOGREG_KWARGS: Dict[str, Any] = { "max_iter": 10000, "solver": "lbfgs", - "penalty": "l2", "C": 1.0, } +# In scikit-learn>=1.8, ``penalty`` is deprecated in favor of ``l1_ratio``/``C`` +# (l1_ratio=0 is equivalent to the old penalty="l2" default), and passing +# ``penalty`` explicitly now raises a FutureWarning even when set to "l2". +# Older versions don't accept l1_ratio unless penalty="elasticnet", so pick +# whichever explicit form matches the installed version instead of relying on +# either version's default. +_SKLEARN_VERSION_MATCH = re.match(r"(\d+)\.(\d+)", sklearn.__version__) +_SKLEARN_VERSION = tuple(map(int, _SKLEARN_VERSION_MATCH.groups())) if _SKLEARN_VERSION_MATCH else (0, 0) +if _SKLEARN_VERSION >= (1, 8): + DEFAULT_LOGREG_KWARGS["l1_ratio"] = 0.0 +else: + DEFAULT_LOGREG_KWARGS["penalty"] = "l2" __all__ = [ "URL_DICT", From 7168100c2ff6697315cc0cfa91fcaa214ce149cf Mon Sep 17 00:00:00 2001 From: ChristopherMancuso Date: Mon, 17 Aug 2026 16:00:34 -0400 Subject: [PATCH 2/3] fixed docs of rupdate to log reg kwargs --- docs/source/notes/cli.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/source/notes/cli.rst b/docs/source/notes/cli.rst index 0aa6428..3090c67 100644 --- a/docs/source/notes/cli.rst +++ b/docs/source/notes/cli.rst @@ -79,7 +79,9 @@ Full CLI options (check out with ``geneplexus --help``) 123}) -lk , --logreg_kwargs Set the logistic regression keyword arguments in fit(). (default: - {'max_iter': 10000, 'solver': 'lbfgs', 'penalty': 'l2', 'C': 1.0}) + {'max_iter': 10000, 'solver': 'lbfgs', 'C': 1.0, 'l1_ratio': 0.0} on + scikit-learn>=1.8, otherwise {'max_iter': 10000, 'solver': 'lbfgs', + 'penalty': 'l2', 'C': 1.0}) -s, --scale When added, will set scale to True in fit(). See docs for more info of when this is good to do. (default: False) -mnp , --min_num_pos From eedf926fb25b72a949ba93200e0513e09c868225 Mon Sep 17 00:00:00 2001 From: ChristopherMancuso Date: Mon, 17 Aug 2026 16:09:33 -0400 Subject: [PATCH 3/3] fixed docs for rupdate to log reg kwargs --- geneplexus/cli.py | 5 ++++- geneplexus/geneplexus.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/geneplexus/cli.py b/geneplexus/cli.py index 7723169..409de4c 100644 --- a/geneplexus/cli.py +++ b/geneplexus/cli.py @@ -225,7 +225,10 @@ def parse_args() -> argparse.Namespace: default=config.DEFAULT_LOGREG_KWARGS, metavar="", type=json.loads, - help="Set the logistic regression keyword arguments in fit().", + help=( + "Set the logistic regression keyword arguments in fit(). The default shown " + "depends on the installed scikit-learn version (penalty vs l1_ratio)." + ), ) parser.add_argument( diff --git a/geneplexus/geneplexus.py b/geneplexus/geneplexus.py index 287912c..9be67f3 100755 --- a/geneplexus/geneplexus.py +++ b/geneplexus/geneplexus.py @@ -630,7 +630,10 @@ def fit( Args: logreg_kwargs: Scikit-learn logistic regression settings (see - :class:`~sklearn.linear_model.LogisticRegression`). + :class:`~sklearn.linear_model.LogisticRegression`). The default + uses ``l1_ratio=0.0`` on scikit-learn>=1.8 and ``penalty="l2"`` + on older versions (equivalent settings), since ``penalty`` is + deprecated in scikit-learn>=1.8. scale: Whether to scale the data when doing model training and prediction. It is not recommended to set to ``True`` unless using custom data. min_num_pos: Minimum number of positives required for the model