> ## Documentation Index
> Fetch the complete documentation index at: https://nixtla-old-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> dask XGBoost forecaster

# DaskXGBForecast

Wrapper of `xgboost.dask.DaskXGBRegressor` that adds a `model_` property
that contains the fitted model and is sent to the workers in the
forecasting step.

***

<a href="https://github.com/Nixtla/mlforecast/blob/main/mlforecast/distributed/models/dask/xgb.py#L10" target="_blank" style={{ float: "right", fontSize: "smaller" }}>source</a>

### DaskXGBForecast

> ```text theme={null}
>  DaskXGBForecast (max_depth:Optional[int]=None,
>                   max_leaves:Optional[int]=None,
>                   max_bin:Optional[int]=None,
>                   grow_policy:Optional[str]=None,
>                   learning_rate:Optional[float]=None,
>                   n_estimators:Optional[int]=None,
>                   verbosity:Optional[int]=None, objective:Union[str,xgboos
>                   t.sklearn._SklObjWProto,Callable[[Any,Any],Tuple[numpy.n
>                   darray,numpy.ndarray]],NoneType]=None,
>                   booster:Optional[str]=None,
>                   tree_method:Optional[str]=None,
>                   n_jobs:Optional[int]=None, gamma:Optional[float]=None,
>                   min_child_weight:Optional[float]=None,
>                   max_delta_step:Optional[float]=None,
>                   subsample:Optional[float]=None,
>                   sampling_method:Optional[str]=None,
>                   colsample_bytree:Optional[float]=None,
>                   colsample_bylevel:Optional[float]=None,
>                   colsample_bynode:Optional[float]=None,
>                   reg_alpha:Optional[float]=None,
>                   reg_lambda:Optional[float]=None,
>                   scale_pos_weight:Optional[float]=None,
>                   base_score:Optional[float]=None, random_state:Union[nump
>                   y.random.mtrand.RandomState,numpy.random._generator.Gene
>                   rator,int,NoneType]=None, missing:float=nan,
>                   num_parallel_tree:Optional[int]=None, monotone_constrain
>                   ts:Union[Dict[str,int],str,NoneType]=None, interaction_c
>                   onstraints:Union[str,Sequence[Sequence[str]],NoneType]=N
>                   one, importance_type:Optional[str]=None,
>                   device:Optional[str]=None,
>                   validate_parameters:Optional[bool]=None,
>                   enable_categorical:bool=False,
>                   feature_types:Optional[Sequence[str]]=None,
>                   max_cat_to_onehot:Optional[int]=None,
>                   max_cat_threshold:Optional[int]=None,
>                   multi_strategy:Optional[str]=None,
>                   eval_metric:Union[str,List[str],Callable,NoneType]=None,
>                   early_stopping_rounds:Optional[int]=None, callbacks:Opti
>                   onal[List[xgboost.callback.TrainingCallback]]=None,
>                   **kwargs:Any)
> ```

*Implementation of the Scikit-Learn API for XGBoost. See
:doc:`/python/sklearn_estimator` for more information.*

|                          | **Type** | **Default** | **Details**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ------------------------ | -------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| max\_depth               | Optional | None        | Maximum tree depth for base learners.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| max\_leaves              | Optional | None        | Maximum number of leaves; 0 indicates no limit.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| max\_bin                 | Optional | None        | If using histogram-based algorithm, maximum number of bins per feature                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| grow\_policy             | Optional | None        | Tree growing policy.<br /><br />- depthwise: Favors splitting at nodes closest to the node,<br />- lossguide: Favors splitting at nodes with highest loss change.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| learning\_rate           | Optional | None        | Boosting learning rate (xgb’s “eta”)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| n\_estimators            | Optional | None        | Number of gradient boosted trees. Equivalent to number of boosting<br />rounds.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| verbosity                | Optional | None        | The degree of verbosity. Valid values are 0 (silent) - 3 (debug).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| objective                | Union    | None        | Specify the learning task and the corresponding learning objective or a custom<br />objective function to be used.<br /><br />For custom objective, see :doc:`/tutorials/custom_metric_obj` and<br />:ref:`custom-obj-metric` for more information, along with the end note for<br />function signatures.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| booster                  | Optional | None        |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| tree\_method             | Optional | None        | Specify which tree method to use. Default to auto. If this parameter is set to<br />default, XGBoost will choose the most conservative option available. It’s<br />recommended to study this option from the parameters document :doc:`tree method<br/></treemethod>`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| n\_jobs                  | Optional | None        | Number of parallel threads used to run xgboost. When used with other<br />Scikit-Learn algorithms like grid search, you may choose which algorithm to<br />parallelize and balance the threads. Creating thread contention will<br />significantly slow down both algorithms.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| gamma                    | Optional | None        | (min\_split\_loss) Minimum loss reduction required to make a further partition on<br />a leaf node of the tree.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| min\_child\_weight       | Optional | None        | Minimum sum of instance weight(hessian) needed in a child.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| max\_delta\_step         | Optional | None        | Maximum delta step we allow each tree’s weight estimation to be.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| subsample                | Optional | None        | Subsample ratio of the training instance.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| sampling\_method         | Optional | None        | Sampling method. Used only by the GPU version of `hist` tree method.<br /><br />- `uniform`: Select random training instances uniformly.<br />- `gradient_based`: Select random training instances with higher probability<br /> when the gradient and hessian are larger. (cf. CatBoost)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| colsample\_bytree        | Optional | None        | Subsample ratio of columns when constructing each tree.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| colsample\_bylevel       | Optional | None        | Subsample ratio of columns for each level.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| colsample\_bynode        | Optional | None        | Subsample ratio of columns for each split.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| reg\_alpha               | Optional | None        | L1 regularization term on weights (xgb’s alpha).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| reg\_lambda              | Optional | None        | L2 regularization term on weights (xgb’s lambda).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| scale\_pos\_weight       | Optional | None        | Balancing of positive and negative weights.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| base\_score              | Optional | None        | The initial prediction score of all instances, global bias.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| random\_state            | Union    | None        | Random number seed.<br /><br />.. note::<br /><br /> Using gblinear booster with shotgun updater is nondeterministic as<br /> it uses Hogwild algorithm.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| missing                  | float    | nan         | Value in the data which needs to be present as a missing value. Default to<br />:py:data:`numpy.nan`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| num\_parallel\_tree      | Optional | None        |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| monotone\_constraints    | Union    | None        | Constraint of variable monotonicity. See :doc:`tutorial </tutorials/monotonic>`<br />for more information.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| interaction\_constraints | Union    | None        | Constraints for interaction representing permitted interactions. The<br />constraints must be specified in the form of a nested list, e.g. `[[0, 1], [2,<br/>3, 4]]`, where each inner list is a group of indices of features that are<br />allowed to interact with each other. See :doc:`tutorial<br/></tutorials/feature_interaction_constraint>` for more information                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| importance\_type         | Optional | None        |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| device                   | Optional | None        | .. versionadded:: 2.0.0<br /><br />Device ordinal, available options are `cpu`, `cuda`, and `gpu`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| validate\_parameters     | Optional | None        | Give warnings for unknown parameter.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| enable\_categorical      | bool     | False       | See the same parameter of :py:class:`DMatrix` for details.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| feature\_types           | Optional | None        | .. versionadded:: 1.7.0<br /><br />Used for specifying feature types without constructing a dataframe. See<br />:py:class:`DMatrix` for details.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| max\_cat\_to\_onehot     | Optional | None        | .. versionadded:: 1.6.0<br /><br />.. note:: This parameter is experimental<br /><br />A threshold for deciding whether XGBoost should use one-hot encoding based split<br />for categorical data. When number of categories is lesser than the threshold<br />then one-hot encoding is chosen, otherwise the categories will be partitioned<br />into children nodes. Also, `enable_categorical` needs to be set to have<br />categorical feature support. See :doc:`Categorical Data<br/></tutorials/categorical>` and :ref:`cat-param` for details.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| max\_cat\_threshold      | Optional | None        | .. versionadded:: 1.7.0<br /><br />.. note:: This parameter is experimental<br /><br />Maximum number of categories considered for each split. Used only by<br />partition-based splits for preventing over-fitting. Also, `enable_categorical`<br />needs to be set to have categorical feature support. See :doc:`Categorical Data<br/></tutorials/categorical>` and :ref:`cat-param` for details.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| multi\_strategy          | Optional | None        | .. versionadded:: 2.0.0<br /><br />.. note:: This parameter is working-in-progress.<br /><br />The strategy used for training multi-target models, including multi-target<br />regression and multi-class classification. See :doc:`/tutorials/multioutput` for<br />more information.<br /><br />- `one_output_per_tree`: One model for each target.<br />- `multi_output_tree`: Use multi-target trees.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| eval\_metric             | Union    | None        | .. versionadded:: 1.6.0<br /><br />Metric used for monitoring the training result and early stopping. It can be a<br />string or list of strings as names of predefined metric in XGBoost (See<br />doc/parameter.rst), one of the metrics in :py:mod:`sklearn.metrics`, or any<br />other user defined metric that looks like `sklearn.metrics`.<br /><br />If custom objective is also provided, then custom metric should implement the<br />corresponding reverse link function.<br /><br />Unlike the `scoring` parameter commonly used in scikit-learn, when a callable<br />object is provided, it’s assumed to be a cost function and by default XGBoost<br />will minimize the result during early stopping.<br /><br />For advanced usage on Early stopping like directly choosing to maximize instead<br />of minimize, see :py:obj:`xgboost.callback.EarlyStopping`.<br /><br />See :doc:`/tutorials/custom_metric_obj` and :ref:`custom-obj-metric` for more<br />information.<br /><br />.. code-block:: python<br /><br /> from sklearn.datasets import load\_diabetes<br /> from sklearn.metrics import mean\_absolute\_error<br /> X, y = load\_diabetes(return\_X\_y=True)<br /> reg = xgb.XGBRegressor(<br /> tree\_method=“hist”,<br /> eval\_metric=mean\_absolute\_error,<br /> )<br /> reg.fit(X, y, eval\_set=\[(X, y)]) |
| early\_stopping\_rounds  | Optional | None        | .. versionadded:: 1.6.0<br /><br />- Activates early stopping. Validation metric needs to improve at least once in<br /> every **early\_stopping\_rounds** round(s) to continue training. Requires at<br /> least one item in **eval\_set** in :py:meth:`fit`.<br /><br />- If early stopping occurs, the model will have two additional attributes:<br /> :py:attr:`best_score` and :py:attr:`best_iteration`. These are used by the<br /> :py:meth:`predict` and :py:meth:`apply` methods to determine the optimal<br /> number of trees during inference. If users want to access the full model<br /> (including trees built after early stopping), they can specify the<br /> `iteration_range` in these inference methods. In addition, other utilities<br /> like model plotting can also use the entire model.<br /><br />- If you prefer to discard the trees after `best_iteration`, consider using the<br /> callback function :py:class:`xgboost.callback.EarlyStopping`.<br /><br />- If there’s more than one item in **eval\_set**, the last entry will be used for<br /> early stopping. If there’s more than one metric in **eval\_metric**, the last<br /> metric will be used for early stopping.                                                                                                                             |
| callbacks                | Optional | None        | List of callback functions that are applied at end of each iteration.<br />It is possible to use predefined callbacks by using<br />:ref:`Callback API <callback_api>`.<br /><br />.. note::<br /><br /> States in callback are not preserved during training, which means callback<br /> objects can not be reused for multiple training sessions without<br /> reinitialization or deepcopy.<br /><br />.. code-block:: python<br /><br /> for params in parameters\_grid:<br /> # be sure to (re)initialize the callbacks before each run<br /> callbacks = \[xgb.callback.LearningRateScheduler(custom\_rates)]<br /> reg = xgboost.XGBRegressor(\*\*params, callbacks=callbacks)<br /> reg.fit(X, y)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| kwargs                   | Any      |             | Keyword arguments for XGBoost Booster object. Full documentation of parameters<br />can be found :doc:`here </parameter>`.<br />Attempting to set a parameter via the constructor args and \*\*kwargs<br />dict simultaneously will result in a TypeError.<br /><br />.. note:: \*\*kwargs unsupported by scikit-learn<br /><br /> \*\*kwargs is unsupported by scikit-learn. We do not guarantee<br /> that parameters passed via this argument will interact properly<br /> with scikit-learn.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| **Returns**              | **None** |             |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
