Skip to content

Incompatible with scikit-learn 1.6 #48

@musicinmybrain

Description

@musicinmybrain
$ git clone https://github.com/manuel-calzolari/sklearn-genetic.git
$ cd sklearn-genetic
$ python3.13 -m venv _e
$ . _e/bin/activate
(_e) $ pip install -e .
(_e) $ pip install pytest
(_e) $ pytest -v
============================================================================================= test session starts =============================================================================================
platform linux -- Python 3.13.1, pytest-8.3.4, pluggy-1.5.0 -- /home/ben/src/forks/sklearn-genetic/_e/bin/python3
cachedir: .pytest_cache
rootdir: /home/ben/src/forks/sklearn-genetic
collected 1 item                                                                                                                                                                                              

genetic_selection/tests/test_selection.py::test_genetic_selection FAILED                                                                                                                                [100%]

================================================================================================== FAILURES ===================================================================================================
___________________________________________________________________________________________ test_genetic_selection ____________________________________________________________________________________________
multiprocess.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "/home/ben/src/forks/sklearn-genetic/_e/lib64/python3.13/site-packages/multiprocess/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
                    ~~~~^^^^^^^^^^^^^^^
  File "/home/ben/src/forks/sklearn-genetic/_e/lib64/python3.13/site-packages/multiprocess/pool.py", line 48, in mapstar
    return list(map(*args))
  File "/home/ben/src/forks/sklearn-genetic/genetic_selection/gscv.py", line 126, in _evalFunction
    scores = cross_val_score(
        estimator=estimator, X=X_selected, y=y, groups=groups, scoring=scorer, cv=cv, fit_params=fit_params
    )   
  File "/home/ben/src/forks/sklearn-genetic/_e/lib64/python3.13/site-packages/sklearn/utils/_param_validation.py", line 194, in wrapper
    params = func_sig.bind(*args, **kwargs)
  File "/usr/lib64/python3.13/inspect.py", line 3264, in bind
    return self._bind(args, kwargs)
           ~~~~~~~~~~^^^^^^^^^^^^^^
  File "/usr/lib64/python3.13/inspect.py", line 3253, in _bind
    raise TypeError(
        'got an unexpected keyword argument {arg!r}'.format(
            arg=next(iter(kwargs))))
TypeError: got an unexpected keyword argument 'fit_params'
"""

The above exception was the direct cause of the following exception:

data = (array([[5.10000000e+00, 3.50000000e+00, 1.40000000e+00, ...,
        5.37916241e-02, 3.73188791e-02, 9.08730246e-02],...2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
       2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]))

    def test_genetic_selection(data):
        random.seed(42)
        np.random.seed(42)
        X = data[0]
        y = data[1]
        estimator = linear_model.LogisticRegression(solver="liblinear", multi_class="ovr")
        selector = GeneticSelectionCV(
            estimator,
            cv=5,
            verbose=1,
            scoring="accuracy",
            max_features=5,
            n_population=50,
            crossover_proba=0.5,
            mutation_proba=0.2,
            n_generations=40,
            crossover_independent_proba=0.5,   
            mutation_independent_proba=0.05,   
            tournament_size=3,
            n_gen_no_change=10,
            caching=True,
            n_jobs=-1,
        )
>       selector = selector.fit(X, y)

genetic_selection/tests/test_selection.py:41:  
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
genetic_selection/gscv.py:310: in fit
    return self._fit(X, y, groups)
genetic_selection/gscv.py:411: in _fit
    _, log = _eaFunction(
genetic_selection/gscv.py:47: in _eaFunction   
    fitnesses = toolbox.map(toolbox.evaluate, invalid_ind)
_e/lib64/python3.13/site-packages/multiprocess/pool.py:367: in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <multiprocess.pool.MapResult object at 0x7f2fa588c830>, timeout = None

    def get(self, timeout=None):
        self.wait(timeout)
        if not self.ready():
            raise TimeoutError
        if self._success:
            return self._value
        else:
>           raise self._value
E           TypeError: got an unexpected keyword argument 'fit_params'

_e/lib64/python3.13/site-packages/multiprocess/pool.py:774: TypeError
-------------------------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------------------------
Selecting features with genetic algorithm.
=========================================================================================== short test summary info ===========================================================================================
FAILED genetic_selection/tests/test_selection.py::test_genetic_selection - TypeError: got an unexpected keyword argument 'fit_params'
============================================================================================== 1 failed in 0.58s ==============================================================================================

This appears to be related to scikit-learn/scikit-learn#29999.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions