§
    ¼¸j¿ý  ã                   ó@  — d Z ddlZddlmZ ddlZddlmZ ddlm	Z	 ddl
mZmZmZmZmZ ddlmZmZmZ dd	lmZ dd
lmZmZmZmZmZ g d¢Zd<d„Z	 d=d„Z edgdgddg eddh¦  «        dgdœd¬¦  «        dddœd„¦   «         Z edgdgddg eeddd¬¦  «        g eddh¦  «        dgdœd¬¦  «        ddddœd„¦   «         Z  edgdgddg eddh¦  «        dgdœd¬¦  «        dddœd„¦   «         Z! edgdgddg eddh¦  «        dgdœd¬¦  «        dddœd„¦   «         Z" edgdgddg eddh¦  «        dgdœd¬¦  «        dddœd „¦   «         Z# edgdgddg eddh¦  «        dgdœd¬¦  «        dddœd!„¦   «         Z$ edgdgddg eddh¦  «        dgdœd¬¦  «        dddœd"„¦   «         Z% edgdg eddh¦  «        dgddgd#œd¬¦  «        ddd$œd%„¦   «         Z&d&„ Z' edgdgddg eh d'£¦  «        dgd(gd)œd¬¦  «        dddd*œd+„¦   «         Z( edgdgddg eh d'£¦  «        ddgd(gd)œd¬¦  «        dddd*œd,„¦   «         Z) edgdgd-œd¬¦  «        d.„ ¦   «         Z*d/„ Z+ edgdgddg eeddd0¬¦  «         eeddd1¬¦  «        gd2œd¬¦  «        ddd3œd4„¦   «         Z, edgdgddgd5œd¬¦  «        dd6œd7„¦   «         Z- edgdgddgd5œd¬¦  «        dd6œd8„¦   «         Z. edgdgddg eeddd0¬¦  «         eeddd1¬¦  «        gd2œd¬¦  «        ddd3œd9„¦   «         Z/ edgdgddg eeddd¬¦  «        g eddh¦  «        dgdœd¬¦  «        ddddœd:„¦   «         Z0 edgdgddg eddh¦  «        dgdœd¬¦  «        dddœd;„¦   «         Z1dS )>zòMetrics to assess performance on regression task.

Functions named as ``*_score`` return a scalar value to maximize: the higher
the better.

Function named as ``*_error`` or ``*_loss`` return a scalar value to minimize:
the lower the better.
é    N)ÚReal)Úxlogyé   )ÚUndefinedMetricWarning)Ú_averageÚ_find_matching_floating_dtypeÚget_namespaceÚget_namespace_and_deviceÚsize)ÚIntervalÚ
StrOptionsÚvalidate_params)Ú_weighted_percentile)Ú_check_sample_weightÚ_num_samplesÚcheck_arrayÚcheck_consistent_lengthÚcolumn_or_1d)Ú	max_errorÚmean_absolute_errorÚmean_squared_errorÚmean_squared_log_errorÚmedian_absolute_errorÚmean_absolute_percentage_errorÚmean_pinball_lossÚr2_scoreÚroot_mean_squared_log_errorÚroot_mean_squared_errorÚexplained_variance_scoreÚmean_tweedie_devianceÚmean_poisson_devianceÚmean_gamma_devianceÚd2_tweedie_scoreÚd2_pinball_scoreÚd2_absolute_error_scoreÚnumericc                 ó0  — t          | |||¬¦  «        \  }}t          | |¦  «         t          | d|¬¦  «        } t          |d|¬¦  «        }| j        dk    r|                     | d¦  «        } |j        dk    r|                     |d¦  «        }| j        d         |j        d         k    r9t          d                     | j        d         |j        d         ¦  «        ¦  «        ‚| j        d         }d}t          |t          ¦  «        r(||vr#t          d                     ||¦  «        ¦  «        ‚nZ|�Xt          |d¬
¦  «        }|dk    rt          d¦  «        ‚||j        d         k    r!t          d|j        d         › d|› d�¦  «        ‚|dk    rdnd}|| ||fS )aY  Check that y_true and y_pred belong to the same regression task.

    To reduce redundancy when calling `_find_matching_floating_dtype`,
    please use `_check_reg_targets_with_floating_dtype` instead.

    Parameters
    ----------
    y_true : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Ground truth (correct) target values.

    y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Estimated target values.

    multioutput : array-like or string in ['raw_values', uniform_average',
        'variance_weighted'] or None
        None is accepted due to backward compatibility of r2_score().

    dtype : str or list, default="numeric"
        the dtype argument passed to check_array.

    xp : module, default=None
        Precomputed array namespace module. When passed, typically from a caller
        that has already performed inspection of its own inputs, skips array
        namespace inspection.

    Returns
    -------
    type_true : one of {'continuous', continuous-multioutput'}
        The type of the true target data, as output by
        'utils.multiclass.type_of_target'.

    y_true : array-like of shape (n_samples, n_outputs)
        Ground truth (correct) target values.

    y_pred : array-like of shape (n_samples, n_outputs)
        Estimated target values.

    multioutput : array-like of shape (n_outputs) or string in ['raw_values',
        uniform_average', 'variance_weighted'] or None
        Custom output weights if ``multioutput`` is array-like or
        just the corresponding argument if ``multioutput`` is a
        correct keyword.
    ©ÚxpF)Ú	ensure_2dÚdtypeé   )éÿÿÿÿr,   z<y_true and y_pred have different number of output ({0}!={1}))Ú
raw_valuesÚuniform_averageÚvariance_weightedzIAllowed 'multioutput' string values are {}. You provided multioutput={!r}N)r*   z5Custom weights are useful only in multi-output cases.r   z+There must be equally many custom weights (z) as outputs (z).Ú
continuousúcontinuous-multioutput)
r	   r   r   ÚndimÚreshapeÚshapeÚ
ValueErrorÚformatÚ
isinstanceÚstr)	Úy_trueÚy_predÚmultioutputr+   r)   Ú_Ú	n_outputsÚallowed_multioutput_strÚy_types	            úk/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/sklearn/metrics/_regression.pyÚ_check_reg_targetsrB   :   sñ  € õX ˜& &¨+¸"Ð=Ñ=Ô=�E€Bˆå˜F FÑ+Ô+Ð+Ý˜¨5¸Ð>Ñ>Ô>€FÝ˜¨5¸Ð>Ñ>Ô>€Fà„{�aÒÐØ—’˜F GÑ,Ô,ˆà„{�aÒÐØ—’˜F GÑ,Ô,ˆà„|�A„˜&œ, qœ/Ò)Ð)ÝØJ×QÒQØ”˜Q” ¤¨a¤ñô ñ
ô 
ð 	
ð ”˜Q”€IØTÐÝ�+�sÑ#Ô#ð ØÐ5Ð5Ð5Ýð0ß06²Ø+¨[ñ1ô 1ñô ð ð 6ð 
Ð	 Ý! +¸Ð?Ñ?Ô?ˆØ˜Š>ˆ>ÝÐTÑUÔUÐUØ˜+Ô+¨AÔ.Ò.Ð.ÝðFØÔ% aÔ(ðFð FØ8AðFð Fð Fñô ð ð '¨!š^˜^ˆ\ˆ\Ð1I€Fà�6˜6 ;Ð.Ð.ó    c                 óš   — t          | |||¬¦  «        }t          | ||||¬¦  «        \  }} }}|�|                     ||¬¦  «        }|| |||fS )a  Ensures that y_true, y_pred, and sample_weight correspond to the same
    regression task.

    Extends `_check_reg_targets` by automatically selecting a suitable floating-point
    data type for inputs using `_find_matching_floating_dtype`.

    Use this private method only when converting inputs to array API-compatibles.

    Parameters
    ----------
    y_true : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Ground truth (correct) target values.

    y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Estimated target values.

    sample_weight : array-like of shape (n_samples,)

    multioutput : array-like or string in ['raw_values', 'uniform_average',         'variance_weighted'] or None
        None is accepted due to backward compatibility of r2_score().

    xp : module, default=None
        Precomputed array namespace module. When passed, typically from a caller
        that has already performed inspection of its own inputs, skips array
        namespace inspection.

    Returns
    -------
    type_true : one of {'continuous', 'continuous-multioutput'}
        The type of the true target data, as output by
        'utils.multiclass.type_of_target'.

    y_true : array-like of shape (n_samples, n_outputs)
        Ground truth (correct) target values.

    y_pred : array-like of shape (n_samples, n_outputs)
        Estimated target values.

    sample_weight : array-like of shape (n_samples,), default=None
        Sample weights.

    multioutput : array-like of shape (n_outputs) or string in ['raw_values',         'uniform_average', 'variance_weighted'] or None
        Custom output weights if ``multioutput`` is array-like or
        just the corresponding argument if ``multioutput`` is a
        correct keyword.
    r(   )r+   r)   N©r+   )r   rB   Úasarray)r:   r;   Úsample_weightr<   r)   Ú
dtype_namer@   s          rA   Ú&_check_reg_targets_with_floating_dtyperI   ‘   sr   € õf /¨v°v¸}ÐQSÐTÑTÔT€Jå*<Ø�˜¨:¸"ð+ñ +ô +Ñ'€FˆF�F˜Kð Ð ØŸ
š
 =¸
˜
ÑCÔCˆà�6˜6 =°+Ð=Ð=rC   z
array-liker.   r/   ©r:   r;   rG   r<   T)Úprefer_skip_nested_validation©rG   r<   c                ó^  — t          | |||¦  «        \  }}t          | ||||¬¦  «        \  }} }}}t          | ||¦  «         t          |                     || z
  ¦  «        |d|¬¦  «        }t          |t          ¦  «        r|dk    r|S |dk    rd}t          ||¬¦  «        }t          |¦  «        S )a  Mean absolute error regression loss.

    Read more in the :ref:`User Guide <mean_absolute_error>`.

    Parameters
    ----------
    y_true : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Ground truth (correct) target values.

    y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Estimated target values.

    sample_weight : array-like of shape (n_samples,), default=None
        Sample weights.

    multioutput : {'raw_values', 'uniform_average'}  or array-like of shape             (n_outputs,), default='uniform_average'
        Defines aggregating of multiple output values.
        Array-like value defines weights used to average errors.

        'raw_values' :
            Returns a full set of errors in case of multioutput input.

        'uniform_average' :
            Errors of all outputs are averaged with uniform weight.

    Returns
    -------
    loss : float or array of floats
        If multioutput is 'raw_values', then mean absolute error is returned
        for each output separately.
        If multioutput is 'uniform_average' or an ndarray of weights, then the
        weighted average of all output errors is returned.

        MAE output is non-negative floating point. The best value is 0.0.

    Examples
    --------
    >>> from sklearn.metrics import mean_absolute_error
    >>> y_true = [3, -0.5, 2, 7]
    >>> y_pred = [2.5, 0.0, 2, 8]
    >>> mean_absolute_error(y_true, y_pred)
    0.5
    >>> y_true = [[0.5, 1], [-1, 1], [7, -6]]
    >>> y_pred = [[0, 2], [-1, 2], [8, -5]]
    >>> mean_absolute_error(y_true, y_pred)
    0.75
    >>> mean_absolute_error(y_true, y_pred, multioutput='raw_values')
    array([0.5, 1. ])
    >>> mean_absolute_error(y_true, y_pred, multioutput=[0.3, 0.7])
    0.85...
    r(   r   )ÚweightsÚaxisr)   r.   r/   N©rN   )r	   rI   r   r   Úabsr8   r9   Úfloat)r:   r;   rG   r<   r)   r=   Úoutput_errorsr   s           rA   r   r   Ò   så   € õ@ ˜& &¨-¸ÑEÔE�E€Bˆõ 	/Ø�F˜M¨;¸2ð	
ñ 	
ô 	
ñ 2€A€vˆv�} kõ ˜F F¨MÑ:Ô:Ð:åØ
�Šˆv˜‰ÑÔ¨¸QÀ2ðñ ô €Mõ �+�sÑ#Ô#ð Ø˜,Ò&Ð&Ø Ð ØÐ-Ò-Ð-àˆKõ # =¸+ÐFÑFÔFÐåÐ$Ñ%Ô%Ð%rC   r,   Úboth)Úclosed)r:   r;   rG   Úalphar<   ç      à?©rG   rV   r<   c                ó’  — t          | ||¦  «        \  }} }}t          | ||¦  «         | |z
  }|dk                         |j        ¦  «        }||z  |z  d|z
  d|z
  z  |z  z
  }t	          j        ||d¬¦  «        }	t          |t          ¦  «        r|dk    r|	S t          |t          ¦  «        r|dk    rd}t	          j        |	|¬¦  «        S )a"  Pinball loss for quantile regression.

    Read more in the :ref:`User Guide <pinball_loss>`.

    Parameters
    ----------
    y_true : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Ground truth (correct) target values.

    y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Estimated target values.

    sample_weight : array-like of shape (n_samples,), default=None
        Sample weights.

    alpha : float, slope of the pinball loss, default=0.5,
        This loss is equivalent to :ref:`mean_absolute_error` when `alpha=0.5`,
        `alpha=0.95` is minimized by estimators of the 95th percentile.

    multioutput : {'raw_values', 'uniform_average'}  or array-like of shape             (n_outputs,), default='uniform_average'
        Defines aggregating of multiple output values.
        Array-like value defines weights used to average errors.

        'raw_values' :
            Returns a full set of errors in case of multioutput input.

        'uniform_average' :
            Errors of all outputs are averaged with uniform weight.

    Returns
    -------
    loss : float or ndarray of floats
        If multioutput is 'raw_values', then mean absolute error is returned
        for each output separately.
        If multioutput is 'uniform_average' or an ndarray of weights, then the
        weighted average of all output errors is returned.

        The pinball loss output is a non-negative floating point. The best
        value is 0.0.

    Examples
    --------
    >>> from sklearn.metrics import mean_pinball_loss
    >>> y_true = [1, 2, 3]
    >>> mean_pinball_loss(y_true, [0, 2, 3], alpha=0.1)
    np.float64(0.03...)
    >>> mean_pinball_loss(y_true, [1, 2, 4], alpha=0.1)
    np.float64(0.3...)
    >>> mean_pinball_loss(y_true, [0, 2, 3], alpha=0.9)
    np.float64(0.3...)
    >>> mean_pinball_loss(y_true, [1, 2, 4], alpha=0.9)
    np.float64(0.03...)
    >>> mean_pinball_loss(y_true, y_true, alpha=0.1)
    np.float64(0.0)
    >>> mean_pinball_loss(y_true, y_true, alpha=0.9)
    np.float64(0.0)
    r   r,   ©rN   rO   r.   r/   NrP   )rB   r   Úastyper+   ÚnpÚaverager8   r9   )
r:   r;   rG   rV   r<   r@   ÚdiffÚsignÚlossrS   s
             rA   r   r   0  sî   € õN +=Ø�˜ñ+ô +Ñ'€FˆF�F˜Kõ ˜F F¨MÑ:Ô:Ð:Ø�F‰?€DØ�AŠI×Ò˜dœjÑ)Ô)€DØ�4‰<˜$Ñ ! e¡)°°D±Ñ!9¸DÑ!@Ñ@€DÝ”J˜t¨]ÀÐCÑCÔC€Må�+�sÑ#Ô#ð ¨°|Ò(CÐ(CØÐå�+�sÑ#Ô#ð ¨Ð7HÒ(HÐ(HàˆåŒ:�m¨[Ð9Ñ9Ô9Ð9rC   c                ó*  — t          | |||¦  «        \  }}t          | ||||¬¦  «        \  }} }}}t          | ||¦  «         |                     |                     |j        ¦  «        j        | j        ¬¦  «        }|                     | ¦  «        }|                     || z
  ¦  «        | 	                    ||¦  «        z  }t          ||d¬¦  «        }	t          |t          ¦  «        r|dk    r|	S |dk    rd}t          |	|¬¦  «        }
t          |
¦  «        S )	a
  Mean absolute percentage error (MAPE) regression loss.

    Note that we are not using the common "percentage" definition: the percentage
    in the range [0, 100] is converted to a relative value in the range [0, 1]
    by dividing by 100. Thus, an error of 200% corresponds to a relative error of 2.

    Read more in the :ref:`User Guide <mean_absolute_percentage_error>`.

    .. versionadded:: 0.24

    Parameters
    ----------
    y_true : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Ground truth (correct) target values.

    y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Estimated target values.

    sample_weight : array-like of shape (n_samples,), default=None
        Sample weights.

    multioutput : {'raw_values', 'uniform_average'} or array-like
        Defines aggregating of multiple output values.
        Array-like value defines weights used to average errors.
        If input is list then the shape must be (n_outputs,).

        'raw_values' :
            Returns a full set of errors in case of multioutput input.

        'uniform_average' :
            Errors of all outputs are averaged with uniform weight.

    Returns
    -------
    loss : float or ndarray of floats
        If multioutput is 'raw_values', then mean absolute percentage error
        is returned for each output separately.
        If multioutput is 'uniform_average' or an ndarray of weights, then the
        weighted average of all output errors is returned.

        MAPE output is non-negative floating point. The best value is 0.0.
        But note that bad predictions can lead to arbitrarily large
        MAPE values, especially if some `y_true` values are very close to zero.
        Note that we return a large value instead of `inf` when `y_true` is zero.

    Examples
    --------
    >>> from sklearn.metrics import mean_absolute_percentage_error
    >>> y_true = [3, -0.5, 2, 7]
    >>> y_pred = [2.5, 0.0, 2, 8]
    >>> mean_absolute_percentage_error(y_true, y_pred)
    0.3273...
    >>> y_true = [[0.5, 1], [-1, 1], [7, -6]]
    >>> y_pred = [[0, 2], [-1, 2], [8, -5]]
    >>> mean_absolute_percentage_error(y_true, y_pred)
    0.5515...
    >>> mean_absolute_percentage_error(y_true, y_pred, multioutput=[0.3, 0.7])
    0.6198...
    >>> # the value when some element of the y_true is zero is arbitrarily high because
    >>> # of the division by epsilon
    >>> y_true = [1., 0., 2.4, 7.]
    >>> y_pred = [1.2, 0.1, 2.4, 8.]
    >>> mean_absolute_percentage_error(y_true, y_pred)
    112589990684262.48
    r(   rE   r   rZ   r.   r/   NrP   )r	   rI   r   rF   ÚfinfoÚfloat64Úepsr+   rQ   Úmaximumr   r8   r9   rR   )r:   r;   rG   r<   r)   r=   ÚepsilonÚ
y_true_absÚmaperS   r   s              rA   r   r   Š  s'  € õZ ˜& &¨-¸ÑEÔE�E€Bˆå.Ø�F˜M¨;¸2ð	
ñ 	
ô 	
ñ 2€A€vˆv�} kõ
 ˜F F¨MÑ:Ô:Ð:Ø�jŠj˜Ÿš "¤*Ñ-Ô-Ô1¸¼ˆjÑFÔF€GØ—’˜‘”€JØ�6Š6�&˜6‘/Ñ"Ô" R§Z¢Z°
¸GÑ%DÔ%DÑD€DÝ˜T¨=¸qÐAÑAÔA€MÝ�+�sÑ#Ô#ð Ø˜,Ò&Ð&Ø Ð ØÐ-Ò-Ð-àˆKõ &.¨mÀ[Ð%QÑ%QÔ%QÐ"åÐ/Ñ0Ô0Ð0rC   c                ó<  — t          | |||¦  «        \  }}t          | ||||¬¦  «        \  }} }}}t          | ||¦  «         t          | |z
  dz  d|¬¦  «        }t	          |t
          ¦  «        r|dk    r|S |dk    rd}t          ||¬¦  «        }t          |¦  «        S )	aZ  Mean squared error regression loss.

    Read more in the :ref:`User Guide <mean_squared_error>`.

    Parameters
    ----------
    y_true : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Ground truth (correct) target values.

    y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Estimated target values.

    sample_weight : array-like of shape (n_samples,), default=None
        Sample weights.

    multioutput : {'raw_values', 'uniform_average'} or array-like of shape             (n_outputs,), default='uniform_average'
        Defines aggregating of multiple output values.
        Array-like value defines weights used to average errors.

        'raw_values' :
            Returns a full set of errors in case of multioutput input.

        'uniform_average' :
            Errors of all outputs are averaged with uniform weight.

    Returns
    -------
    loss : float or array of floats
        A non-negative floating point value (the best value is 0.0), or an
        array of floating point values, one for each individual target.

    Examples
    --------
    >>> from sklearn.metrics import mean_squared_error
    >>> y_true = [3, -0.5, 2, 7]
    >>> y_pred = [2.5, 0.0, 2, 8]
    >>> mean_squared_error(y_true, y_pred)
    0.375
    >>> y_true = [[0.5, 1],[-1, 1],[7, -6]]
    >>> y_pred = [[0, 2],[-1, 2],[8, -5]]
    >>> mean_squared_error(y_true, y_pred)
    0.708...
    >>> mean_squared_error(y_true, y_pred, multioutput='raw_values')
    array([0.41666667, 1.        ])
    >>> mean_squared_error(y_true, y_pred, multioutput=[0.3, 0.7])
    0.825...
    r(   r   r   )rO   rN   r.   r/   NrP   )r	   rI   r   r   r8   r9   rR   )r:   r;   rG   r<   r)   r=   rS   r   s           rA   r   r   ó  sÑ   € õ@ ˜& &¨-¸ÑEÔE�E€Bˆå.Ø�F˜M¨;¸2ð	
ñ 	
ô 	
ñ 2€A€vˆv�} kõ
 ˜F F¨MÑ:Ô:Ð:Ý˜f v™o°!Ñ3¸!À]ÐSÑSÔS€Må�+�sÑ#Ô#ð Ø˜,Ò&Ð&Ø Ð ØÐ-Ò-Ð-àˆKõ " -¸ÐEÑEÔEÐåÐ#Ñ$Ô$Ð$rC   c                ó  — t          | |||¦  «        \  }}|                     t          | ||d¬¦  «        ¦  «        }t          |t          ¦  «        r|dk    r|S |dk    rd}t          ||¬¦  «        }t          |¦  «        S )aÕ  Root mean squared error regression loss.

    Read more in the :ref:`User Guide <mean_squared_error>`.

    .. versionadded:: 1.4

    Parameters
    ----------
    y_true : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Ground truth (correct) target values.

    y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Estimated target values.

    sample_weight : array-like of shape (n_samples,), default=None
        Sample weights.

    multioutput : {'raw_values', 'uniform_average'} or array-like of shape             (n_outputs,), default='uniform_average'
        Defines aggregating of multiple output values.
        Array-like value defines weights used to average errors.

        'raw_values' :
            Returns a full set of errors in case of multioutput input.

        'uniform_average' :
            Errors of all outputs are averaged with uniform weight.

    Returns
    -------
    loss : float or ndarray of floats
        A non-negative floating point value (the best value is 0.0), or an
        array of floating point values, one for each individual target.

    Examples
    --------
    >>> from sklearn.metrics import root_mean_squared_error
    >>> y_true = [3, -0.5, 2, 7]
    >>> y_pred = [2.5, 0.0, 2, 8]
    >>> root_mean_squared_error(y_true, y_pred)
    0.612...
    >>> y_true = [[0.5, 1],[-1, 1],[7, -6]]
    >>> y_pred = [[0, 2],[-1, 2],[8, -5]]
    >>> root_mean_squared_error(y_true, y_pred)
    0.822...
    r.   rL   r/   NrP   )r	   Úsqrtr   r8   r9   r   rR   )r:   r;   rG   r<   r)   r=   rS   r   s           rA   r   r   M  s¤   € õv ˜& &¨-¸ÑEÔE�E€Bˆà—G’GÝØ�F¨-À\ð	
ñ 	
ô 	
ñô €Mõ �+�sÑ#Ô#ð Ø˜,Ò&Ð&Ø Ð ØÐ-Ò-Ð-àˆKõ ' }¸kÐJÑJÔJÐåÐ(Ñ)Ô)Ð)rC   c                óP  — t          | |¦  «        \  }}t          | ||||¬¦  «        \  }} }}}|                     | dk    ¦  «        s|                     |dk    ¦  «        rt          d¦  «        ‚t	          |                     | ¦  «        |                     |¦  «        ||¬¦  «        S )aœ  Mean squared logarithmic error regression loss.

    Read more in the :ref:`User Guide <mean_squared_log_error>`.

    Parameters
    ----------
    y_true : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Ground truth (correct) target values.

    y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Estimated target values.

    sample_weight : array-like of shape (n_samples,), default=None
        Sample weights.

    multioutput : {'raw_values', 'uniform_average'} or array-like of shape             (n_outputs,), default='uniform_average'

        Defines aggregating of multiple output values.
        Array-like value defines weights used to average errors.

        'raw_values' :
            Returns a full set of errors when the input is of multioutput
            format.

        'uniform_average' :
            Errors of all outputs are averaged with uniform weight.

    Returns
    -------
    loss : float or ndarray of floats
        A non-negative floating point value (the best value is 0.0), or an
        array of floating point values, one for each individual target.

    Examples
    --------
    >>> from sklearn.metrics import mean_squared_log_error
    >>> y_true = [3, 5, 2.5, 7]
    >>> y_pred = [2.5, 5, 4, 8]
    >>> mean_squared_log_error(y_true, y_pred)
    0.039...
    >>> y_true = [[0.5, 1], [1, 2], [7, 6]]
    >>> y_pred = [[0.5, 2], [1, 2.5], [8, 8]]
    >>> mean_squared_log_error(y_true, y_pred)
    0.044...
    >>> mean_squared_log_error(y_true, y_pred, multioutput='raw_values')
    array([0.00462428, 0.08377444])
    >>> mean_squared_log_error(y_true, y_pred, multioutput=[0.3, 0.7])
    0.060...
    r(   r-   zcMean Squared Logarithmic Error cannot be used when targets contain values less than or equal to -1.rL   )r	   rI   Úanyr6   r   Úlog1p©r:   r;   rG   r<   r)   r=   s         rA   r   r   ¡  sÇ   € õD ˜& &Ñ)Ô)�E€BˆåDØ�˜ {°rðñ ô Ñ€A€vˆv�q˜!ð 
‡v‚vˆf˜ŠlÑÔð 
˜rŸvšv f°¢lÑ3Ô3ð 
Ýð?ñ
ô 
ð 	
õ
 Ø
�Š�ÑÔØ
�Š�ÑÔØ#Øð	ñ ô ð rC   c                óP  — t          | |¦  «        \  }}t          | ||||¬¦  «        \  }} }}}|                     | dk    ¦  «        s|                     |dk    ¦  «        rt          d¦  «        ‚t	          |                     | ¦  «        |                     |¦  «        ||¬¦  «        S )ao  Root mean squared logarithmic error regression loss.

    Read more in the :ref:`User Guide <mean_squared_log_error>`.

    .. versionadded:: 1.4

    Parameters
    ----------
    y_true : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Ground truth (correct) target values.

    y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Estimated target values.

    sample_weight : array-like of shape (n_samples,), default=None
        Sample weights.

    multioutput : {'raw_values', 'uniform_average'} or array-like of shape             (n_outputs,), default='uniform_average'

        Defines aggregating of multiple output values.
        Array-like value defines weights used to average errors.

        'raw_values' :
            Returns a full set of errors when the input is of multioutput
            format.

        'uniform_average' :
            Errors of all outputs are averaged with uniform weight.

    Returns
    -------
    loss : float or ndarray of floats
        A non-negative floating point value (the best value is 0.0), or an
        array of floating point values, one for each individual target.

    Examples
    --------
    >>> from sklearn.metrics import root_mean_squared_log_error
    >>> y_true = [3, 5, 2.5, 7]
    >>> y_pred = [2.5, 5, 4, 8]
    >>> root_mean_squared_log_error(y_true, y_pred)
    0.199...
    r(   r-   zhRoot Mean Squared Logarithmic Error cannot be used when targets contain values less than or equal to -1.rL   )r	   rI   rm   r6   r   rn   ro   s         rA   r   r   ÷  sÇ   € õp ˜& &Ñ)Ô)�E€BˆåDØ�˜ {°rðñ ô Ñ€A€vˆv�q˜!ð 
‡v‚vˆf˜ŠlÑÔð 
˜rŸvšv f°¢lÑ3Ô3ð 
Ýð?ñ
ô 
ð 	
õ
 #Ø
�Š�ÑÔØ
�Š�ÑÔØ#Øð	ñ ô ð rC   )r:   r;   r<   rG   )r<   rG   c                ól  — t          | ||¦  «        \  }} }}|€,t          j        t          j        || z
  ¦  «        d¬¦  «        }n6t	          ||¦  «        }t          t          j        || z
  ¦  «        |¬¦  «        }t          |t          ¦  «        r|dk    r|S |dk    rd}t          j        ||¬¦  «        S )aa  Median absolute error regression loss.

    Median absolute error output is non-negative floating point. The best value
    is 0.0. Read more in the :ref:`User Guide <median_absolute_error>`.

    Parameters
    ----------
    y_true : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Ground truth (correct) target values.

    y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Estimated target values.

    multioutput : {'raw_values', 'uniform_average'} or array-like of shape             (n_outputs,), default='uniform_average'
        Defines aggregating of multiple output values. Array-like value defines
        weights used to average errors.

        'raw_values' :
            Returns a full set of errors in case of multioutput input.

        'uniform_average' :
            Errors of all outputs are averaged with uniform weight.

    sample_weight : array-like of shape (n_samples,), default=None
        Sample weights.

        .. versionadded:: 0.24

    Returns
    -------
    loss : float or ndarray of floats
        If multioutput is 'raw_values', then mean absolute error is returned
        for each output separately.
        If multioutput is 'uniform_average' or an ndarray of weights, then the
        weighted average of all output errors is returned.

    Examples
    --------
    >>> from sklearn.metrics import median_absolute_error
    >>> y_true = [3, -0.5, 2, 7]
    >>> y_pred = [2.5, 0.0, 2, 8]
    >>> median_absolute_error(y_true, y_pred)
    np.float64(0.5)
    >>> y_true = [[0.5, 1], [-1, 1], [7, -6]]
    >>> y_pred = [[0, 2], [-1, 2], [8, -5]]
    >>> median_absolute_error(y_true, y_pred)
    np.float64(0.75)
    >>> median_absolute_error(y_true, y_pred, multioutput='raw_values')
    array([0.5, 1. ])
    >>> median_absolute_error(y_true, y_pred, multioutput=[0.3, 0.7])
    np.float64(0.85)
    Nr   ©rO   ©rG   r.   r/   rP   )	rB   r\   ÚmedianrQ   r   r   r8   r9   r]   )r:   r;   r<   rG   r@   rS   s         rA   r   r   C  sÑ   € õB +=Ø�˜ñ+ô +Ñ'€FˆF�F˜Kð ÐÝœ	¥"¤&¨°&©Ñ"9Ô"9ÀÐBÑBÔBˆˆå,¨]¸FÑCÔCˆÝ,ÝŒF�6˜F‘?Ñ#Ô#°=ð
ñ 
ô 
ˆõ �+�sÑ#Ô#ð Ø˜,Ò&Ð&Ø Ð ØÐ-Ò-Ð-àˆKåŒ:�m¨[Ð9Ñ9Ô9Ð9rC   c                 ó´  — | j         }|dk    }|s	d| |z  z
  }	nD| dk    }
|                     |g||¬¦  «        }	||
z  }d| |         ||         z  z
  |	|<   d|	|
| z  <   t          |t          ¦  «        r1|dk    r|	S |dk    rd}n"|dk    r|}|                     |¦  «        sd}n|}t          |	|¬	¦  «        }t          |¦  «        dk    rt          |¦  «        S |S )
zCCommon part used by explained variance score and :math:`R^2` score.r   r,   )Údevicer+   ç        r.   r/   Nr0   rP   )r+   Úonesr8   r9   rm   r   r   rR   )Ú	numeratorÚdenominatorr>   r<   Úforce_finiter)   rv   r+   Únonzero_denominatorÚoutput_scoresÚnonzero_numeratorÚvalid_scoreÚavg_weightsÚresults                 rA   Ú_assemble_r2_explained_variancer‚   ˜  s6  € ð ŒO€Eà%¨Ò*Ðàð Fà˜Y¨Ñ4Ñ5ˆˆà%¨šNÐð Ÿš  °FÀ%˜ÑHÔHˆà)Ð,=Ñ=ˆà%&Ø�kÔ" [°Ô%=Ñ=ñ&
ˆ�kÑ"ð CFˆÐ'Ð+>Ð*>Ñ>Ñ?å�+�sÑ#Ô#ð "Ø˜,Ò&Ð&à Ð ØÐ-Ò-Ð-àˆKˆKØÐ/Ò/Ð/Ø%ˆKØ—6’6Ð-Ñ.Ô.ð #ð #�øà!ˆå�m¨[Ð9Ñ9Ô9€FÝˆF�|„|�qÒÐÝ�V‰}Œ}ÐØ€MrC   >   r.   r/   r0   Úboolean)r:   r;   rG   r<   r{   )rG   r<   r{   c          
      ó”  — t          | ||¦  «        \  }} }}t          | ||¦  «         t          j        | |z
  |d¬¦  «        }t          j        | |z
  |z
  dz  |d¬¦  «        }t          j        | |d¬¦  «        }t          j        | |z
  dz  |d¬¦  «        }	t	          ||	| j        d         ||t          | ¦  «        d         d¬¦  «        S )a„  Explained variance regression score function.

    Best possible score is 1.0, lower values are worse.

    In the particular case when ``y_true`` is constant, the explained variance
    score is not finite: it is either ``NaN`` (perfect predictions) or
    ``-Inf`` (imperfect predictions). To prevent such non-finite numbers to
    pollute higher-level experiments such as a grid search cross-validation,
    by default these cases are replaced with 1.0 (perfect predictions) or 0.0
    (imperfect predictions) respectively. If ``force_finite``
    is set to ``False``, this score falls back on the original :math:`R^2`
    definition.

    .. note::
       The Explained Variance score is similar to the
       :func:`R^2 score <r2_score>`, with the notable difference that it
       does not account for systematic offsets in the prediction. Most often
       the :func:`R^2 score <r2_score>` should be preferred.

    Read more in the :ref:`User Guide <explained_variance_score>`.

    Parameters
    ----------
    y_true : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Ground truth (correct) target values.

    y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Estimated target values.

    sample_weight : array-like of shape (n_samples,), default=None
        Sample weights.

    multioutput : {'raw_values', 'uniform_average', 'variance_weighted'} or             array-like of shape (n_outputs,), default='uniform_average'
        Defines aggregating of multiple output scores.
        Array-like value defines weights used to average scores.

        'raw_values' :
            Returns a full set of scores in case of multioutput input.

        'uniform_average' :
            Scores of all outputs are averaged with uniform weight.

        'variance_weighted' :
            Scores of all outputs are averaged, weighted by the variances
            of each individual output.

    force_finite : bool, default=True
        Flag indicating if ``NaN`` and ``-Inf`` scores resulting from constant
        data should be replaced with real numbers (``1.0`` if prediction is
        perfect, ``0.0`` otherwise). Default is ``True``, a convenient setting
        for hyperparameters' search procedures (e.g. grid search
        cross-validation).

        .. versionadded:: 1.1

    Returns
    -------
    score : float or ndarray of floats
        The explained variance or ndarray if 'multioutput' is 'raw_values'.

    See Also
    --------
    r2_score :
        Similar metric, but accounting for systematic offsets in
        prediction.

    Notes
    -----
    This is not a symmetric function.

    Examples
    --------
    >>> from sklearn.metrics import explained_variance_score
    >>> y_true = [3, -0.5, 2, 7]
    >>> y_pred = [2.5, 0.0, 2, 8]
    >>> explained_variance_score(y_true, y_pred)
    0.957...
    >>> y_true = [[0.5, 1], [-1, 1], [7, -6]]
    >>> y_pred = [[0, 2], [-1, 2], [8, -5]]
    >>> explained_variance_score(y_true, y_pred, multioutput='uniform_average')
    0.983...
    >>> y_true = [-2, -2, -2]
    >>> y_pred = [-2, -2, -2]
    >>> explained_variance_score(y_true, y_pred)
    1.0
    >>> explained_variance_score(y_true, y_pred, force_finite=False)
    nan
    >>> y_true = [-2, -2, -2]
    >>> y_pred = [-2, -2, -2 + 1e-8]
    >>> explained_variance_score(y_true, y_pred)
    0.0
    >>> explained_variance_score(y_true, y_pred, force_finite=False)
    -inf
    r   rZ   r   r,   N©ry   rz   r>   r<   r{   r)   rv   )rB   r   r\   r]   r‚   r5   r	   )
r:   r;   rG   r<   r{   r@   Ú
y_diff_avgry   Ú
y_true_avgrz   s
             rA   r   r   Ê  sõ   € õh +=Ø�˜ñ+ô +Ñ'€FˆF�F˜Kõ ˜F F¨MÑ:Ô:Ð:å”˜F V™O°]ÈÐKÑKÔK€JÝ”
Ø	�&‰˜:Ñ	%¨!Ñ+°]Èðñ ô €Iõ ”˜F¨MÀÐBÑBÔB€JÝ”*˜f zÑ1°aÑ7ÀÐUVÐWÑWÔW€Kå*ØØØ”,˜q”/ØØ!Ý˜Ñ Ô  Ô#àð	ñ 	ô 	ð 	rC   c          
      ó$  — t          | |||¦  «        \  }}}t          | ||||¬¦  «        \  }} }}}t          | ||¦  «         t          |¦  «        dk     r+d}t	          j        |t          ¦  «         t          d¦  «        S |�t          |¦  «        }|dd…df         }	nd}	| 	                    |	| |z
  dz  z  d¬¦  «        }
| 	                    |	| t          | d||¬	¦  «        z
  dz  z  d¬¦  «        }t          |
|| j        d
         ||||¬¦  «        S )aX  :math:`R^2` (coefficient of determination) regression score function.

    Best possible score is 1.0 and it can be negative (because the
    model can be arbitrarily worse). In the general case when the true y is
    non-constant, a constant model that always predicts the average y
    disregarding the input features would get a :math:`R^2` score of 0.0.

    In the particular case when ``y_true`` is constant, the :math:`R^2` score
    is not finite: it is either ``NaN`` (perfect predictions) or ``-Inf``
    (imperfect predictions). To prevent such non-finite numbers to pollute
    higher-level experiments such as a grid search cross-validation, by default
    these cases are replaced with 1.0 (perfect predictions) or 0.0 (imperfect
    predictions) respectively. You can set ``force_finite`` to ``False`` to
    prevent this fix from happening.

    Note: when the prediction residuals have zero mean, the :math:`R^2` score
    is identical to the
    :func:`Explained Variance score <explained_variance_score>`.

    Read more in the :ref:`User Guide <r2_score>`.

    Parameters
    ----------
    y_true : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Ground truth (correct) target values.

    y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Estimated target values.

    sample_weight : array-like of shape (n_samples,), default=None
        Sample weights.

    multioutput : {'raw_values', 'uniform_average', 'variance_weighted'},             array-like of shape (n_outputs,) or None, default='uniform_average'

        Defines aggregating of multiple output scores.
        Array-like value defines weights used to average scores.
        Default is "uniform_average".

        'raw_values' :
            Returns a full set of scores in case of multioutput input.

        'uniform_average' :
            Scores of all outputs are averaged with uniform weight.

        'variance_weighted' :
            Scores of all outputs are averaged, weighted by the variances
            of each individual output.

        .. versionchanged:: 0.19
            Default value of multioutput is 'uniform_average'.

    force_finite : bool, default=True
        Flag indicating if ``NaN`` and ``-Inf`` scores resulting from constant
        data should be replaced with real numbers (``1.0`` if prediction is
        perfect, ``0.0`` otherwise). Default is ``True``, a convenient setting
        for hyperparameters' search procedures (e.g. grid search
        cross-validation).

        .. versionadded:: 1.1

    Returns
    -------
    z : float or ndarray of floats
        The :math:`R^2` score or ndarray of scores if 'multioutput' is
        'raw_values'.

    Notes
    -----
    This is not a symmetric function.

    Unlike most other scores, :math:`R^2` score may be negative (it need not
    actually be the square of a quantity R).

    This metric is not well-defined for single samples and will return a NaN
    value if n_samples is less than two.

    References
    ----------
    .. [1] `Wikipedia entry on the Coefficient of determination
            <https://en.wikipedia.org/wiki/Coefficient_of_determination>`_

    Examples
    --------
    >>> from sklearn.metrics import r2_score
    >>> y_true = [3, -0.5, 2, 7]
    >>> y_pred = [2.5, 0.0, 2, 8]
    >>> r2_score(y_true, y_pred)
    0.948...
    >>> y_true = [[0.5, 1], [-1, 1], [7, -6]]
    >>> y_pred = [[0, 2], [-1, 2], [8, -5]]
    >>> r2_score(y_true, y_pred,
    ...          multioutput='variance_weighted')
    0.938...
    >>> y_true = [1, 2, 3]
    >>> y_pred = [1, 2, 3]
    >>> r2_score(y_true, y_pred)
    1.0
    >>> y_true = [1, 2, 3]
    >>> y_pred = [2, 2, 2]
    >>> r2_score(y_true, y_pred)
    0.0
    >>> y_true = [1, 2, 3]
    >>> y_pred = [3, 2, 1]
    >>> r2_score(y_true, y_pred)
    -3.0
    >>> y_true = [-2, -2, -2]
    >>> y_pred = [-2, -2, -2]
    >>> r2_score(y_true, y_pred)
    1.0
    >>> r2_score(y_true, y_pred, force_finite=False)
    nan
    >>> y_true = [-2, -2, -2]
    >>> y_pred = [-2, -2, -2 + 1e-8]
    >>> r2_score(y_true, y_pred)
    0.0
    >>> r2_score(y_true, y_pred, force_finite=False)
    -inf
    r(   r   z9R^2 score is not well-defined with less than two samples.ÚnanNg      ð?r   rr   )rO   rN   r)   r,   r…   )r
   rI   r   r   ÚwarningsÚwarnr   rR   r   Úsumr   r‚   r5   )r:   r;   rG   r<   r{   r)   r=   Údevice_ÚmsgÚweightry   rz   s               rA   r   r   W  s^  € õZ .Ø�˜ {ñô �N€Bˆˆ7õ
 	/Ø�F˜M¨;¸2ð	
ñ 	
ô 	
ñ 2€A€vˆv�} kõ ˜F F¨MÑ:Ô:Ð:å�FÑÔ˜aÒÐØIˆÝŒ�cÕ1Ñ2Ô2Ð2Ý�U‰|Œ|ÐàÐ Ý$ ]Ñ3Ô3ˆØ˜q˜q˜q $˜wÔ'ˆˆàˆà—’�v ¨&¡°QÑ 6Ñ6¸Q�Ñ?Ô?€IØ—&’&Ø�&�8 F°¸MÈbÐQÑQÔQÑQÐVWÑWÑWØð ñ ô €Kõ
 +ØØØ”,˜q”/ØØ!ØØðñ ô ð rC   )r:   r;   c                 óØ   — t          | |¦  «        \  }}t          | |d|¬¦  «        \  }} }}|dk    rt          d¦  «        ‚|                     |                     | |z
  ¦  «        ¦  «        S )al  
    The max_error metric calculates the maximum residual error.

    Read more in the :ref:`User Guide <max_error>`.

    Parameters
    ----------
    y_true : array-like of shape (n_samples,)
        Ground truth (correct) target values.

    y_pred : array-like of shape (n_samples,)
        Estimated target values.

    Returns
    -------
    max_error : float
        A positive floating point value (the best value is 0.0).

    Examples
    --------
    >>> from sklearn.metrics import max_error
    >>> y_true = [3, 2, 7, 1]
    >>> y_pred = [4, 2, 7, 1]
    >>> max_error(y_true, y_pred)
    np.int64(1)
    Nr(   r2   z&Multioutput not supported in max_error)r	   rB   r6   ÚmaxrQ   )r:   r;   r)   r=   r@   s        rA   r   r     st   € õD ˜& &Ñ)Ô)�E€BˆÝ 2°6¸6À4ÈBÐ OÑ OÔ OÑ€FˆF�F˜AØÐ)Ò)Ð)ÝÐAÑBÔBÐBØ�6Š6�"—&’&˜ &™Ñ)Ô)Ñ*Ô*Ð*rC   c           
      ó,  — t          | |¦  «        \  }}|}|                     d| j        ¬¦  «        }|dk     r¿d|                     |                     | dk    | |¦  «        |                     d|z
  ¦  «        ¦  «        d|z
  d|z
  z  z  | |                     ||                     d|z
  ¦  «        ¦  «        z  d|z
  z  z
  |                     ||                     d|z
  ¦  «        ¦  «        d|z
  z  z   z  }�n|dk    r	| |z
  dz  }nò|dk    rdt          | | |z  ¦  «        | z
  |z   z  }nÏ|dk    r%d|                     || z  ¦  «        | |z  z   dz
  z  }n¤d|                     | |                     d|z
  ¦  «        ¦  «        d|z
  d|z
  z  z  | |                     ||                     d|z
  ¦  «        ¦  «        z  d|z
  z  z
  |                     ||                     d|z
  ¦  «        ¦  «        d|z
  z  z   z  }t          t          ||¬¦  «        ¦  «        S )z&Mean Tweedie deviance regression loss.r   rE   r   r,   rP   )	r	   rF   r+   ÚpowÚwherer   ÚlogrR   r   )	r:   r;   rG   Úpowerr)   r=   ÚpÚzeroÚdevs	            rA   Ú_mean_tweedie_deviancerš   5  s/  € å˜& &Ñ)Ô)�E€BˆØ€AØ�:Š:�a˜vœ|ˆ:Ñ,Ô,€DØˆ1‚u€uàØ�FŠF�2—8’8˜F QšJ¨°Ñ5Ô5°r·z²zÀ!ÀaÁ%Ñ7HÔ7HÑIÔIØ�A‘˜!˜a™%Ñ ñ"à�r—v’v˜f b§j¢j°°Q±Ñ&7Ô&7Ñ8Ô8Ñ8¸AÀ¹EÑBñCð �fŠf�V˜RŸZšZ¨¨A©Ñ.Ô.Ñ/Ô/°1°q±5Ñ9ñ:ñ
ˆ‰ð 
ˆaŠˆà˜‰ 1Ñ$ˆˆØ	
ˆaŠˆà•5˜ ¨&¡Ñ1Ô1°FÑ:¸VÑCÑDˆˆØ	
ˆaŠˆà�2—6’6˜& 6™/Ñ*Ô*¨V°f©_Ñ<¸qÑ@ÑAˆˆàØ�FŠF�6˜2Ÿ:š: a¨!¡eÑ,Ô,Ñ-Ô-°!°a±%¸AÀ¹EÑ1BÑCØ�r—v’v˜f b§j¢j°°Q±Ñ&7Ô&7Ñ8Ô8Ñ8¸AÀ¹EÑBñCà�fŠf�V˜RŸZšZ¨¨A©Ñ.Ô.Ñ/Ô/°1°q±5Ñ9ñ:ñ
ˆõ
 •˜# }Ð5Ñ5Ô5Ñ6Ô6Ð6rC   ÚrightÚleft)r:   r;   rG   r–   ©rG   r–   c                óè  — t          | |¦  «        \  }}t          | ||d|¬¦  «        \  }} }}}|dk    rt          d¦  «        ‚t          | ||¦  «         |�%t	          |¦  «        }|dd…t
          j        f         }d|› d�}|dk     r,|                     |dk    ¦  «        rt          |dz   ¦  «        ‚n®|dk    rn§d	|cxk    rd
k     rHn nE|                     | dk     ¦  «        s|                     |dk    ¦  «        rt          |dz   ¦  «        ‚nR|d
k    rE|                     | dk    ¦  «        s|                     |dk    ¦  «        rt          |dz   ¦  «        ‚nt          ‚t          | |||¬¦  «        S )a[  Mean Tweedie deviance regression loss.

    Read more in the :ref:`User Guide <mean_tweedie_deviance>`.

    Parameters
    ----------
    y_true : array-like of shape (n_samples,)
        Ground truth (correct) target values.

    y_pred : array-like of shape (n_samples,)
        Estimated target values.

    sample_weight : array-like of shape (n_samples,), default=None
        Sample weights.

    power : float, default=0
        Tweedie power parameter. Either power <= 0 or power >= 1.

        The higher `p` the less weight is given to extreme
        deviations between true and predicted targets.

        - power < 0: Extreme stable distribution. Requires: y_pred > 0.
        - power = 0 : Normal distribution, output corresponds to
          mean_squared_error. y_true and y_pred can be any real numbers.
        - power = 1 : Poisson distribution. Requires: y_true >= 0 and
          y_pred > 0.
        - 1 < p < 2 : Compound Poisson distribution. Requires: y_true >= 0
          and y_pred > 0.
        - power = 2 : Gamma distribution. Requires: y_true > 0 and y_pred > 0.
        - power = 3 : Inverse Gaussian distribution. Requires: y_true > 0
          and y_pred > 0.
        - otherwise : Positive stable distribution. Requires: y_true > 0
          and y_pred > 0.

    Returns
    -------
    loss : float
        A non-negative floating point value (the best value is 0.0).

    Examples
    --------
    >>> from sklearn.metrics import mean_tweedie_deviance
    >>> y_true = [2, 0, 1, 4]
    >>> y_pred = [0.5, 0.5, 2., 2.]
    >>> mean_tweedie_deviance(y_true, y_pred, power=1)
    1.4260...
    N©r<   r)   r2   z2Multioutput not supported in mean_tweedie_deviancez'Mean Tweedie deviance error with power=z can only be used on r   zstrictly positive y_pred.r,   r   z,non-negative y and strictly positive y_pred.zstrictly positive y and y_pred.r�   )	r	   rI   r6   r   r   r\   Únewaxisrm   rš   )r:   r;   rG   r–   r)   r=   r@   Úmessages           rA   r    r    T  sÐ  € õx ˜& &Ñ)Ô)�E€BˆÝ/UØ�˜°4¸Bð0ñ 0ô 0Ñ,€FˆF�F˜M¨1ð Ð)Ò)Ð)ÝÐMÑNÔNÐNÝ˜F F¨MÑ:Ô:Ð:àÐ Ý$ ]Ñ3Ô3ˆØ% a a a­¬ mÔ4ˆàT¸ÐTÐTÐT€GØˆq‚y€yà�6Š6�&˜A’+ÑÔð 	DÝ˜WÐ'BÑBÑCÔCÐCð	Dà	�!ŠˆàØ	
ˆeˆˆŠˆ�aŠˆˆˆˆà�6Š6�&˜1’*ÑÔð 	W §¢¨°!ªÑ!4Ô!4ð 	WÝ˜WÐ'UÑUÑVÔVÐVð	Wà	�!Šˆà�6Š6�&˜A’+ÑÔð 	J "§&¢&¨°1ªÑ"5Ô"5ð 	JÝ˜WÐ'HÑHÑIÔIÐIð	Jõ Ðå!Ø� m¸5ðñ ô ð rC   ©r:   r;   rG   rs   c                ó(   — t          | ||d¬¦  «        S )ad  Mean Poisson deviance regression loss.

    Poisson deviance is equivalent to the Tweedie deviance with
    the power parameter `power=1`.

    Read more in the :ref:`User Guide <mean_tweedie_deviance>`.

    Parameters
    ----------
    y_true : array-like of shape (n_samples,)
        Ground truth (correct) target values. Requires y_true >= 0.

    y_pred : array-like of shape (n_samples,)
        Estimated target values. Requires y_pred > 0.

    sample_weight : array-like of shape (n_samples,), default=None
        Sample weights.

    Returns
    -------
    loss : float
        A non-negative floating point value (the best value is 0.0).

    Examples
    --------
    >>> from sklearn.metrics import mean_poisson_deviance
    >>> y_true = [2, 0, 1, 4]
    >>> y_pred = [0.5, 0.5, 2., 2.]
    >>> mean_poisson_deviance(y_true, y_pred)
    1.4260...
    r,   r�   ©r    r¢   s      rA   r!   r!   µ  s   € õP ! ¨¸}ÐTUÐVÑVÔVÐVrC   c                ó(   — t          | ||d¬¦  «        S )a²  Mean Gamma deviance regression loss.

    Gamma deviance is equivalent to the Tweedie deviance with
    the power parameter `power=2`. It is invariant to scaling of
    the target variable, and measures relative errors.

    Read more in the :ref:`User Guide <mean_tweedie_deviance>`.

    Parameters
    ----------
    y_true : array-like of shape (n_samples,)
        Ground truth (correct) target values. Requires y_true > 0.

    y_pred : array-like of shape (n_samples,)
        Estimated target values. Requires y_pred > 0.

    sample_weight : array-like of shape (n_samples,), default=None
        Sample weights.

    Returns
    -------
    loss : float
        A non-negative floating point value (the best value is 0.0).

    Examples
    --------
    >>> from sklearn.metrics import mean_gamma_deviance
    >>> y_true = [2, 0.5, 1, 4]
    >>> y_pred = [0.5, 0.5, 2., 2.]
    >>> mean_gamma_deviance(y_true, y_pred)
    1.0568...
    r   r�   r¤   r¢   s      rA   r"   r"   à  s   € õR ! ¨¸}ÐTUÐVÑVÔVÐVrC   c                óÞ  — t          | |¦  «        \  }}t          | ||d|¬¦  «        \  }} }}}|dk    rt          d¦  «        ‚t          |¦  «        dk     r+d}t	          j        |t          ¦  «         t          d¦  «        S |                     | d¬	¦  «        |                     |d¬	¦  «        }} t          | |||¬
¦  «        }t          | ||¬¦  «        }	t          | |	||¬
¦  «        }
d||
z  z
  S )a'
  
    :math:`D^2` regression score function, fraction of Tweedie deviance explained.

    Best possible score is 1.0 and it can be negative (because the model can be
    arbitrarily worse). A model that always uses the empirical mean of `y_true` as
    constant prediction, disregarding the input features, gets a D^2 score of 0.0.

    Read more in the :ref:`User Guide <d2_score>`.

    .. versionadded:: 1.0

    Parameters
    ----------
    y_true : array-like of shape (n_samples,)
        Ground truth (correct) target values.

    y_pred : array-like of shape (n_samples,)
        Estimated target values.

    sample_weight : array-like of shape (n_samples,), default=None
        Sample weights.

    power : float, default=0
        Tweedie power parameter. Either power <= 0 or power >= 1.

        The higher `p` the less weight is given to extreme
        deviations between true and predicted targets.

        - power < 0: Extreme stable distribution. Requires: y_pred > 0.
        - power = 0 : Normal distribution, output corresponds to r2_score.
          y_true and y_pred can be any real numbers.
        - power = 1 : Poisson distribution. Requires: y_true >= 0 and
          y_pred > 0.
        - 1 < p < 2 : Compound Poisson distribution. Requires: y_true >= 0
          and y_pred > 0.
        - power = 2 : Gamma distribution. Requires: y_true > 0 and y_pred > 0.
        - power = 3 : Inverse Gaussian distribution. Requires: y_true > 0
          and y_pred > 0.
        - otherwise : Positive stable distribution. Requires: y_true > 0
          and y_pred > 0.

    Returns
    -------
    z : float or ndarray of floats
        The D^2 score.

    Notes
    -----
    This is not a symmetric function.

    Like R^2, D^2 score may be negative (it need not actually be the square of
    a quantity D).

    This metric is not well-defined for single samples and will return a NaN
    value if n_samples is less than two.

    References
    ----------
    .. [1] Eq. (3.11) of Hastie, Trevor J., Robert Tibshirani and Martin J.
           Wainwright. "Statistical Learning with Sparsity: The Lasso and
           Generalizations." (2015). https://hastie.su.domains/StatLearnSparsity/

    Examples
    --------
    >>> from sklearn.metrics import d2_tweedie_score
    >>> y_true = [0.5, 1, 2.5, 7]
    >>> y_pred = [1, 1, 5, 3.5]
    >>> d2_tweedie_score(y_true, y_pred)
    0.285...
    >>> d2_tweedie_score(y_true, y_pred, power=1)
    0.487...
    >>> d2_tweedie_score(y_true, y_pred, power=2)
    0.630...
    >>> d2_tweedie_score(y_true, y_true, power=2)
    1.0
    NrŸ   r2   z-Multioutput not supported in d2_tweedie_scorer   ú9D^2 score is not well-defined with less than two samples.r‰   r,   rr   r�   )rN   r)   )r	   rI   r6   r   rŠ   r‹   r   rR   Úsqueezer    r   rš   )r:   r;   rG   r–   r)   r=   r@   rŽ   ry   Úy_avgrz   s              rA   r#   r#     s!  € õr ˜& &Ñ)Ô)�E€Bˆå/UØ�˜°4¸Bð0ñ 0ô 0Ñ,€FˆF�F˜M¨1ð Ð)Ò)Ð)ÝÐHÑIÔIÐIå�FÑÔ˜aÒÐØIˆÝŒ�cÕ1Ñ2Ô2Ð2Ý�U‰|Œ|Ðà—Z’Z ¨Q�ZÑ/Ô/°·²¸FÈ°Ñ1KÔ1KˆF€FÝ%Ø� m¸5ðñ ô €Iõ �V ]°rÐ:Ñ:Ô:€EÝ(Ø� ]¸%ðñ ô €Kð ˆy˜;Ñ&Ñ&Ð&rC   c                ó8  — t          | ||¦  «        \  }} }}t          | ||¦  «         t          |¦  «        dk     r+d}t          j        |t
          ¦  «         t          d¦  «        S t          | |||d¬¦  «        }|€=t          j	        t          j
        | |dz  d¬	¦  «        t          | ¦  «        d
f¦  «        }nGt          || ¦  «        }t          j	        t          | ||dz  ¬¦  «        t          | ¦  «        d
f¦  «        }t          | |||d¬¦  «        }	|dk    }
|	dk    }|
|z  }t          j        | j        d
         ¦  «        }d
||         |	|         z  z
  ||<   d||
| z  <   t!          |t"          ¦  «        r|dk    r|S d}n|}t          j        ||¬¦  «        S )uò
  
    :math:`D^2` regression score function, fraction of pinball loss explained.

    Best possible score is 1.0 and it can be negative (because the model can be
    arbitrarily worse). A model that always uses the empirical alpha-quantile of
    `y_true` as constant prediction, disregarding the input features,
    gets a :math:`D^2` score of 0.0.

    Read more in the :ref:`User Guide <d2_score>`.

    .. versionadded:: 1.1

    Parameters
    ----------
    y_true : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Ground truth (correct) target values.

    y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Estimated target values.

    sample_weight : array-like of shape (n_samples,), default=None
        Sample weights.

    alpha : float, default=0.5
        Slope of the pinball deviance. It determines the quantile level alpha
        for which the pinball deviance and also D2 are optimal.
        The default `alpha=0.5` is equivalent to `d2_absolute_error_score`.

    multioutput : {'raw_values', 'uniform_average'} or array-like of shape             (n_outputs,), default='uniform_average'
        Defines aggregating of multiple output values.
        Array-like value defines weights used to average scores.

        'raw_values' :
            Returns a full set of errors in case of multioutput input.

        'uniform_average' :
            Scores of all outputs are averaged with uniform weight.

    Returns
    -------
    score : float or ndarray of floats
        The :math:`D^2` score with a pinball deviance
        or ndarray of scores if `multioutput='raw_values'`.

    Notes
    -----
    Like :math:`R^2`, :math:`D^2` score may be negative
    (it need not actually be the square of a quantity D).

    This metric is not well-defined for a single point and will return a NaN
    value if n_samples is less than two.

     References
    ----------
    .. [1] Eq. (7) of `Koenker, Roger; Machado, JosÃ© A. F. (1999).
           "Goodness of Fit and Related Inference Processes for Quantile Regression"
           <https://doi.org/10.1080/01621459.1999.10473882>`_
    .. [2] Eq. (3.11) of Hastie, Trevor J., Robert Tibshirani and Martin J.
           Wainwright. "Statistical Learning with Sparsity: The Lasso and
           Generalizations." (2015). https://hastie.su.domains/StatLearnSparsity/

    Examples
    --------
    >>> from sklearn.metrics import d2_pinball_score
    >>> y_true = [1, 2, 3]
    >>> y_pred = [1, 3, 3]
    >>> d2_pinball_score(y_true, y_pred)
    np.float64(0.5)
    >>> d2_pinball_score(y_true, y_pred, alpha=0.9)
    np.float64(0.772...)
    >>> d2_pinball_score(y_true, y_pred, alpha=0.1)
    np.float64(-1.045...)
    >>> d2_pinball_score(y_true, y_true, alpha=0.1)
    np.float64(1.0)
    r   r§   r‰   r.   rX   Néd   r   )ÚqrO   r,   )rG   Ú
percentilerw   rP   )rB   r   r   rŠ   r‹   r   rR   r   r\   Útiler­   Úlenr   r   rx   r5   r8   r9   r]   )r:   r;   rG   rV   r<   r@   rŽ   ry   Ú
y_quantilerz   r~   r|   r   r}   r€   s                  rA   r$   r$     sõ  € õx +=Ø�˜ñ+ô +Ñ'€FˆF�F˜Kõ ˜F F¨MÑ:Ô:Ð:å�FÑÔ˜aÒÐØIˆÝŒ�cÕ1Ñ2Ô2Ð2Ý�U‰|Œ|Ðå!ØØØ#ØØ ðñ ô €Ið ÐÝ”WÝŒM˜& E¨C¡K°aÐ8Ñ8Ô8½3¸v¹;¼;ÈÐ:Jñ
ô 
ˆ
ˆ
õ -¨]¸FÑCÔCˆÝ”WÝ Ø mÀÈÁðñ ô õ �‰[Œ[˜!Ðñ	
ô 
ˆ
õ $ØØØ#ØØ ðñ ô €Kð " QšÐØ%¨Ò*ÐØ#Ð&9Ñ9€KÝ”G˜FœL¨œOÑ,Ô,€Mà!" i°Ô&<¸{È;Ô?WÑ&WÑ!X€M�+ÑØ>A€MÐ#Ð':Ð&:Ñ:Ñ;å�+�sÑ#Ô#ð "Ø˜,Ò&Ð&à Ð ð ˆKˆKà!ˆåŒ:�m¨[Ð9Ñ9Ô9Ð9rC   c                ó*   — t          | ||d|¬¦  «        S )a  
    :math:`D^2` regression score function, fraction of absolute error explained.

    Best possible score is 1.0 and it can be negative (because the model can be
    arbitrarily worse). A model that always uses the empirical median of `y_true`
    as constant prediction, disregarding the input features,
    gets a :math:`D^2` score of 0.0.

    Read more in the :ref:`User Guide <d2_score>`.

    .. versionadded:: 1.1

    Parameters
    ----------
    y_true : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Ground truth (correct) target values.

    y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Estimated target values.

    sample_weight : array-like of shape (n_samples,), default=None
        Sample weights.

    multioutput : {'raw_values', 'uniform_average'} or array-like of shape             (n_outputs,), default='uniform_average'
        Defines aggregating of multiple output values.
        Array-like value defines weights used to average scores.

        'raw_values' :
            Returns a full set of errors in case of multioutput input.

        'uniform_average' :
            Scores of all outputs are averaged with uniform weight.

    Returns
    -------
    score : float or ndarray of floats
        The :math:`D^2` score with an absolute error deviance
        or ndarray of scores if 'multioutput' is 'raw_values'.

    Notes
    -----
    Like :math:`R^2`, :math:`D^2` score may be negative
    (it need not actually be the square of a quantity D).

    This metric is not well-defined for single samples and will return a NaN
    value if n_samples is less than two.

     References
    ----------
    .. [1] Eq. (3.11) of Hastie, Trevor J., Robert Tibshirani and Martin J.
           Wainwright. "Statistical Learning with Sparsity: The Lasso and
           Generalizations." (2015). https://hastie.su.domains/StatLearnSparsity/

    Examples
    --------
    >>> from sklearn.metrics import d2_absolute_error_score
    >>> y_true = [3, -0.5, 2, 7]
    >>> y_pred = [2.5, 0.0, 2, 8]
    >>> d2_absolute_error_score(y_true, y_pred)
    np.float64(0.764...)
    >>> y_true = [[0.5, 1], [-1, 1], [7, -6]]
    >>> y_pred = [[0, 2], [-1, 2], [8, -5]]
    >>> d2_absolute_error_score(y_true, y_pred, multioutput='uniform_average')
    np.float64(0.691...)
    >>> d2_absolute_error_score(y_true, y_pred, multioutput='raw_values')
    array([0.8125    , 0.57142857])
    >>> y_true = [1, 2, 3]
    >>> y_pred = [1, 2, 3]
    >>> d2_absolute_error_score(y_true, y_pred)
    np.float64(1.0)
    >>> y_true = [1, 2, 3]
    >>> y_pred = [2, 2, 2]
    >>> d2_absolute_error_score(y_true, y_pred)
    np.float64(0.0)
    >>> y_true = [1, 2, 3]
    >>> y_pred = [3, 2, 1]
    >>> d2_absolute_error_score(y_true, y_pred)
    np.float64(-1.0)
    rW   rX   )r$   rJ   s       rA   r%   r%     s'   € õ~ Ø� m¸3ÈKðñ ô ð rC   )r&   N)N)2Ú__doc__rŠ   Únumbersr   Únumpyr\   Úscipy.specialr   Ú
exceptionsr   Úutils._array_apir   r   r	   r
   r   Úutils._param_validationr   r   r   Úutils.statsr   Úutils.validationr   r   r   r   r   Ú__ALL__rB   rI   r   r   r   r   r   r   r   r   r‚   r   r   r   rš   r    r!   r"   r#   r$   r%   © rC   rA   ú<module>r½      s(
  ððð ð €€€Ø Ð Ð Ð Ð Ð à Ð Ð Ð Ø Ð Ð Ð Ð Ð à /Ð /Ð /Ð /Ð /Ð /ðð ð ð ð ð ð ð ð ð ð ð ð ð ð LÐ KÐ KÐ KÐ KÐ KÐ KÐ KÐ KÐ KØ .Ð .Ð .Ð .Ð .Ð .ðð ð ð ð ð ð ð ð ð ð ð ð ð ðð ð €ð*T/ð T/ð T/ð T/ðp 48ð>>ð >>ð >>ð >>ðB €à�.Ø�.Ø&¨Ð-Ø"˜
 LÐ2CÐ#DÑEÔEÀ|ÐTð	ð ð #'ðñ ô ð &*Ð7HðR&ð R&ð R&ð R&ñô ðR&ðj €à�.Ø�.Ø&¨Ð-Ø�(˜4  A¨fÐ5Ñ5Ô5Ð6Ø"˜
 LÐ2CÐ#DÑEÔEÀ|ÐTðð ð #'ð	ñ 	ô 	ð &*°ÐBSðM:ð M:ð M:ð M:ñ	ô 	ðM:ð` €à�.Ø�.Ø&¨Ð-Ø"˜
 LÐ2CÐ#DÑEÔEÀ|ÐTð	ð ð #'ðñ ô ð &*Ð7Hð]1ð ]1ð ]1ð ]1ñô ð]1ð@ €à�.Ø�.Ø&¨Ð-Ø"˜
 LÐ2CÐ#DÑEÔEÀ|ÐTð	ð ð #'ðñ ô ð Ø!ðN%ð N%ð N%ð N%ñô ðN%ðb €à�.Ø�.Ø&¨Ð-Ø"˜
 LÐ2CÐ#DÑEÔEÀ|ÐTð	ð ð #'ðñ ô ð &*Ð7HðH*ð H*ð H*ð H*ñô ðH*ðV €à�.Ø�.Ø&¨Ð-Ø"˜
 LÐ2CÐ#DÑEÔEÀ|ÐTð	ð ð #'ðñ ô ð Ø!ðJð Jð Jð Jñô ðJðZ €à�.Ø�.Ø&¨Ð-Ø"˜
 LÐ2CÐ#DÑEÔEÀ|ÐTð	ð ð #'ðñ ô ð &*Ð7Hð@ð @ð @ð @ñô ð@ðF €à�.Ø�.Ø"˜
 LÐ2CÐ#DÑEÔEÀ|ÐTØ&¨Ð-ð	ð ð #'ðñ ô ð $5ÀDðI:ð I:ð I:ð I:ñô ðI:ðX/ð /ð /ðd €à�.Ø�.Ø&¨Ð-àˆJÐMÐMÐMÑNÔNØð
ð #˜ð	ð 	ð #'ðñ ô ð" Ø!Øð}ð }ð }ð }ñô ð}ð@ €à�.Ø�.Ø&¨Ð-àˆJÐMÐMÐMÑNÔNØØð
ð
 #˜ð
ð 
ð #'ðñ ô ð$ Ø!Øðdð dð dð dñô ðdðN €à�.Ø�.ðð ð #'ðñ ô ð+ð +ñô ð+ðD7ð 7ð 7ð> €à�.Ø�.Ø&¨Ð-àˆH�T˜4 ¨7Ð3Ñ3Ô3ØˆH�T˜1˜d¨6Ð2Ñ2Ô2ð
ð	ð ð #'ðñ ô ð <@Àqð Rð Rð Rð Rñô ðRðj €à�.Ø�.Ø&¨Ð-ðð ð
 #'ðñ ô ð <@ð  Wð  Wð  Wð  Wñô ð WðF €à�.Ø�.Ø&¨Ð-ðð ð
 #'ðñ ô ð :>ð !Wð !Wð !Wð !Wñô ð!WðH €à�.Ø�.Ø&¨Ð-àˆH�T˜4 ¨7Ð3Ñ3Ô3ØˆH�T˜1˜d¨6Ð2Ñ2Ô2ð
ð	ð ð #'ðñ ô ð 7;À!ð d'ð d'ð d'ð d'ñô ðd'ðN €à�.Ø�.Ø&¨Ð-Ø�(˜4  A¨fÐ5Ñ5Ô5Ð6àˆJ˜Ð&7Ð8Ñ9Ô9Øð
ð	ð 	ð #'ðñ ô ð &*°ÐBSðH:ð H:ð H:ð H:ñô ðH:ðV €à�.Ø�.Ø&¨Ð-àˆJ˜Ð&7Ð8Ñ9Ô9Øð
ð	ð ð #'ðñ ô ð &*Ð7HðUð Uð Uð Uñô ðUð Uð UrC   