66from sklearn .linear_model import QuantileRegressor
77from sklearn .model_selection import train_test_split
88from sklearn .pipeline import Pipeline
9+ from sklearn .utils import check_random_state
910from sklearn .utils .validation import (
1011 indexable ,
1112 check_is_fitted ,
@@ -330,53 +331,18 @@ def _check_calib_set(
330331 X_calib : Optional [ArrayLike ] = None ,
331332 y_calib : Optional [ArrayLike ] = None ,
332333 calib_size : Optional [float ] = 0.3 ,
333- random_state : Optional [Union [int , None ]] = None ,
334+ random_state : Optional [Union [int , np . random . RandomState , None ]] = None ,
334335 shuffle : Optional [bool ] = True ,
335336 stratify : Optional [ArrayLike ] = None ,
336337 ) -> Tuple [
337338 ArrayLike , ArrayLike , ArrayLike , ArrayLike , Optional [ArrayLike ]
338339 ]:
339- """_summary_
340+ """
341+ HPUT SOMETHING
340342
341343 Parameters
342344 ----------
343- X : ArrayLike of shape (n_samples, n_features)
344- Training data.
345- y : ArrayLike of shape (n_samples,)
346- Training labels.
347- sample_weight : Optional[ArrayLike] of shape (n_samples,)
348- Sample weights for fitting the out-of-fold models.
349- If None, then samples are equally weighted.
350- If some weights are null,
351- their corresponding observations are removed
352- before the fitting process and hence have no residuals.
353- If weights are non-uniform, residuals are still uniformly weighted.
354- Note that the sample weight defined are only for the training, not
355- for the calibration procedure.
356- By default ``None``.
357- X_calib : Optional[ArrayLike] of shape (n_calib_samples, n_features)
358- Calibration data.
359- y_calib : Optional[ArrayLike] of shape (n_calib_samples,)
360- Calibration labels.
361- calib_size : Optional[float]
362- If X_calib and y_calib are not defined, then the calibration
363- dataset is created with the split defined by calib_size.
364- random_state : int, RandomState instance or None, default=None
365- For the ``sklearn.model_selection.train_test_split`` documentation.
366- Controls the shuffling applied to the data before applying the
367- split.
368- Pass an int for reproducible output across multiple function calls.
369- See :term:`Glossary <random_state>`.
370- shuffle : bool, default=True
371- For the ``sklearn.model_selection.train_test_split`` documentation.
372- Whether or not to shuffle the data before splitting.
373- If shuffle=False
374- then stratify must be None.
375- stratify : array-like, default=None
376- For the ``sklearn.model_selection.train_test_split`` documentation.
377- If not None, data is split in a stratified fashion, using this as
378- the class labels.
379- Read more in the :ref:`User Guide <stratification>`.
345+ Same definition of parameters as for the ``fit`` method.
380346
381347 Returns
382348 -------
@@ -430,7 +396,7 @@ def fit(
430396 X_calib : Optional [ArrayLike ] = None ,
431397 y_calib : Optional [ArrayLike ] = None ,
432398 calib_size : Optional [float ] = 0.3 ,
433- random_state : Optional [Union [int , None ]] = None ,
399+ random_state : Optional [Union [int , np . random . RandomState , None ]] = None ,
434400 shuffle : Optional [bool ] = True ,
435401 stratify : Optional [ArrayLike ] = None ,
436402 ) -> MapieQuantileRegressor :
@@ -493,7 +459,8 @@ def fit(
493459 alpha = self ._check_alpha (self .alpha )
494460 self .cv = self ._check_cv (cast (str , self .cv ))
495461 X , y = indexable (X , y )
496- X_train , y_train , X_calib , y_calib , sample_weight_train = self ._check_calib_set (
462+ random_state = check_random_state (random_state )
463+ results = self ._check_calib_set (
497464 X ,
498465 y ,
499466 sample_weight ,
@@ -504,6 +471,7 @@ def fit(
504471 shuffle ,
505472 stratify ,
506473 )
474+ X_train , y_train , X_calib , y_calib , sample_weight_train = results
507475 X_train , y_train = indexable (X_train , y_train )
508476 X_calib , y_calib = indexable (X_calib , y_calib )
509477 y_train , y_calib = _check_y (y_train ), _check_y (y_calib )
0 commit comments