classQuantileCV(RegressionCV):""" Defines an auto quantile tree, based on the bayesian optimization base class. """@validate_call(config={"arbitrary_types_allowed":True})def__init__(self,alpha:NonNegativeFloat,cv:BaseCrossValidator,n_trials:NonNegativeInt,timeout:NonNegativeInt,config:RegressionCVConfig,backend:str="xgboost",)->None:""" Constructor for QuantileCV. Args: alpha: The quantile to estimate, which must be between 0 and 1. cv: Splitter object to use when estimating the model. n_trials: Number of optimization trials to use when finding a model. timeout: Timeout in seconds to stop the optimization. config: Configuration to use when fitting the model. backend: Backend to use for the model. Either "xgboost" or "catboost". """super().__init__("quantile",cv,n_trials,timeout,config,backend=backend)self.alpha_=alpha@propertydefscorer(self)->tp.Callable[...,float]:""" Returns correct scorer to use when scoring with QuantileCV. """# For quantile regression, we always use the quantile metric with alpha parameterreturnmake_scorer(update_wrapper(partial(regression_metrics["quantile"],alpha=self.alpha_,),regression_metrics["quantile"],),greater_is_better=False,)
scorerproperty
scorer
Returns correct scorer to use when scoring with QuantileCV.
Backend to use for the model. Either "xgboost" or "catboost".
'xgboost'
Source code in src/tree_machine/quantile_cv.py
2122232425262728293031323334353637383940414243
@validate_call(config={"arbitrary_types_allowed":True})def__init__(self,alpha:NonNegativeFloat,cv:BaseCrossValidator,n_trials:NonNegativeInt,timeout:NonNegativeInt,config:RegressionCVConfig,backend:str="xgboost",)->None:""" Constructor for QuantileCV. Args: alpha: The quantile to estimate, which must be between 0 and 1. cv: Splitter object to use when estimating the model. n_trials: Number of optimization trials to use when finding a model. timeout: Timeout in seconds to stop the optimization. config: Configuration to use when fitting the model. backend: Backend to use for the model. Either "xgboost" or "catboost". """super().__init__("quantile",cv,n_trials,timeout,config,backend=backend)self.alpha_=alpha