get_params method in cross-validation splitters
See original GitHub issueDescribe the workflow you want to enable
I would like to be able to recreate the cross-validataion splitters from parameters.
Presently, the cross-validation splitters do not have get_params or set_params options. I want to make different steps in my process stateless, and to do that I need to be able to retrieve the parameters used to create an object (and pass them out), then recreate the object (obviously in an unfitted state, but that doesn’t matter for cv splitters) when the parameters are passed back in.
Describe your proposed solution
get_params and set_params are already implemented in BaseEstimator. There are two possible options:
- Copy the implementation into
BaseCrossValidatorThis is faster to implement, but it isn’t very DRY, and it isn’t very maintainable. This could be done as a quick patch, but doing so might make problems for someone else later. - Pull the common API stuff backward to some kind of BaseSKObject class This is more maintainable, cleaner, and overall a better solution, but it will take thought, architectural consideration, and intentionality. This is not a quick patch.
Describe alternatives you’ve considered, if relevant
I can (and probably will) store the values I used to create the object in the first place, and pass them out when I build my parameter string. I don’t think this will be completed right away (if it’s even desired by the community at large), and the show must go on.
But having get_params and set_params common across all sklearn objects feels like a necessary step toward a more unified codebase. And it would make my life a lot easier!
Additional context
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (5 by maintainers)

Top Related StackOverflow Question
For you use-case I would just implement a custom class that re-implements the
get_params()logic https://github.com/scikit-learn/scikit-learn/blob/fac31e727947ad53f2ed107f58a10b56b165cee7/sklearn/base.py#L187, possibly in a simplified way; you probably don’t need everything inBaseEstimator.get_params()just for splitters. After all, all it does it return the parameters that were passed toinit().Alternatively, I am deeply ashamed but this might work in most cases:
OK got it. We also have the scorers that are in the same situation (while this is true that you can pass some strings).
It would be nice to have thoughts of others @scikit-learn/core-devs