o
    Ù­j^	  ã                   @   s²   d Z ddlZddlmZmZ ddlmZmZ ddlZ	ddl
mZmZmZmZ ddlmZmZ ddlmZ er<dd	lmZ G d
d„ deƒZG dd„ deƒZdededefdd„ZdS )zÅExperimental support for a new objective interface with target dimension
reduction.

.. warning::

  Do not use this module unless you want to participate in development.

.. versionadded:: 3.2.0

é    N)ÚABCÚabstractmethod)ÚTYPE_CHECKINGÚTupleé   )Ú_ensure_np_dtypeÚ_is_flattenÚarray_interfaceÚcuda_array_interface)Ú	ArrayLikeÚNumpyOrCupy)Ú_is_cupy_alike)ÚDMatrixc                   @   s6   e Zd ZdZedededddeeef fdd„ƒZd	S )
Ú	Objectivez­Base class for custom objective functions.

    .. warning::

        Do not use this class unless you want to participate in development.

    .. versionadded:: 3.2.0

    Ú	iterationÚy_predÚdtrainr   Úreturnc                 C   s   d S )N© )Úselfr   r   r   r   r   úN/var/www/html/CropPilot/venv/lib/python3.10/site-packages/xgboost/objective.pyÚ__call__*   s   zObjective.__call__N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úintr   r   r   r   r   r   r   r      s    
ÿÿÿ
þr   c                
   @   s6   e Zd ZdZdedededeeef dB fdd„ZdS )	ÚTreeObjectivez»Base class for tree-specific custom objective functions.

    .. warning::

        Do not use this class unless you want to participate in development.

    .. versionadded:: 3.2.0

    r   ÚgradÚhessr   Nc                 C   s   dS )z>Provide a different gradient type for finding tree structures.Nr   )r   r   r   r   r   r   r   Ú
split_grad<   s   zTreeObjective.split_grad)r   r   r   r   r   r   r   r    r   r   r   r   r   0   s    ÿÿÿþr   ÚarrayÚ	n_samplesr   c                 C   s¢   dt | ƒ› �}t| tjƒst| ƒst|ƒ‚| jd |kr/t| ƒr/t 	dt
¡ |  || j| ¡} t| tjƒrCt| | jƒ\} }t| ƒ}|S t| ƒrMt| ƒ}|S t|ƒ‚)NzHExpecting `np.ndarray` or `cupy.ndarray` for gradient and hessian. Got: r   zvSince 2.1.0, the shape of the gradient and hessian is required to be (n_samples, n_targets) or (n_samples, n_classes).)ÚtypeÚ
isinstanceÚnpÚndarrayr   Ú	TypeErrorÚshaper   ÚwarningsÚwarnÚFutureWarningÚreshapeÚsizer   Údtyper	   r
   )r!   r"   ÚmsgÚ_Ú	interfacer   r   r   Ú_grad_arrinfC   s(   ÿÿýûþr2   )r   r)   Úabcr   r   Útypingr   r   Únumpyr%   Ú_data_utilsr   r   r	   r
   Ú_typingr   r   Úcompatr   Úcorer   r   r   r   Úbytesr2   r   r   r   r   Ú<module>   s    