Quantco / glum

High performance Python GLMs with all the features!
https://glum.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
312 stars 25 forks source link

GeneralizedLinearRegressorCV - Is it possible to use custom defined folds? #690

Closed seanlewis08 closed 1 year ago

seanlewis08 commented 1 year ago
cv : int, cross-validation generator or Iterable, optional (default=None)
    Determines the cross-validation splitting strategy. One of:

    - ``None``, to use the default 5-fold cross-validation,
    - ``int``, to specify the number of folds.
    - ``Iterable`` yielding (train, test) splits as arrays of indices.

    For integer/``None`` inputs, :class:`KFold` is used

It appears that it is not possible to feed custom folds into the GeneralizedLinearRegressorCV? Am I reading this correctly or am I misunderstanding?

lbittarello commented 1 year ago

Hi @seanlewis08! You can feed custom folds by implementing them as an iterable in accordance with scikit-learn's splitter API. You might find PredefinedSplit particularly helpful.