ó
    §ñ:iïõ  ã                   óÜ  • S r SSKrSSKJr  SSKrSSKJr  SSKJ	r	  SSK
JrJrJrJrJr  SSKJrJrJrJr  SS	KJr  SS
KJrJrJrJrJr  / SQrS=S jr\" S/S/SS/\" SS15      S/S.SS9SSS.S j5       r\" S/S/SS/\" \SSSS9/\" SS15      S/S.SS9SSSS.S j5       r \" S/S/SS/\" SS15      S/S.SS9SSS.S j5       r!\" S/S/SS/\" SS15      S/\" \" S15      5      S/S.SS9SSSS .S! j5       r"\" S/S/SS/\" SS15      S/S.SS9SSS.S" j5       r#\" S/S/SS/\" SS15      S/\" \" S15      5      S/S.SS9SSSS .S# j5       r$\" S/S/SS/\" SS15      S/S.SS9SSS.S$ j5       r%\" S/S/\" SS15      S/SS/S%.SS9SSS&.S' j5       r&S( r'\" S/S/SS/\" 1 S)k5      S/S/S*.SS9SSSS+.S, j5       r(\" S/S/SS/\" 1 S)k5      SS/S/S*.SS9SSSS+.S- j5       r)\" S/S/S..SS9S/ 5       r*S0 r+\" S/S/SS/\" \SSS1S9\" \SSS2S9/S3.SS9SSS4.S5 j5       r,\" S/S/SS/S6.SS9SS7.S8 j5       r-\" S/S/SS/S6.SS9SS7.S9 j5       r.\" S/S/SS/\" \SSS1S9\" \SSS2S9/S3.SS9SSS4.S: j5       r/\" S/S/SS/\" \SSSS9/\" SS15      S/S.SS9SSSS.S; j5       r0\" S/S/SS/\" SS15      S/S.SS9SSS.S< j5       r1g)>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)ÚHiddenÚ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_scorec                 óÂ  • [        XX$S9u  pE[        X5        [        U SUS9n [        USUS9nU R                  S:X  a  UR	                  U S5      n UR                  S:X  a  UR	                  US5      nU R
                  S   UR
                  S   :w  a5  [        SR                  U R
                  S   UR
                  S   5      5      eU R
                  S   nSn[        U[        5      (       a   X';  a  [        SR                  Xr5      5      eOFUbC  [        USS	9nUS:X  a  [        S
5      eU[        U5      :w  a  [        S[        U5      U4-  5      eUS:X  a  SOSnX€X4$ )aæ  Check that y_true and y_pred belong to the same regression task.

Parameters
----------
y_true : array-like

y_pred : array-like

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.

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})r*   z5Custom weights are useful only in multi-output cases.z?There must be equally many custom weights (%d) as outputs (%d).Ú
continuousúcontinuous-multioutput)r	   r   r   ÚndimÚreshapeÚshapeÚ
ValueErrorÚformatÚ
isinstanceÚstrÚlen)	Úy_trueÚy_predÚmultioutputr+   r)   Ú_Ú	n_outputsÚallowed_multioutput_strÚy_types	            Ú^/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/sklearn/metrics/_regression.pyÚ_check_reg_targetsrC   K   st  € ôD ˜&¨+Ñ=�E€Bä˜FÔ+Ü˜¨5¸Ñ>€FÜ˜¨5¸Ñ>€Fà‡{�{�aÓØ—‘˜F GÓ,ˆà‡{�{�aÓØ—‘˜F GÓ,ˆà‡|�|�A�˜&Ÿ,™, q™/Ó)ÜØJ×QÑQØ—‘˜Q‘ §¡¨a¡óó
ð 	
ð —‘˜Q‘€IØTÐÜ�+œs×#Ñ#ØÓ5Üð0ß06±Ø+ó1óð ð 6ð 
Ñ	 Ü! +¸Ñ?ˆØ˜‹>ÜÐTÓUÐUØœ#˜kÓ*Ó*ÜØQÜ�{Ó# YÐ/ñ0óð ð '¨!›^‰\Ð1I€Fà˜6Ð.Ð.ó    z
array-liker.   r/   ©r;   r<   Úsample_weightr=   T)Úprefer_skip_nested_validation©rF   r=   c                ó  • [        XU5      u  p@p[        XU5        [        R                  " [        R                  " X-
  5      USS9n[        U[        5      (       a  US:X  a  U$ US:X  a  Sn[        R                  " XSS9$ )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 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.

    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)
np.float64(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)
np.float64(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])
np.float64(0.85...)
r   ©ÚweightsÚaxisr.   r/   N©rK   )rC   r   ÚnpÚaverageÚabsr8   r9   )r;   r<   rF   r=   rA   Úoutput_errorss         rB   r   r   ˜   s{   € ô@ +=Ø˜ó+Ñ'€F�Fô ˜F¨MÔ:Ü—J’JœrŸvšv f¡oÓ6ÀÐTUÑV€MÜ�+œs×#Ñ#Ø˜,Ó&Ø Ð ØÐ-Ó-àˆKä�:Š:�mÑ9Ð9rD   r,   Úboth)Úclosed)r;   r<   rF   Úalphar=   ç      à?©rF   rT   r=   c                ón  • [        XU5      u  pPp[        XU5        X-
  nUS:¬  R                  UR                  5      nX7-  U-  SU-
  SU-
  -  U-  -
  n[        R
                  " X‚SS9n	[        U[        5      (       a  US:X  a  U	$ [        U[        5      (       a  US:X  a  Sn[        R
                  " X”S9$ )an  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,   rJ   r.   r/   NrM   )rC   r   Úastyper+   rN   rO   r8   r9   )
r;   r<   rF   rT   r=   rA   ÚdiffÚsignÚlossrQ   s
             rB   r   r   ç   sº   € ôN +=Ø˜ó+Ñ'€F�Fô ˜F¨MÔ:Ø‰?€DØ�A‰I×Ñ˜dŸj™jÓ)€DØ‰<˜$Ñ ! e¡)°°D±Ñ!9¸DÑ!@Ñ@€DÜ—J’J˜tÀÑC€Mä�+œs×#Ñ#¨°|Ó(CØÐä�+œs×#Ñ#¨Ð7HÓ(Hàˆä�:Š:�mÑ9Ð9rD   c                ó¸  • [        XU5      u  p@p[        XU5        [        R                  " [        R                  5      R
                  n[        R                  " X-
  5      [        R                  " [        R                  " U 5      U5      -  n[        R                  " XbSS9n[        U[        5      (       a  US:X  a  U$ US:X  a  Sn[        R                  " XsS9$ )aÀ	  Mean absolute percentage error (MAPE) regression loss.

Note here that the output is not a percentage in the range [0, 100]
and a value of 100 does not mean 100% but 1e2. Furthermore, the output
can be arbitrarily high when `y_true` is small (which is specific to the
metric) or when `abs(y_true - y_pred)` is large (which is common for most
regression metrics). 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)
np.float64(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)
np.float64(0.5515...)
>>> mean_absolute_percentage_error(y_true, y_pred, multioutput=[0.3, 0.7])
np.float64(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)
np.float64(112589990684262.48)
r   rJ   r.   r/   NrM   )rC   r   rN   ÚfinfoÚfloat64ÚepsrP   ÚmaximumrO   r8   r9   )r;   r<   rF   r=   rA   ÚepsilonÚmaperQ   s           rB   r   r   A  s­   € ô\ +=Ø˜ó+Ñ'€F�Fô ˜F¨MÔ:Ü�hŠh”r—z‘zÓ"×&Ñ&€GÜ�6Š6�&‘/Ó"¤R§Z¢Z´·²°v³ÀÓ%HÑH€DÜ—J’J˜tÀÑC€MÜ�+œs×#Ñ#Ø˜,Ó&Ø Ð ØÐ-Ó-àˆKä�:Š:�mÑ9Ð9rD   Ú
deprecatedÚboolean)r;   r<   rF   r=   Úsquared)rF   r=   re   c                óD  • US:w  a,  [         R                  " S[        5        U(       d
  [        XX#S9$ [	        XU5      u  pPp[        XU5        [        R                  " X-
  S-  SUS9n[        U[        5      (       a  US:X  a  U$ US:X  a  S	n[        R                  " XcS
9$ )a  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.

squared : bool, default=True
    If True returns MSE value, if False returns RMSE value.

    .. deprecated:: 1.4
       `squared` is deprecated in 1.4 and will be removed in 1.6.
       Use :func:`~sklearn.metrics.root_mean_squared_error`
       instead to calculate the root mean squared error.

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_error
>>> y_true = [3, -0.5, 2, 7]
>>> y_pred = [2.5, 0.0, 2, 8]
>>> mean_squared_error(y_true, y_pred)
np.float64(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)
np.float64(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])
np.float64(0.825...)
rc   z—'squared' is deprecated in version 1.4 and will be removed in 1.6. To calculate the root mean squared error, use the function'root_mean_squared_error'.rH   r   r   )rL   rK   r.   r/   NrM   )
ÚwarningsÚwarnÚFutureWarningr   rC   r   rN   rO   r8   r9   )r;   r<   rF   r=   re   rA   rQ   s          rB   r   r      s­   € ðV �,ÓÜ�Šð-ô
 ô	
ö Ü*Ø¨mñð ô +=Ø˜ó+Ñ'€F�Fô ˜F¨MÔ:Ü—J’J ¡°AÑ5¸AÀ}ÑU€Mä�+œs×#Ñ#Ø˜,Ó&Ø Ð ØÐ-Ó-àˆKä�:Š:�mÑ9Ð9rD   c          	      ó²   • [         R                  " [        XUSS95      n[        U[        5      (       a  US:X  a  U$ US:X  a  Sn[         R
                  " XCS9$ )ae  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)
np.float64(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)
np.float64(0.822...)
r.   rH   r/   NrM   )rN   Úsqrtr   r8   r9   rO   )r;   r<   rF   r=   rQ   s        rB   r   r   
  s\   € ôt —G’GÜØ¨-À\ñ	
ó€Mô �+œs×#Ñ#Ø˜,Ó&Ø Ð ØÐ-Ó-àˆKä�:Š:�mÑ9Ð9rD   c                óz  • US:w  a,  [         R                  " S[        5        U(       d
  [        XX#S9$ [	        XU5      u  pPp[        XU5        U S:  R                  5       (       d  US:  R                  5       (       a  [        S5      e[        [        R                  " U 5      [        R                  " U5      UUS9$ )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.

squared : bool, default=True
    If True returns MSLE (mean squared log error) value.
    If False returns RMSLE (root mean squared log error) value.

    .. deprecated:: 1.4
       `squared` is deprecated in 1.4 and will be removed in 1.6.
       Use :func:`~sklearn.metrics.root_mean_squared_log_error`
       instead to calculate the root mean squared logarithmic error.

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)
np.float64(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)
np.float64(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])
np.float64(0.060...)
rc   z§'squared' is deprecated in version 1.4 and will be removed in 1.6. To calculate the root mean squared logarithmic error, use the function'root_mean_squared_log_error'.rH   r   zSMean Squared Logarithmic Error cannot be used when targets contain negative values.)rg   rh   ri   r   rC   r   Úanyr6   r   rN   Úlog1p)r;   r<   rF   r=   re   rA   s         rB   r   r   T  sÀ   € ð\ �,ÓÜ�Šð1ô
 ô	
ö Ü.Ø¨mñð ô +=Ø˜ó+Ñ'€F�Fô ˜F¨MÔ:à�‰
×Ñ×Ñ˜f q™j×-Ñ-×/Ñ/Üð/ó
ð 	
ô
 Ü
�Š�ÓÜ
�Š�ÓØ#Øñ	ð rD   c                ó  • [        XU5      u  p@p[        XU5        U S:  R                  5       (       d  US:  R                  5       (       a  [        S5      e[	        [
        R                  " U 5      [
        R                  " U5      UUS9$ )aÿ  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)
np.float64(0.199...)
r   zXRoot Mean Squared Logarithmic Error cannot be used when targets contain negative values.rH   )rC   r   rm   r6   r   rN   rn   )r;   r<   rF   r=   r>   s        rB   r   r   Ä  s„   € ôp &8¸ÈÓ%TÑ"€AˆvÜ˜F¨MÔ:à�‰
×Ñ×Ñ˜f q™j×-Ñ-×/Ñ/Üð/ó
ð 	
ô
 #Ü
�Š�ÓÜ
�Š�ÓØ#Øñ	ð rD   )r;   r<   r=   rF   )r=   rF   c                óF  • [        XU5      u  p@pUc,  [        R                  " [        R                  " X-
  5      SS9nO+[	        X15      n[        [        R                  " X-
  5      US9n[        U[        5      (       a  US:X  a  U$ US:X  a  Sn[        R                  " XRS9$ )a½  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   ©rL   ©rF   r.   r/   rM   )	rC   rN   ÚmedianrP   r   r   r8   r9   rO   )r;   r<   r=   rF   rA   rQ   s         rB   r   r     sš   € ôB +=Ø˜ó+Ñ'€F�Fð ÑÜŸ	š	¤"§&¢&¨©Ó"9ÀÑB‰ä,¨]ÓCˆÜ,Ü�FŠF�6‘?Ó#°=ñ
ˆô �+œs×#Ñ#Ø˜,Ó&Ø Ð ØÐ-Ó-àˆKä�:Š:�mÑ9Ð9rD   c                 ó€  • U R                   nUS:g  nU(       d  SX-  -
  n	O0U S:g  n
UR                  U/XgS9n	XŠ-  nSX   X   -  -
  X›'   SXšU) -  '   [        U[        5      (       a2  US:X  a  U	$ US:X  a  SnO#US:X  a  UnUR	                  U5      (       d  SnOUn[        U	WS	9n[        U5      S:X  a  [        U5      $ U$ )
zCCommon part used by explained variance score and :math:`R^2` score.r   r,   )Údevicer+   ç        r.   r/   Nr0   rM   )r+   Úonesr8   r9   rm   r   r   Úfloat)Ú	numeratorÚdenominatorr?   r=   Úforce_finiter)   ru   r+   Únonzero_denominatorÚoutput_scoresÚnonzero_numeratorÚvalid_scoreÚavg_weightsÚresults                 rB   Ú_assemble_r2_explained_variancer‚   b  sû   € ð �O‰O€Eà%¨Ñ*Ðæà˜YÑ4Ñ5‰à%¨™NÐð Ÿ™  °F˜ÐHˆà)Ñ=ˆà%&ØÑ" [Ñ%=Ñ=ñ&
ˆÑ"ð CFˆÐ+>Ð*>Ñ>Ñ?ä�+œs×#Ñ#Ø˜,Ó&à Ð ØÐ-Ó-à‰KØÐ/Ó/Ø%ˆKØ—6‘6Ð-×.Ñ.ð #�øà!ˆä�m¨[Ñ9€FÜˆFƒ|�qÓÜ�V‹}ÐØ€MrD   >   r.   r/   r0   )r;   r<   rF   r=   r{   )rF   r=   r{   c          
      óT  • [        XU5      u  pPp[        XU5        [        R                  " X-
  USS9n[        R                  " X-
  U-
  S-  USS9n[        R                  " XSS9n[        R                  " X-
  S-  USS9n	[	        UU	U R
                  S   UU[        U 5      S   SS9$ )aT  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   rJ   r   r,   N©ry   rz   r?   r=   r{   r)   ru   )rC   r   rN   rO   r‚   r5   r	   )
r;   r<   rF   r=   r{   rA   Ú
y_diff_avgry   Ú
y_true_avgrz   s
             rB   r    r    ”  s»   € ôh +=Ø˜ó+Ñ'€F�Fô ˜F¨MÔ:ä—’˜F™O°]ÈÑK€JÜ—
’
Ø	‰˜:Ñ	%¨!Ñ+°]Èñ€Iô —’˜FÀÑB€JÜ—*’*˜fÑ1°aÑ7ÀÐUVÑW€Kä*ØØØ—,‘,˜q‘/ØØ!Ü˜Ó  Ñ#àñ	ð 	rD   c                ó°  • [        XX#5      u  pVn[        XX%S9n[        XX8US9u  p`p[        XU5        [	        U5      S:  a(  Sn	[
        R                  " U	[        5        [        S5      $ Ub  [        X(S9nUSS2S4   n
OSn
UR                  X U-
  S-  -  S	S
9nUR                  X [        U S	X%S9-
  S-  -  S	S
9n[        UUU R                  S   UUUUS9$ )aØ  :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+   r)   r   z9R^2 score is not well-defined with less than two samples.ÚnanN©r+   g      ð?r   rq   )rL   rK   r)   r,   r„   )r
   r   rC   r   r   rg   rh   r   rx   r   Úsumr   r‚   r5   )r;   r<   rF   r=   r{   r)   r>   Údevice_r+   ÚmsgÚweightry   rz   s                rB   r   r   !  s  € ôZ .Ø˜ó�N€Bˆ7ô *¨&¸-ÑO€Eä%7Ø˜°Rñ&Ñ"€Aˆvô ˜F¨MÔ:ä�FÓ˜aÓØIˆÜ�Š�cÔ1Ô2Ü�U‹|ÐàÑ Ü$ ]Ñ@ˆØšq $˜wÑ'‰àˆà—‘�v¨&¡°QÑ 6Ñ6¸Q�Ð?€IØ—&‘&Øœ8 F°¸MÑQÑQÐVWÑWÑWØð ð €Kô
 +ØØØ—,‘,˜q‘/ØØ!ØØñð rD   )r;   r<   c                 óš   • [        XS5      u  p pUS:X  a  [        S5      e[        R                  " [        R                  " X-
  5      5      $ )a  
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)
Nr2   z&Multioutput not supported in max_error)rC   r6   rN   ÚmaxrP   )r;   r<   rA   r>   s       rB   r   r   Õ  sE   € ôD !3°6À4Ó HÑ€F�FØÐ)Ó)ÜÐAÓBÐBÜ�6Š6”"—&’&˜™Ó)Ó*Ð*rD   c                 óÊ  • UnUS:  a„  S[         R                  " [         R                  " U S5      SU-
  5      SU-
  SU-
  -  -  U [         R                  " USU-
  5      -  SU-
  -  -
  [         R                  " USU-
  5      SU-
  -  -   -  nOÄUS:X  a  X-
  S-  nO¶US:X  a  S[        X U-  5      U -
  U-   -  nO˜US:X  a$  S[         R                  " X-  5      X-  -   S-
  -  nOnS[         R                  " U SU-
  5      SU-
  SU-
  -  -  U [         R                  " USU-
  5      -  SU-
  -  -
  [         R                  " USU-
  5      SU-
  -  -   -  n[         R
                  " XRS9$ )z&Mean Tweedie deviance regression loss.r   r   r,   rM   )rN   Úpowerr`   r   ÚlogrO   )r;   r<   rF   r‘   ÚpÚdevs         rB   Ú_mean_tweedie_deviancer•   ý  sq  € à€AØˆ1ƒuàÜ�HŠH”R—Z’Z ¨Ó*¨A°©EÓ2°q¸1±uÀÀQÁÑ6GÑHØ”r—x’x ¨¨A©Ó.Ñ.°!°a±%Ñ8ñ9ä�hŠh�v˜q 1™uÓ%¨¨Q©Ñ/ñ0ñ
‰ð
 
ˆa‹à‰ 1Ñ$‰Ø	
ˆa‹à”5˜¨&¡Ó1°FÑ:¸VÑCÑD‰Ø	
ˆa‹à”2—6’6˜&™/Ó*¨V©_Ñ<¸qÑ@ÑA‰àÜ�HŠH�V˜Q ™UÓ#¨¨A©°!°a±%Ñ'8Ñ9Ø”r—x’x ¨¨A©Ó.Ñ.°!°a±%Ñ8ñ9ä�hŠh�v˜q 1™uÓ%¨¨Q©Ñ/ñ0ñ
ˆô �:Š:�cÑ1Ð1rD   ÚrightÚleft)r;   r<   rF   r‘   ©rF   r‘   c                óš  • [        XS[        R                  [        R                  /S9u  p@pUS:X  a  [	        S5      e[        XU5        Ub"  [        U5      nUSS2[        R                  4   nSU S3nUS:  a'  US:*  R                  5       (       a  [	        US-   5      eO¡US:X  a  OšS	Us=::  a  S
:  aB  O  O?U S:  R                  5       (       d  US:*  R                  5       (       a  [	        US-   5      eOKUS
:¼  a?  U S:*  R                  5       (       d  US:*  R                  5       (       a  [	        US-   5      eO[        e[        XX#S9$ )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)
np.float64(1.4260...)
Nr‰   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˜   )
rC   rN   r^   Úfloat32r6   r   r   Únewaxisrm   r•   )r;   r<   rF   r‘   rA   r>   Úmessages          rB   r!   r!     sV  € ôx !3Ø˜¤R§Z¡Z´·±Ð$<ñ!Ñ€F�Fð Ð)Ó)ÜÐMÓNÐNÜ˜F¨MÔ:àÑ Ü$ ]Ó3ˆØ%¢a¬¯© mÑ4ˆà7¸°wÐ>SÐT€GØˆqƒyà�a‰K×Ñ×ÑÜ˜WÐ'BÑBÓCÐCð à	�!‹àØ	
ˆe��aŽà�Q‰J×Ñ×Ñ &¨A¡+×!2Ñ!2×!4Ñ!4Ü˜WÐ'UÑUÓVÐVð "5à	�!‹à�a‰K×Ñ×Ñ 6¨Q¡;×"3Ñ"3×"5Ñ"5Ü˜WÐ'HÑHÓIÐIð #6ô Ðä!Ø mñð rD   ©r;   r<   rF   rr   c                ó   • [        XUSS9$ )a  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)
np.float64(1.4260...)
r,   r˜   ©r!   r�   s      rB   r"   r"   z  s   € ôP ! ¸}ÐTUÑVÐVrD   c                ó   • [        XUSS9$ )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)
np.float64(1.0568...)
r   r˜   rŸ   r�   s      rB   r#   r#   ¥  s   € ôR ! ¸}ÐTUÑVÐVrD   c                óž  • [        XS[        R                  [        R                  /S9u  p@pUS:X  a  [	        S5      e[        U5      S:  a(  Sn[        R                  " U[        5        [        S5      $ [        R                  " U 5      [        R                  " U5      p[        XX#S9n[        R                  " XS	9n[        XX#S9n	S
Xy-  -
  $ )ag	  
: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)
np.float64(0.285...)
>>> d2_tweedie_score(y_true, y_pred, power=1)
np.float64(0.487...)
>>> d2_tweedie_score(y_true, y_pred, power=2)
np.float64(0.630...)
>>> d2_tweedie_score(y_true, y_true, power=2)
np.float64(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˜   rM   r,   )rC   rN   r^   rš   r6   r   rg   rh   r   rx   Úsqueezer!   rO   r•   )
r;   r<   rF   r‘   rA   r>   rŒ   ry   Úy_avgrz   s
             rB   r$   r$   Ñ  sÁ   € ôr !3Ø˜¤R§Z¡Z´·±Ð$<ñ!Ñ€F�Fð Ð)Ó)ÜÐHÓIÐIä�FÓ˜aÓØIˆÜ�Š�cÔ1Ô2Ü�U‹|Ðä—Z’Z Ó'¬¯ª°FÓ);ˆFÜ%Ø mñ€Iô �JŠJ�vÑ5€EÜ(Ø ]ñ€Kð ˆyÑ&Ñ&Ð&rD   c                ó¼  • [        XU5      u  pPp[        XU5        [        U5      S:  a(  Sn[        R                  " U[
        5        [        S5      $ [        U UUUSS9nUc9  [        R                  " [        R                  " XS-  SS	9[        U 5      S
45      nO8[        X 5      n[        R                  " [        XUS-  S9[        U 5      S
45      n[        U UUUSS9n	US:g  n
U	S:g  nX«-  n[        R                  " U R                  S
   5      nS
X|   Xœ   -  -
  XÜ'   SXÚU) -  '   [!        U["        5      (       a  US:X  a  U$ SnOUn[        R$                  " XÞS9$ )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.   rV   Néd   r   )ÚqrL   r,   )rF   Ú
percentilerv   rM   )rC   r   r   rg   rh   r   rx   r   rN   Útiler¨   r:   r   r   rw   r5   r8   r9   rO   )r;   r<   rF   rT   r=   rA   rŒ   ry   Ú
y_quantilerz   r~   r|   r   r}   r€   s                  rB   r%   r%   B  s„  € ôx +=Ø˜ó+Ñ'€F�Fô ˜F¨MÔ:ä�FÓ˜aÓØIˆÜ�Š�cÔ1Ô2Ü�U‹|Ðä!ØØØ#ØØ ñ€Ið ÑÜ—W’WÜ�MŠM˜&¨C¡K°aÑ8¼3¸v»;ÈÐ:Jó
‰
ô -¨]ÓCˆÜ—W’WÜ ØÀÈÁñô �‹[˜!Ðó	
ˆ
ô $ØØØ#ØØ ñ€Kð " Q™ÐØ%¨Ñ*ÐØ#Ñ9€KÜ—G’G˜FŸL™L¨™OÓ,€Mà!" iÑ&<¸{Ñ?WÑ&WÑ!X€MÑØ>A€MÐ':Ð&:Ñ:Ñ;ä�+œs×#Ñ#Ø˜,Ó&à Ð ð ‰Kà!ˆä�:Š:�mÑ9Ð9rD   c                ó   • [        XUSUS9$ )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)
rU   rV   )r%   rE   s       rB   r&   r&   Ú  s   € ô~ Ø m¸3ÈKñð rD   )ÚnumericN)2Ú__doc__rg   Únumbersr   ÚnumpyrN   Úscipy.specialr   Ú
exceptionsr   Úutils._array_apir   r   r	   r
   r   Úutils._param_validationr   r   r   r   Úutils.statsr   Úutils.validationr   r   r   r   r   Ú__ALL__rC   r   r   r   r   r   r   r   r   r‚   r    r   r   r•   r!   r"   r#   r$   r%   r&   © rD   rB   Ú<module>r¸      s	  ðñó: Ý ã Ý å /÷õ ÷ TÓ SÝ .÷õ ò€ô*J/ñZ à�.Ø�.Ø&¨Ð-Ù" LÐ2CÐ#DÓEÀ|ÐTñ	ð #'ñð &*Ð7HôC:óðC:ñL à�.Ø�.Ø&¨Ð-Ù˜4  A¨fÑ5Ð6Ù" LÐ2CÐ#DÓEÀ|ÐTñð #'ñ	ð &*°ÐBSôM:ó	ðM:ñ` à�.Ø�.Ø&¨Ð-Ù" LÐ2CÐ#DÓEÀ|ÐTñ	ð #'ñð &*Ð7HôS:óðS:ñl à�.Ø�.Ø&¨Ð-Ù" LÐ2CÐ#DÓEÀ|ÐTÙ™: | nÓ5Ó6¸	ÐBñð #'ñ	ð Ø!Øô]:ó	ð]:ñ@ à�.Ø�.Ø&¨Ð-Ù" LÐ2CÐ#DÓEÀ|ÐTñ	ð #'ñð &*Ð7Hô>:óð>:ñB à�.Ø�.Ø&¨Ð-Ù" LÐ2CÐ#DÓEÀ|ÐTÙ™: | nÓ5Ó6¸	ÐBñð #'ñ	ð Ø!Øôcó	ðcñL à�.Ø�.Ø&¨Ð-Ù" LÐ2CÐ#DÓEÀ|ÐTñ	ð #'ñð &*Ð7Hô=óð=ñ@ à�.Ø�.Ù" LÐ2CÐ#DÓEÀ|ÐTØ&¨Ð-ñ	ð #'ñð $5ÀDôI:óðI:òX/ñd à�.Ø�.Ø&¨Ð-áÒMÓNØð
ð #˜ñ	ð #'ñð" Ø!Øô}óð}ñ@ à�.Ø�.Ø&¨Ð-áÒMÓNØØð
ð
 #˜ñ
ð #'ñð$ Ø!ØôcóðcñL à�.Ø�.ñð #'ññ+óð+òB2ñ: à�.Ø�.Ø&¨Ð-á�T˜4 ¨7Ñ3Ù�T˜1˜d¨6Ñ2ð
ñ	ð #'ñð <@Àqô QóðQñh à�.Ø�.Ø&¨Ð-ñð
 #'ñð <@ô  Wóð WñF à�.Ø�.Ø&¨Ð-ñð
 #'ñð :>ô !Wóð!WñH à�.Ø�.Ø&¨Ð-á�T˜4 ¨7Ñ3Ù�T˜1˜d¨6Ñ2ð
ñ	ð #'ñð 7;À!ô b'óðb'ñJ à�.Ø�.Ø&¨Ð-Ù˜4  A¨fÑ5Ð6á˜Ð&7Ð8Ó9Øð
ñ	ð #'ñð &*°ÐBSôH:óðH:ñV à�.Ø�.Ø&¨Ð-á˜Ð&7Ð8Ó9Øð
ñ	ð #'ñð &*Ð7HôUóñUrD   