sknetwork-team / scikit-network

Graph Algorithms
Other
606 stars 66 forks source link

Using `scikit-base` to have `get_params`, `get_fitted_params` and be composition compatible with, e.g., `scikit-learn` and `sktime`? #557

Closed fkiraly closed 1 year ago

fkiraly commented 1 year ago

PR and a design proposal in one - would you be open to consider scikit-base as the root of your base class tree?

My motivation for contributing this is, I wanted to use scikit-network algorithms as components in sktime algorithms (in some local playing around), e.g., distance based classification or clustering.

Now, if you don't have get_params, set_params, the parameters within scikit-network cannot be tuned. If you don't have get_fitted_params, the fitted parameters cannot be easily read by parameter retrieval interfaces.

Another benefit would be that you could use the testing framework for streamlined API testing (not contained in this PR).

Thoughts? Happy to help with integration - it should mostly be plug & play.

The other option would be doing double inheritance downstream, i.e. inherit from the scikit-network estimators in question and scikit-base BaseEstimator, but that seems more hacky and error prone...

Recent tutorial here: https://github.com/sktime/sktime-tutorial-pydata-seattle-2023

tbonald commented 1 year ago

Thanks for the PR. We would like to restrict dependencies to Numpy and Scipy at this stage. However, it is an excellent suggestion to have a base class with get_params, set_params, etc. If you can make another PR (on the Develop branch) without dependency, that would be great.

fkiraly commented 1 year ago

If you can make another PR (on the Develop branch) without dependency, that would be great.

That would basically amount to copy-pasting those functions from scikit-base and/or scikit-learn...

Seems a bit wasteful in terms of DRY-ness. I'll leave that to you if you want to do it this way.

tbonald commented 1 year ago

OK, I'll take a look (moved to Projects). Thanks.

tbonald commented 1 year ago

Now available (see new release, 0.31.0). Thanks for the suggestion!