giotto-ai / giotto-tda

A high-performance topological machine learning toolbox in Python

Home Page:https://giotto-ai.github.io/gtda-docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Scikit-Learn 1.3 support

cngmid opened this issue · comments

commented

Is your feature request related to a problem? Please describe.
scikit-learn 1.3 is released and has deprecated sklearn.utils.metaestimators.if_delegate_has_method for sklearn.utils.metaestimators.available_if

Describe the solution you'd like
It seems to be enough to modify the file gtda.pipeline.py.
In the header, the line from sklearn.utils.metaestimators import if_delegate_has_method shall be replaced with from sklearn.utils.metaestimators import available_if.
The lines 254 and 410 @if_delegate_has_method(delegate='_final_estimator') shall be replaced with @available_if(pipeline.Pipeline._final_estimator)

Describe alternatives you've considered

Additional context

commented

Same ...

% pip show scikit-learn
Name: scikit-learn
Version: 1.3.0
Summary: A set of python modules for machine learning and data mining
Home-page: http://scikit-learn.org
Author: 
Author-email: 
License: new BSD
Location: /Users/davidlaxer/anaconda3/envs/ai/lib/python3.8/site-packages
Requires: joblib, numpy, scipy, threadpoolctl
Required-by: cdt, CellProfiler, giotto-ph, giotto-tda, giotto-tda-nightly, gplearn, hdbscan, librosa, openml, pynndescent, pysr, sentence-transformers, shap, skrebate, torch-geometric, umap-learn

% pytest gtda
============================= test session starts ==============================
platform darwin -- Python 3.8.13, pytest-7.4.0, pluggy-1.0.0
benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /Users/davidlaxer/giotto-tda
configfile: setup.cfg
plugins: anyio-3.5.0, hypothesis-6.82.0, typeguard-2.13.0, cov-4.1.0, hydra-core-1.0.7, azurepipelines-1.0.5, benchmark-4.0.0, lazy-fixture-0.6.3, nunit-1.0.4
collected 1299 items / 2 errors                                                
##vso[task.logissue type=warning;]Jupyter is migrating its paths to use standard platformdirs
given by the platformdirs library.  To remove this warning and
see the appropriate new directories, set the environment variable
`JUPYTER_PLATFORM_DIRS=1` and then run `jupyter --paths`.
The use of platformdirs will be the default in `jupyter_core` v6
##vso[results.publish type=NUnit;runTitle='Pytest results';publishRunAttachments=true;]/Users/davidlaxer/giotto-tda/test-output.xml
##vso[task.logissue type=error;]2 test(s) failed, 1299 test(s) collected.
##vso[task.logissue type=warning;]Coverage XML was not created, skipping upload.

==================================== ERRORS ====================================
__ ERROR collecting gtda/metaestimators/tests/test_collection_transformer.py ___
ImportError while importing test module '/Users/davidlaxer/giotto-tda/gtda/metaestimators/tests/test_collection_transformer.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../anaconda3/envs/ai/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
gtda/metaestimators/__init__.py:4: in <module>
    from .collection_transformer import CollectionTransformer
gtda/metaestimators/collection_transformer.py:12: in <module>
    from sklearn.utils.metaestimators import if_delegate_has_method
E   ImportError: cannot import name 'if_delegate_has_method' from 'sklearn.utils.metaestimators' (/Users/davidlaxer/anaconda3/envs/ai/lib/python3.8/site-packages/sklearn/utils/metaestimators.py)
_________________ ERROR collecting gtda/tests/test_pipeline.py _________________
ImportError while importing test module '/Users/davidlaxer/giotto-tda/gtda/tests/test_pipeline.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../anaconda3/envs/ai/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
gtda/tests/test_pipeline.py:6: in <module>
    from gtda.pipeline import Pipeline
gtda/pipeline.py:7: in <module>
    from sklearn.utils.metaestimators import if_delegate_has_method
E   ImportError: cannot import name 'if_delegate_has_method' from 'sklearn.utils.metaestimators' (/Users/davidlaxer/anaconda3/envs/ai/lib/python3.8/site-packages/sklearn/utils/metaestimators.py)
=============================== warnings summary ===============================
../anaconda3/envs/ai/lib/python3.8/site-packages/jupyter_client/connect.py:27
  /Users/davidlaxer/anaconda3/envs/ai/lib/python3.8/site-packages/jupyter_client/connect.py:27: DeprecationWarning:
  
  Jupyter is migrating its paths to use standard platformdirs
  given by the platformdirs library.  To remove this warning and
  see the appropriate new directories, set the environment variable
  `JUPYTER_PLATFORM_DIRS=1` and then run `jupyter --paths`.
  The use of platformdirs will be the default in `jupyter_core` v6

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
---- generated Nunit xml file: /Users/davidlaxer/giotto-tda/test-output.xml ----
=========================== short test summary info ============================
ERROR gtda/metaestimators/tests/test_collection_transformer.py
ERROR gtda/tests/test_pipeline.py
!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!
========================= 1 warning, 2 errors in 7.43s =========================