Skip to content

quantile_cv.py

Summary

This code defines a QuantileCV class for automated quantile regression tree modeling with Bayesian optimization and pluggable boosting backends.

Dependencies

Standard Library

  • typing
  • functools

Other

  • numpy
  • pandas
  • pydantic
  • sklearn
  • xgboost
  • catboost

Description

The quantile_cv.py file implements a QuantileCV class, which provides automated quantile regression using tree-based models and Bayesian optimization. This class is designed for flexible and robust quantile regression tasks, leveraging advanced machine learning techniques.

The implementation includes:

  1. QuantileCV uses RegressionCVConfig for its configuration (same as RegressionCV), including:
  2. monotone_constraints: Dictionary specifying monotonicity direction for variables (0 for none, 1 for increasing, -1 for decreasing)
  3. interactions: List of lists containing permitted feature interactions
  4. n_jobs: Number of parallel jobs to use when fitting the model
  5. parameters: Hyperparameter search space definition (OptimizerParams instance)
  6. return_train_score: Whether to include training scores during optimization

  7. Pre-configured settings (from RegressionCVConfig):

  8. default_regression: A standard configuration using all hyperparameters
  9. balanced_regression: A configuration focused on regularization parameters

  10. QuantileCV: The main class that inherits from RegressionCV and provides:

  11. Automated hyperparameter tuning via Bayesian optimization
  12. Backend selection via backend ("xgboost" or "catboost")
  13. Support for custom quantile levels via the alpha parameter
  14. Integration with scikit-learn's scoring system for quantile regression metrics
  15. Parallel processing support

The class uses cross-validation during the optimization process to ensure model robustness and prevent overfitting. It supports various regression metrics, with a focus on quantile loss, and leverages Pydantic for configuration validation.

Overall, this module offers a comprehensive solution for quantile regression tasks, combining automated model selection, advanced regression techniques, and robust validation mechanisms.