ó
    uñ:iž]  ã                   óx  • S r SSKJrJrJrJrJr  SSKrSSK	J
r
  SSKJrJr  SSKJrJr  SSKJr  SS	KJrJrJr  S
SKJrJrJr  S
SKJr  S\\   S\\   SS4S jr " S S\5      r " S S\5      r\" \\5         " S S\\\5      r  " S S\5      r!\" \ \!5         " S S\5      r" " S S\5      r#\" \"\#5        g)z8Xgboost pyspark integration submodule for estimator API.é    )ÚAnyÚListÚOptionalÚTypeÚUnionN)Úkeyword_only)ÚParamÚParams)ÚHasProbabilityColÚHasRawPredictionColé   )ÚConfig)ÚXGBClassifierÚ	XGBRankerÚXGBRegressoré   )Ú_ClassificationModelÚ_SparkXGBEstimatorÚ_SparkXGBModel)Úget_class_nameÚ	estimatorÚmodelÚreturnc                 óú  ^ ^^	• T R                  5       nS[        S[        4U	4S jjm	S[        S[        SS4U UU	4S jjnUR	                  5        HG  nS[        T R                  5       5       S	U 3n[        [        R                  " 5       XES
9nU" XF5        MI     T R                  5       nUR	                  5        HR  nS[        T R                  5       5       SU 3nUS:X  a  US-  n[        [        R                  " 5       XES
9nU" XF5        MT     T R                  5       nUR	                  5        HG  nS[        T R                  5       5       SU 3n[        [        R                  " 5       XES
9nU" XF5        MI     g)zuThis function automatically infer to xgboost parameters and set them
into corresponding pyspark estimators and modelsÚvr   c                 ó‚  >• [        U [        R                  5      (       a$  [        R                  " U 5      R	                  5       $ [        U [
        5      (       a,  U R                  5        VVs0 s H  u  pUT" U5      _M     snn$ [        U [        5      (       a  U  Vs/ s H  nT" U5      PM     sn$ U $ s  snnf s  snf ©N)Ú
isinstanceÚnpÚgenericÚarrayÚitemÚdictÚitemsÚlist)r   ÚkÚnvÚparam_value_converters      €ÚZ/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/xgboost/spark/estimator.pyr(   Ú?_set_pyspark_xgb_cls_param_attrs.<locals>.param_value_converter   s–   ø€ Ü�aœŸ™×$Ñ$ä—8’8˜A“;×#Ñ#Ó%Ð%Ü�aœ×ÑØ>?¿g¹g¼iÔHºi±U°Q�AÑ,¨RÓ0Ò0¹iÒHÐHÜ�aœ×ÑÙ89Ó:º°"Ñ)¨"Ö-¹Ñ:Ð:Øˆùó Iùâ:s   Á-B6ÂB<Ú	attr_nameÚparamNc                 óD   >• TUl         [        TX5        [        TX5        g r   )ÚtypeConverterÚsetattr)r+   r,   r   r   r(   s     €€€r)   Úset_param_attrsÚ9_set_pyspark_xgb_cls_param_attrs.<locals>.set_param_attrs(   s   ø€ Ø3ˆÔÜ�	˜9Ô,Ü��yÕ(ó    zRefer to XGBoost doc of z for this param )ÚnameÚdocz.fit() for this param Ú	callbacksz°The callbacks can be arbitrary functions. It is saved using cloudpickle which is not a fully self-contained format. It may fail to load with different versions of dependencies.z.predict() for this param )Ú_get_xgb_params_defaultr   Ústrr	   Úkeysr   Ú_xgb_clsr
   Ú_dummyÚ_get_fit_params_defaultÚ_get_predict_params_default)
r   r   Úparams_dictr0   r3   r4   Ú	param_objÚfit_params_dictÚpredict_params_dictr(   s
   ``       @r)   Ú _set_pyspark_xgb_cls_param_attrsrA      s…  ú€ ð
 ×3Ñ3Ó5€Kð¤ð ¬÷ ð)¤3ð )¬uð )¸÷ )ñ )ð
 × Ñ Ö"ˆà&Ü˜i×0Ñ0Ó2Ó3Ð4Ð4DÀTÀFðLð 	ô
 !¤§¢£°tÑEˆ	Ù˜Ö(ñ #ð  ×7Ñ7Ó9€OØ×$Ñ$Ö&ˆà&¤~°i×6HÑ6HÓ6JÓ'KÐ&LØ$ T Fð,ð 	ð �;ÓØð6ñˆCô
 œ&Ÿ-š-›/°Ñ>ˆ	Ù˜Ö(ñ 'ð $×?Ñ?ÓAÐØ#×(Ñ(Ö*ˆà&¤~°i×6HÑ6HÓ6JÓ'KÐ&LØ(¨¨ð0ð 	ô œ&Ÿ-š-›/°Ñ>ˆ	Ù˜Ö(ò +r2   c            "       ó  ^ • \ rS rSrSr\SSSSSSSSSSSSS	SS
.S\\\\   4   S\S\S\	\   S\	\   S\	\   S\	\   S\
S\	\   S\S\S\S\S\	\   S\SS4 U 4S jjj5       r\S\\   4S j5       r\S\S   4S j5       rS!U 4S jjrS rU =r$ )"ÚSparkXGBRegressoréO   a  SparkXGBRegressor is a PySpark ML estimator. It implements the XGBoost regression
algorithm based on XGBoost python library, and it can be used in PySpark Pipeline
and PySpark ML meta algorithms like
- :py:class:`~pyspark.ml.tuning.CrossValidator`/
- :py:class:`~pyspark.ml.tuning.TrainValidationSplit`/
- :py:class:`~pyspark.ml.classification.OneVsRest`

SparkXGBRegressor automatically supports most of the parameters in
:py:class:`xgboost.XGBRegressor` constructor and most of the parameters used in
:py:meth:`xgboost.XGBRegressor.fit` and :py:meth:`xgboost.XGBRegressor.predict`
method.

To enable GPU support, set `device` to `cuda` or `gpu`.

SparkXGBRegressor doesn't support setting `base_margin` explicitly as well, but
support another param called `base_margin_col`. see doc below for more details.

SparkXGBRegressor doesn't support `validate_features` and `output_margin` param.

SparkXGBRegressor doesn't support setting `nthread` xgboost param, instead, the
`nthread` param for each xgboost worker will be set equal to `spark.task.cpus`
config value.


Parameters
----------

features_col:
    When the value is string, it requires the features column name to be vector type.
    When the value is a list of string, it requires all the feature columns to be numeric types.
label_col:
    Label column name. Default to "label".
prediction_col:
    Prediction column name. Default to "prediction"
pred_contrib_col:
    Contribution prediction column name.
validation_indicator_col:
    For params related to `xgboost.XGBRegressor` training with
    evaluation dataset's supervision,
    set :py:attr:`xgboost.spark.SparkXGBRegressor.validation_indicator_col`
    parameter instead of setting the `eval_set` parameter in `xgboost.XGBRegressor`
    fit method.
weight_col:
    To specify the weight of the training and validation dataset, set
    :py:attr:`xgboost.spark.SparkXGBRegressor.weight_col` parameter instead of setting
    `sample_weight` and `sample_weight_eval_set` parameter in `xgboost.XGBRegressor`
    fit method.
base_margin_col:
    To specify the base margins of the training and validation
    dataset, set :py:attr:`xgboost.spark.SparkXGBRegressor.base_margin_col` parameter
    instead of setting `base_margin` and `base_margin_eval_set` in the
    `xgboost.XGBRegressor` fit method.

num_workers:
    How many XGBoost workers to be used to train.
    Each XGBoost worker corresponds to one spark task.
device:

    .. versionadded:: 2.0.0

    Device for XGBoost workers, available options are `cpu`, `cuda`, and `gpu`.

force_repartition:
    Boolean value to specify if forcing the input dataset to be repartitioned
    before XGBoost training.
repartition_random_shuffle:
    Boolean value to specify if randomly shuffling the dataset when repartitioning is required.
enable_sparse_data_optim:
    Boolean value to specify if enabling sparse data optimization, if True,
    Xgboost DMatrix object will be constructed from sparse matrix instead of
    dense matrix.
launch_tracker_on_driver:
    Boolean value to indicate whether the tracker should be launched on the driver side or
    the executor side.
coll_cfg:
    The collective configuration. See :py:class:`~xgboost.collective.Config`

kwargs:
    A dictionary of xgboost parameters, please refer to
    https://xgboost.readthedocs.io/en/stable/parameter.html

Note
----

The Parameters chart above contains parameters that need special handling.
For a full list of parameters, see entries with `Param(parent=...` below.

This API is experimental.


Examples
--------

>>> from xgboost.spark import SparkXGBRegressor
>>> from pyspark.ml.linalg import Vectors
>>> df_train = spark.createDataFrame([
...     (Vectors.dense(1.0, 2.0, 3.0), 0, False, 1.0),
...     (Vectors.sparse(3, {1: 1.0, 2: 5.5}), 1, False, 2.0),
...     (Vectors.dense(4.0, 5.0, 6.0), 2, True, 1.0),
...     (Vectors.sparse(3, {1: 6.0, 2: 7.5}), 3, True, 2.0),
... ], ["features", "label", "isVal", "weight"])
>>> df_test = spark.createDataFrame([
...     (Vectors.dense(1.0, 2.0, 3.0), ),
...     (Vectors.sparse(3, {1: 1.0, 2: 5.5}), )
... ], ["features"])
>>> xgb_regressor = SparkXGBRegressor(max_depth=5, missing=0.0,
... validation_indicator_col='isVal', weight_col='weight',
... early_stopping_rounds=1, eval_metric='rmse')
>>> xgb_reg_model = xgb_regressor.fit(df_train)
>>> xgb_reg_model.transform(df_test)

ÚfeaturesÚlabelÚ
predictionNr   FT)Úfeatures_colÚ	label_colÚprediction_colÚpred_contrib_colÚvalidation_indicator_colÚ
weight_colÚbase_margin_colÚnum_workersÚdeviceÚforce_repartitionÚrepartition_random_shuffleÚenable_sparse_data_optimÚlaunch_tracker_on_driverÚcoll_cfgrH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   Úkwargsr   c                ó^   >• [         TU ]  5         U R                  nU R                  " S0 UD6  g ©N© ©ÚsuperÚ__init__Ú_input_kwargsÚ	setParams)ÚselfrH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   Úinput_kwargsÚ	__class__s                    €r)   r\   ÚSparkXGBRegressor.__init__Á   s*   ø€ ô( 	‰ÑÔØ×)Ñ)ˆØ�ŠÑ&˜Ó&r2   c                 ó   • [         $ r   ©r   ©Úclss    r)   r9   ÚSparkXGBRegressor._xgb_clsÙ   ó   € äÐr2   ÚSparkXGBRegressorModelc                 ó   • [         $ r   )ri   re   s    r)   Ú_pyspark_model_clsÚ$SparkXGBRegressor._pyspark_model_clsÝ   s   € ä%Ð%r2   c                 óx   >• [         TU ]  5         U R                  U R                  5      (       a  [	        S5      eg )NzCSpark Xgboost regressor estimator does not support `qid_col` param.©r[   Ú_validate_paramsÚ	isDefinedÚqid_colÚ
ValueError©r_   ra   s    €r)   ro   Ú"SparkXGBRegressor._validate_paramsá   s6   ø€ Ü‰Ñ Ô"Ø�>‰>˜$Ÿ,™,×'Ñ'ÜØUóð ð (r2   rY   ©r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r7   r   r   ÚintÚboolr   r   r\   Úclassmethodr   r   r9   rk   ro   Ú__static_attributes__Ú__classcell__©ra   s   @r)   rC   rC   O   s[  ø† ñoðb ð /9Ø Ø*Ø*.Ø26Ø$(Ø)-ØØ $Ø"'Ø+0Ø).Ø)-Ø%)ò!'ð ˜C  c¡˜NÑ+ð'ð ð	'ð
 ð'ð # 3™-ð'ð #+¨3¡-ð'ð ˜S‘Mð'ð " #™ð'ð ð'ð ˜‘ð'ð  ð'ð %)ð'ð #'ð'ð #'ð'ð  ˜6Ñ"ð!'ð" ð#'ð$ 
÷%'ó ð'ð. ð˜˜lÑ+ó ó ðð ð& 4Ð(@Ñ#Aó &ó ð&÷õ r2   rC   c                   ó6   • \ rS rSrSr\S\\   4S j5       rSr	g)ri   éé   zh
The model returned by :func:`xgboost.spark.SparkXGBRegressor.fit`

.. Note:: This API is experimental.
r   c                 ó   • [         $ r   rd   re   s    r)   r9   ÚSparkXGBRegressorModel._xgb_clsð   rh   r2   rY   N)
rv   rw   rx   ry   rz   r}   r   r   r9   r~   rY   r2   r)   ri   ri   é   s'   † ñð ð˜˜lÑ+ó ó ór2   ri   c            &       ó(  ^ • \ rS rSrSr\SSSSSSSSSS	SS
S
S
SSS.S\\\\   4   S\S\S\S\S\	\   S\	\   S\	\   S\	\   S\
S\	\   S\S\S\S\S\	\   S\SS4$U 4S jjj5       r\S\\   4S  j5       r\S\S!   4S" j5       rS%U 4S# jjrS$rU =r$ )&ÚSparkXGBClassifieréø   aè  SparkXGBClassifier is a PySpark ML estimator. It implements the XGBoost
classification algorithm based on XGBoost python library, and it can be used in
PySpark Pipeline and PySpark ML meta algorithms like
- :py:class:`~pyspark.ml.tuning.CrossValidator`/
- :py:class:`~pyspark.ml.tuning.TrainValidationSplit`/
- :py:class:`~pyspark.ml.classification.OneVsRest`

SparkXGBClassifier automatically supports most of the parameters in
:py:class:`xgboost.XGBClassifier` constructor and most of the parameters used in
:py:meth:`xgboost.XGBClassifier.fit` and :py:meth:`xgboost.XGBClassifier.predict`
method.

To enable GPU support, set `device` to `cuda` or `gpu`.

SparkXGBClassifier doesn't support setting `base_margin` explicitly as well, but
support another param called `base_margin_col`. see doc below for more details.

SparkXGBClassifier doesn't support setting `output_margin`, but we can get output
margin from the raw prediction column. See `raw_prediction_col` param doc below for
more details.

SparkXGBClassifier doesn't support `validate_features` and `output_margin` param.

SparkXGBClassifier doesn't support setting `nthread` xgboost param, instead, the
`nthread` param for each xgboost worker will be set equal to `spark.task.cpus`
config value.


Parameters
----------

features_col:
    When the value is string, it requires the features column name to be vector type.
    When the value is a list of string, it requires all the feature columns to be numeric types.
label_col:
    Label column name. Default to "label".
prediction_col:
    Prediction column name. Default to "prediction"
probability_col:
    Column name for predicted class conditional probabilities. Default to probabilityCol
raw_prediction_col:
    The `output_margin=True` is implicitly supported by the
    `rawPredictionCol` output column, which is always returned with the predicted margin
    values.
pred_contrib_col:
    Contribution prediction column name.
validation_indicator_col:
    For params related to `xgboost.XGBClassifier` training with
    evaluation dataset's supervision,
    set :py:attr:`xgboost.spark.SparkXGBClassifier.validation_indicator_col`
    parameter instead of setting the `eval_set` parameter in `xgboost.XGBClassifier`
    fit method.
weight_col:
    To specify the weight of the training and validation dataset, set
    :py:attr:`xgboost.spark.SparkXGBClassifier.weight_col` parameter instead of setting
    `sample_weight` and `sample_weight_eval_set` parameter in `xgboost.XGBClassifier`
    fit method.
base_margin_col:
    To specify the base margins of the training and validation
    dataset, set :py:attr:`xgboost.spark.SparkXGBClassifier.base_margin_col` parameter
    instead of setting `base_margin` and `base_margin_eval_set` in the
    `xgboost.XGBClassifier` fit method.

num_workers:
    How many XGBoost workers to be used to train.
    Each XGBoost worker corresponds to one spark task.
device:

    .. versionadded:: 2.0.0

    Device for XGBoost workers, available options are `cpu`, `cuda`, and `gpu`.

force_repartition:
    Boolean value to specify if forcing the input dataset to be repartitioned
    before XGBoost training.
repartition_random_shuffle:
    Boolean value to specify if randomly shuffling the dataset when repartitioning is required.
enable_sparse_data_optim:
    Boolean value to specify if enabling sparse data optimization, if True,
    Xgboost DMatrix object will be constructed from sparse matrix instead of
    dense matrix.
launch_tracker_on_driver:
    Boolean value to indicate whether the tracker should be launched on the driver side or
    the executor side.
coll_cfg:
    The collective configuration. See :py:class:`~xgboost.collective.Config`

kwargs:
    A dictionary of xgboost parameters, please refer to
    https://xgboost.readthedocs.io/en/stable/parameter.html

Note
----

The Parameters chart above contains parameters that need special handling.
For a full list of parameters, see entries with `Param(parent=...` below.

This API is experimental.

Examples
--------

>>> from xgboost.spark import SparkXGBClassifier
>>> from pyspark.ml.linalg import Vectors
>>> df_train = spark.createDataFrame([
...     (Vectors.dense(1.0, 2.0, 3.0), 0, False, 1.0),
...     (Vectors.sparse(3, {1: 1.0, 2: 5.5}), 1, False, 2.0),
...     (Vectors.dense(4.0, 5.0, 6.0), 0, True, 1.0),
...     (Vectors.sparse(3, {1: 6.0, 2: 7.5}), 1, True, 2.0),
... ], ["features", "label", "isVal", "weight"])
>>> df_test = spark.createDataFrame([
...     (Vectors.dense(1.0, 2.0, 3.0), ),
... ], ["features"])
>>> xgb_classifier = SparkXGBClassifier(max_depth=5, missing=0.0,
...     validation_indicator_col='isVal', weight_col='weight',
...     early_stopping_rounds=1, eval_metric='logloss')
>>> xgb_clf_model = xgb_classifier.fit(df_train)
>>> xgb_clf_model.transform(df_test).show()

rE   rF   rG   ÚprobabilityÚrawPredictionNr   FT)rH   rI   rJ   Úprobability_colÚraw_prediction_colrK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rH   rI   rJ   rŠ   r‹   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   r   c                ó|   >• [         TU ]  5         U R                  nU R                  " S0 UD6  U R	                  S S9  g )N)Ú	objectiverY   )r[   r\   r]   r^   Ú_setDefault)r_   rH   rI   rJ   rŠ   r‹   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   r`   ra   s                      €r)   r\   ÚSparkXGBClassifier.__init__r  s=   ø€ ô, 	‰ÑÔð
 ×)Ñ)ˆØ�ŠÑ&˜Ò&Ø×Ñ 4ÐÒ(r2   c                 ó   • [         $ r   ©r   re   s    r)   r9   ÚSparkXGBClassifier._xgb_cls‘  ó   € äÐr2   ÚSparkXGBClassifierModelc                 ó   • [         $ r   )r”   re   s    r)   rk   Ú%SparkXGBClassifier._pyspark_model_cls•  s   € ä&Ð&r2   c                 óº   >• [         TU ]  5         U R                  U R                  5      (       a  [	        S5      eU R                  S5      (       a  [	        S5      eg )NzDSpark Xgboost classifier estimator does not support `qid_col` param.r�   zHSetting custom 'objective' param is not allowed in 'SparkXGBClassifier'.)r[   ro   rp   rq   rr   ÚgetOrDefaultrs   s    €r)   ro   Ú#SparkXGBClassifier._validate_params™  sY   ø€ Ü‰Ñ Ô"Ø�>‰>˜$Ÿ,™,×'Ñ'ÜØVóð ð ×Ñ˜[×)Ñ)ÜØZóð ð *r2   rY   ru   )rv   rw   rx   ry   rz   r   r   r7   r   r   r{   r|   r   r   r\   r}   r   r   r9   rk   ro   r~   r   r€   s   @r)   r†   r†   ø   su  ø† ñwðr ð /9Ø Ø*Ø,Ø"1Ø*.Ø26Ø$(Ø)-ØØ $Ø"'Ø+0Ø).Ø)-Ø%)ò%)ð ˜C  c¡˜NÑ+ð)ð ð	)ð
 ð)ð ð)ð  ð)ð # 3™-ð)ð #+¨3¡-ð)ð ˜S‘Mð)ð " #™ð)ð ð)ð ˜‘ð)ð  ð)ð %)ð)ð  #'ð!)ð" #'ð#)ð$ ˜6Ñ"ð%)ð& ð')ð( 
÷))ó ð)ð< ð˜˜mÑ,ó ó ðð ð' 4Ð(AÑ#Bó 'ó ð'÷	õ 	r2   r†   c                   ó6   • \ rS rSrSr\S\\   4S j5       rSr	g)r”   i¥  zi
The model returned by :func:`xgboost.spark.SparkXGBClassifier.fit`

.. Note:: This API is experimental.
r   c                 ó   • [         $ r   r‘   re   s    r)   r9   Ú SparkXGBClassifierModel._xgb_cls¬  r“   r2   rY   N)
rv   rw   rx   ry   rz   r}   r   r   r9   r~   rY   r2   r)   r”   r”   ¥  s'   † ñð ð˜˜mÑ,ó ó ór2   r”   c            $       ó(  ^ • \ rS rSrSr\SSSSSSSSSSSSSS	SS
.S\\\\   4   S\S\S\	\   S\	\   S\	\   S\	\   S\	\   S\
S\	\   S\S\S\S\S\	\   S\SS4"U 4S jjj5       r\S\\   4S j5       r\S\S   4S j5       rS"U 4S  jjrS!rU =r$ )#ÚSparkXGBRankeri´  a®  SparkXGBRanker is a PySpark ML estimator. It implements the XGBoost
ranking algorithm based on XGBoost python library, and it can be used in
PySpark Pipeline and PySpark ML meta algorithms like
:py:class:`~pyspark.ml.tuning.CrossValidator`/
:py:class:`~pyspark.ml.tuning.TrainValidationSplit`/
:py:class:`~pyspark.ml.classification.OneVsRest`

SparkXGBRanker automatically supports most of the parameters in
:py:class:`xgboost.XGBRanker` constructor and most of the parameters used in
:py:meth:`xgboost.XGBRanker.fit` and :py:meth:`xgboost.XGBRanker.predict` method.

To enable GPU support, set `device` to `cuda` or `gpu`.

SparkXGBRanker doesn't support setting `base_margin` explicitly as well, but support
another param called `base_margin_col`. see doc below for more details.

SparkXGBRanker doesn't support setting `output_margin`, but we can get output margin
from the raw prediction column. See `raw_prediction_col` param doc below for more
details.

SparkXGBRanker doesn't support `validate_features` and `output_margin` param.

SparkXGBRanker doesn't support setting `nthread` xgboost param, instead, the
`nthread` param for each xgboost worker will be set equal to `spark.task.cpus`
config value.


Parameters
----------

features_col:
    When the value is string, it requires the features column name to be vector type.
    When the value is a list of string, it requires all the feature columns to be numeric types.
label_col:
    Label column name. Default to "label".
prediction_col:
    Prediction column name. Default to "prediction"
pred_contrib_col:
    Contribution prediction column name.
validation_indicator_col:
    For params related to `xgboost.XGBRanker` training with
    evaluation dataset's supervision,
    set :py:attr:`xgboost.spark.SparkXGBRanker.validation_indicator_col`
    parameter instead of setting the `eval_set` parameter in :py:class:`xgboost.XGBRanker`
    fit method.
weight_col:
    To specify the weight of the training and validation dataset, set
    :py:attr:`xgboost.spark.SparkXGBRanker.weight_col` parameter instead of setting
    `sample_weight` and `sample_weight_eval_set` parameter in :py:class:`xgboost.XGBRanker`
    fit method.
base_margin_col:
    To specify the base margins of the training and validation
    dataset, set :py:attr:`xgboost.spark.SparkXGBRanker.base_margin_col` parameter
    instead of setting `base_margin` and `base_margin_eval_set` in the
    :py:class:`xgboost.XGBRanker` fit method.
qid_col:
    Query id column name.
num_workers:
    How many XGBoost workers to be used to train.
    Each XGBoost worker corresponds to one spark task.
device:

    .. versionadded:: 2.0.0

    Device for XGBoost workers, available options are `cpu`, `cuda`, and `gpu`.

force_repartition:
    Boolean value to specify if forcing the input dataset to be repartitioned
    before XGBoost training.
repartition_random_shuffle:
    Boolean value to specify if randomly shuffling the dataset when repartitioning is required.
enable_sparse_data_optim:
    Boolean value to specify if enabling sparse data optimization, if True,
    Xgboost DMatrix object will be constructed from sparse matrix instead of
    dense matrix.
launch_tracker_on_driver:
    Boolean value to indicate whether the tracker should be launched on the driver side or
    the executor side.
coll_cfg:
    The collective configuration. See :py:class:`~xgboost.collective.Config`

kwargs:
    A dictionary of xgboost parameters, please refer to
    https://xgboost.readthedocs.io/en/stable/parameter.html

.. Note:: The Parameters chart above contains parameters that need special handling.
    For a full list of parameters, see entries with `Param(parent=...` below.

.. Note:: This API is experimental.

Examples
--------

>>> from xgboost.spark import SparkXGBRanker
>>> from pyspark.ml.linalg import Vectors
>>> ranker = SparkXGBRanker(qid_col="qid")
>>> df_train = spark.createDataFrame(
...     [
...         (Vectors.dense(1.0, 2.0, 3.0), 0, 0),
...         (Vectors.dense(4.0, 5.0, 6.0), 1, 0),
...         (Vectors.dense(9.0, 4.0, 8.0), 2, 0),
...         (Vectors.sparse(3, {1: 1.0, 2: 5.5}), 0, 1),
...         (Vectors.sparse(3, {1: 6.0, 2: 7.5}), 1, 1),
...         (Vectors.sparse(3, {1: 8.0, 2: 9.5}), 2, 1),
...     ],
...     ["features", "label", "qid"],
... )
>>> df_test = spark.createDataFrame(
...     [
...         (Vectors.dense(1.5, 2.0, 3.0), 0),
...         (Vectors.dense(4.5, 5.0, 6.0), 0),
...         (Vectors.dense(9.0, 4.5, 8.0), 0),
...         (Vectors.sparse(3, {1: 1.0, 2: 6.0}), 1),
...         (Vectors.sparse(3, {1: 6.0, 2: 7.0}), 1),
...         (Vectors.sparse(3, {1: 8.0, 2: 10.5}), 1),
...     ],
...     ["features", "qid"],
... )
>>> model = ranker.fit(df_train)
>>> model.transform(df_test).show()
rE   rF   rG   Nr   FT)rH   rI   rJ   rK   rL   rM   rN   rq   rO   rP   rQ   rR   rS   rT   rU   rH   rI   rJ   rK   rL   rM   rN   rq   rO   rP   rQ   rR   rS   rT   rU   rV   r   c                ó^   >• [         TU ]  5         U R                  nU R                  " S0 UD6  g rX   rZ   )r_   rH   rI   rJ   rK   rL   rM   rN   rq   rO   rP   rQ   rR   rS   rT   rU   rV   r`   ra   s                     €r)   r\   ÚSparkXGBRanker.__init__/  s*   ø€ ô* 	‰ÑÔØ×)Ñ)ˆØ�ŠÑ&˜Ó&r2   c                 ó   • [         $ r   ©r   re   s    r)   r9   ÚSparkXGBRanker._xgb_clsH  ó   € äÐr2   ÚSparkXGBRankerModelc                 ó   • [         $ r   )r¥   re   s    r)   rk   Ú!SparkXGBRanker._pyspark_model_clsL  s   € ä"Ð"r2   c                 óx   >• [         TU ]  5         U R                  U R                  5      (       d  [	        S5      eg )Nz@Spark Xgboost ranker estimator requires setting `qid_col` param.rn   rs   s    €r)   ro   ÚSparkXGBRanker._validate_paramsP  s6   ø€ Ü‰Ñ Ô"Ø�~‰~˜dŸl™l×+Ñ+ÜØRóð ð ,r2   rY   ru   )rv   rw   rx   ry   rz   r   r   r7   r   r   r{   r|   r   r   r\   r}   r   r   r9   rk   ro   r~   r   r€   s   @r)   rž   rž   ´  sk  ø† ñxðt ð /9Ø Ø*Ø*.Ø26Ø$(Ø)-Ø!%ØØ $Ø"'Ø+0Ø).Ø)-Ø%)ò#'ð ˜C  c¡˜NÑ+ð'ð ð	'ð
 ð'ð # 3™-ð'ð #+¨3¡-ð'ð ˜S‘Mð'ð " #™ð'ð ˜#‘ð'ð ð'ð ˜‘ð'ð  ð'ð %)ð'ð #'ð'ð  #'ð!'ð" ˜6Ñ"ð#'ð$ ð%'ð& 
÷''ó ð'ð0 ð˜˜i™ó ó ðð ð# 4Ð(=Ñ#>ó #ó ð#÷õ r2   rž   c                   ó6   • \ rS rSrSr\S\\   4S j5       rSr	g)r¥   iX  ze
The model returned by :func:`xgboost.spark.SparkXGBRanker.fit`

.. Note:: This API is experimental.
r   c                 ó   • [         $ r   r¢   re   s    r)   r9   ÚSparkXGBRankerModel._xgb_cls_  r¤   r2   rY   N)
rv   rw   rx   ry   rz   r}   r   r   r9   r~   rY   r2   r)   r¥   r¥   X  s&   † ñð ð˜˜i™ó ó ór2   r¥   )$rz   Útypingr   r   r   r   r   Únumpyr   Úpysparkr   Úpyspark.ml.paramr	   r
   Úpyspark.ml.param.sharedr   r   Ú
collectiver   Úsklearnr   r   r   Úcorer   r   r   Úutilsr   rA   rC   ri   r†   r”   rž   r¥   rY   r2   r)   Ú<module>r¶      sá   ðÙ >÷
 4Õ 3ã Ý  ß *ß Jå ß <Ñ <÷ñ õ
 "ð5)ØÐ&Ñ'ð5)Ø04°^Ñ0Dð5)à	ô5)ôpWÐ*ô Wôt	˜^ô 	ñ !Ð!2Ð4JÔ KôjÐ+Ð->Ð@Sô jôZ	Ð2ô 	ñ !Ð!3Ð5LÔ MôaÐ'ô aôH	˜.ô 	ñ ! Ð1DÕ Er2   