
    -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	J
r
JrJrJr  SSKJr  SSK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 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.SS9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.SS9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*S. r+\" S/S/SS/\" \SSS/S9\" \SSS0S9/S1.SS9SSS2.S3 j5       r,\" S/S/SS/S4.SS9SS5.S6 j5       r-\" S/S/SS/S4.SS9SS5.S7 j5       r.\" S/S/SS/\" \SSS/S9\" \SSS0S9/S1.SS9SSS2.S8 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.S9 j5       r0\" S/S/SS/\" SS15      S/S.SS9SSS.S: j5       r1g)=zMetrics 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   )UndefinedMetricWarning)_average_find_matching_floating_dtypeget_namespaceget_namespace_and_devicesize)_xlogy)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X5S9u  pV[        XU5        [        U SUS9n [        USUS9nUb
  [        X 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   X8;  a  [        S	R                  X5      5      eOOUbL  [        USS
9nUS:X  a  [        S5      eXsR                  S   :w  a  [        SUR                  S    SU S35      eUS:X  a  SOSn	XXU4$ )a  Check that y_true, y_pred and sample_weight 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.

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

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.

sample_weight : array-like of shape (n_samples,) or 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.
xpF)	ensure_2ddtype)r*      )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.r   z+There must be equally many custom weights (z) as outputs (z).
continuouscontinuous-multioutput)r   r   r   r   ndimreshapeshape
ValueErrorformat
isinstancestr)
y_truey_predsample_weightmultioutputr*   r(   _	n_outputsallowed_multioutput_stry_types
             N/var/www/html/venv/lib/python3.13/site-packages/sklearn/metrics/_regression.py_check_reg_targetsrB   <   s   h &+=EBFM:5>F5>F ,]%P{{aFG,{{aFG,||A&,,q/)JQQQa
 	
 QIT+s##5006+1  6 
	 !+?>TUU++A..%%a()	{"F  '!^\1IF6+==    c           	      >    [        XX$S9n[        XX#XTS9u  p`pnX`XU4$ )a~  Ensures y_true, y_pred, and sample_weight correspond to 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(   )r   rB   )r9   r:   r;   r<   r(   
dtype_namer@   s          rA   &_check_reg_targets_with_floating_dtyperF      s8    d /v}TJ9K*:6FF; 6+==rC   z
array-liker-   r.   r9   r:   r;   r<   T)prefer_skip_nested_validationr;   r<   c                    [        XX#5      u  pE[        XX#US9u  pPpn[        UR                  X-
  5      USUS9n[	        U[
        5      (       a  US:X  a  U$ US:X  a  Sn[        XcS9n[        U5      $ )a  Mean absolute error regression loss.

The mean absolute error is a non-negative floating point value, where best value
is 0.0. 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rK   )r   rF   r   absr7   r8   float)r9   r:   r;   r<   r(   r=   output_errorsr   s           rA   r   r      s    B &-EEB 	/M2	
 2Avk 
vQ2M +s##,&  --K #=F$%%rC   r+   both)closed)r9   r:   r;   alphar<         ?r;   rS   r<   c                Z   [        XX$5      u  pV[        XX$US9u  p`pnX-
  nUR                  US:  UR                  5      nX8-  U-  SU-
  SU-
  -  U-  -
  n	[	        XSS9n
[        U[        5      (       a  US:X  a  U
$ [        U[        5      (       a  US:X  a  Sn[        [	        XS95      $ )	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)
0.03...
>>> mean_pinball_loss(y_true, [1, 2, 4], alpha=0.1)
0.3...
>>> mean_pinball_loss(y_true, [0, 2, 3], alpha=0.9)
0.3...
>>> mean_pinball_loss(y_true, [1, 2, 4], alpha=0.9)
0.03...
>>> mean_pinball_loss(y_true, y_true, alpha=0.1)
0.0
>>> mean_pinball_loss(y_true, y_true, alpha=0.9)
0.0
r'   r   r+   rK   rL   r-   r.   NrM   )r   rF   astyper*   r   r7   r8   rO   )r9   r:   r;   rS   r<   r(   r=   diffsignlossrP   s              rA   r   r   5  s    N &-EEB 	/M2	
 2Avk ?D99TQY

+D<$!e)D!9D!@@DTqAM+s##|(C+s##7H(H -=>>rC   c                   [        XX#5      u  pEn[        XX#US9u  pPpnUR                  UR                  UR                  5      R
                  U R                  US9nUR                  U 5      nUR                  X-
  5      UR                  X5      -  n	[        XSS9n
[        U[        5      (       a  US:X  a  U
$ US:X  a  Sn[        XS9n[        U5      $ )	aH	  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'   )r*   devicer   rW   r-   r.   NrM   )r	   rF   asarrayfinfofloat64epsr*   rN   maximumr   r7   r8   rO   )r9   r:   r;   r<   r(   r=   device_epsilon
y_true_absmaperP   r   s               rA   r   r     s    Z .NB7 	/M2	
 2Avk
 jj"**-11gjVGJ66&/"RZZ
%DDDTqAM+s##,&  --K &.m%Q"/00rC   c                    [        XX#5      u  pE[        XX#US9u  pPpn[        X-
  S-  SUS9n[        U[        5      (       a  US:X  a  U$ US:X  a  Sn[        XcS9n[        U5      $ )	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.

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   )rL   rK   r-   r.   NrM   )r   rF   r   r7   r8   rO   )r9   r:   r;   r<   r(   r=   rP   r   s           rA   r   r     s    @ &-EEB.M2	
 2Avk
 fo!3!]SM+s##,&  --K "-E#$$rC   c          	          [        XX#5      u  pEUR                  [        XUSS95      n[        U[        5      (       a  US:X  a  U$ US:X  a  Sn[        XcS9n[        U5      $ )aM  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-   rI   r.   NrM   )r   sqrtr   r7   r8   r   rO   )r9   r:   r;   r<   r(   r=   rP   r   s           rA   r   r   [  st    v &-EEBGG-\	
M +s##,&  --K '}J())rC   c                   [        X5      u  pE[        XX#US9u  pPpnUR                  U S:*  5      (       d  UR                  US:*  5      (       a  [        S5      e[	        UR                  U 5      U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.

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.rI   )r   rF   anyr5   r   log1pr9   r:   r;   r<   r(   r=   s         rA   r   r     s    D &)EB 	/M2	
 2Avk 
vvflrvvfl33?
 	

 

#	 rC   c                   [        X5      u  pE[        XX#US9u  pPpnUR                  U S:*  5      (       d  UR                  US:*  5      (       a  [        S5      e[	        UR                  U 5      U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)
0.199...
r'   r,   zhRoot Mean Squared Logarithmic Error cannot be used when targets contain values less than or equal to -1.rI   )r   rF   rk   r5   r   rl   rm   s         rA   r   r     s    p &)EB 	/M2	
 2Avk 
vvflrvvfl33?
 	

 #

#	 rC   )r9   r:   r<   r;   )r<   r;   c                D   [        XX25      u  p@pnUc,  [        R                  " [        R                  " X-
  5      SS9nO [	        [        R                  " X-
  5      US9n[        U[        5      (       a  US:X  a  U$ US:X  a  Sn[        [        R                  " XRS95      $ )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)
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)
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])
0.85
Nr   rL   r;   r-   r.   rM   )	rB   npmedianrN   r   r7   r8   rO   average)r9   r:   r<   r;   r=   rP   s         rA   r   r   U  s    B 5G51Avk 		"&&"9B,FF6?#=
 +s##,&  --KM?@@rC   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XU) -  '   [        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+   )r]   r*           r-   r.   Nr/   rM   )r*   onesr7   r8   rk   r   r
   rO   )	numeratordenominatorr>   r<   force_finiter(   r]   r*   nonzero_denominatoroutput_scoresnonzero_numeratorvalid_scoreavg_weightsresults                 rA   _assemble_r2_explained_variancer     s     OOE%*Y45%N FH)=%&"[%==&
" CF+>*>>?+s##,&  --K//%K66-.. #!m[9FF|qV}MrC   >   r-   r.   r/   boolean)r9   r:   r;   r<   rz   )r;   r<   rz   c          
          [        XX#5      u  pVn[        XX#US9u  p`pn[        X-
  USS9n[        X-
  U-
  S-  USS9n	[        XSS9n
[        X
-
  S-  USS9n[        U	UU R                  S   UUUU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'   r   rW   r   r+   rx   ry   r>   r<   rz   r(   r]   )r	   rF   r   r   r4   )r9   r:   r;   r<   rz   r(   r=   r]   
y_diff_avgrx   
y_true_avgry   s               rA   r   r     s    h -V]XMB6 	/M2	
 2Avk &/=qIJ	:	%!+]I &a@JF/A5}STUK*,,q/! rC   c                   [        XX#5      u  pVn[        XX#US9u  p`pn[        U5      S:  a(  Sn[        R                  " U[
        5        [        S5      $ Ub  [        U5      nUSS2S4   n	OSn	UR                  XU-
  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   z9R^2 score is not well-defined with less than two samples.nanNg      ?r   rp   )rL   rK   r(   r+   r   )r	   rF   r   warningswarnr   rO   r   sumr   r   r4   )r9   r:   r;   r<   rz   r(   r=   rc   msgweightrx   ry   s               rA   r   r   j  s    Z .NB7
 	/M2	
 2Avk FaIc12U| $]3q$w'v&Q 66Q?I&&8FMQQVWWW  K
 +,,q/! rC   )r9   r:   c                     [        X5      u  p#[        XSSUS9u  p@n  nUS:X  a  [        S5      e[        UR	                  UR                  X-
  5      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)
1.0
N)r;   r<   r(   r1   z&Multioutput not supported in max_error)r   rB   r5   rO   maxrN   )r9   r:   r(   r=   r@   s        rA   r   r     sc    D &)EB#5d$ FFAq ))ABBv/011rC   c                    [        X5      u  pEnUnUS:  as  SUR                  UR                  U S:  U S5      SU-
  5      SU-
  SU-
  -  -  XR                  USU-
  5      -  SU-
  -  -
  UR                  USU-
  5      SU-
  -  -   -  nOUS:X  a  X-
  S-  nOUS:X  a  S[        X U-  5      U -
  U-   -  nOUS:X  a  SUR	                  X-  5      X-  -   S-
  -  nO^SUR                  U SU-
  5      SU-
  SU-
  -  -  XR                  USU-
  5      -  SU-
  -  -
  UR                  USU-
  5      SU-
  -  -   -  n[        [        XS95      $ )z&Mean Tweedie deviance regression loss.r   r   rv   r+   rM   )r	   powwherexlogylogrO   r   )	r9   r:   r;   powerr(   r=   rc   pdevs	            rA   _mean_tweedie_deviancer   H  s   -f=NB7A1uFF!VS1A A!a% 	"
 vvfa!e,,A67 ffVQU#q1u-.
 
a1$	
a5&1F:VCD	
a266&/*V_<q@AFF61q5!a!eA%67vvfa!e,,A67ffVQU#q1u-.

 #566rC   rightleft)r9   r:   r;   r   r;   r   c                n   [        X5      u  pE[        XUSUS9u  p`pnUS:X  a  [        S5      eUb"  [        U5      nUSS2[        R
                  4   nSU S3nUS:  a(  UR                  US:*  5      (       a  [        US-   5      eOUS:X  a  OS	Us=::  a  S
:  aD  O  OAUR                  U S:  5      (       d  UR                  US:*  5      (       a  [        US-   5      eOMUS
:  aA  UR                  U S:*  5      (       d  UR                  US:*  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)
1.4260...
Nr<   r(   r1   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   rF   r5   r   rr   newaxisrk   r   )r9   r:   r;   r   r(   r=   r@   messages           rA   r    r    i  sO   x &)EB/U4B0,FF1 ))MNN $]3%am47w>STGqy66&A+W'BBCC 	!	
ea66&1*!!4!4W'UUVV "5	!66&A+"&&1"5"5W'HHII #6 !m rC   r9   r:   r;   rq   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)
1.4260...
r+   r   r    r   s      rA   r!   r!     s    P !}TUVVrC   c                    [        XUSS9$ )aR  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VrC   c                T   [        X5      u  pE[        XUSUS9u  p`pnUS:X  a  [        S5      e[        U5      S:  a(  Sn[        R
                  " U[        5        [        S5      $ UR                  U SS	9UR                  USS	9p[        XX#S
9n[        XUS9n	[        X	X#S
9n
SX-  -
  $ )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
    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   r1   z-Multioutput not supported in d2_tweedie_scorer   9D^2 score is not well-defined with less than two samples.r   r+   rp   r   )rK   r(   )r   rF   r5   r   r   r   r   rO   squeezer    r   r   )r9   r:   r;   r   r(   r=   r@   r   rx   y_avgry   s              rA   r#   r#      s    r &)EB/U4B0,FF1 ))HIIFaIc12U|ZZQZ/F1KF%mI Vr:E(]K y&&&rC   c                   [        XX$5      u  pPpn[        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O-[        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XU) -  '   [        U[        5      (       a  US:X  a  U$ SnOUn[        [        R                   " XS95      $ )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)
0.5
>>> d2_pinball_score(y_true, y_pred, alpha=0.9)
0.772...
>>> d2_pinball_score(y_true, y_pred, alpha=0.1)
-1.045...
>>> d2_pinball_score(y_true, y_true, alpha=0.1)
1.0
r   r   r   r-   rU   Nd   r   )qrL   r+   )r;   percentile_rankrv   rM   )rB   r   r   r   r   rO   r   rr   tile
percentilelenr   rw   r4   r7   r8   rt   )r9   r:   r;   rS   r<   r=   r   rx   
y_quantilery   r}   r{   r~   r|   r   s                  rA   r$   r$     sx   x 5G51Avk FaIc12U|!# I WWMM&CKa83v;:J

 WW US[ [!	

 $# K "Q%*#9KGGFLLO,M!"i&<{?W&W!XM>AM':&::;+s##,&   K!M?@@rC   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)
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')
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)
1.0
>>> y_true = [1, 2, 3]
>>> y_pred = [2, 2, 2]
>>> d2_absolute_error_score(y_true, y_pred)
0.0
>>> y_true = [1, 2, 3]
>>> y_pred = [3, 2, 1]
>>> d2_absolute_error_score(y_true, y_pred)
-1.0
rT   rU   )r$   rG   s       rA   r%   r%   )  s    ~ m3K rC   )numericN)N)2__doc__r   numbersr   numpyrr   
exceptionsr   utils._array_apir   r   r   r	   r
   r   r   utils._param_validationr   r   r   utils.statsr   utils.validationr   r   r   r   r   __ALL__rB   rF   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 . , EI^>D 488>v ..&-"L2C#DE|T	 #' &*7HQ&Q&h ..&-4Af56"L2C#DE|T #'	 &*BSV?	V?r ..&-"L2C#DE|T	 #' &*7H^1^1B ..&-"L2C#DE|T	 #' !M%M%` ..&-"L2C#DE|T	 #' &*7HH*H*V ..&-"L2C#DE|T	 #' !LL^ ..&-"L2C#DE|T	 #' &*7HBBJ .."L2C#DE|T&-	 #' $5DHAHAV/d ..&-MN
 #	 #'" !D ..&-MN

 #
 #'$ !bbJ .. #'!2!2H7B ..&-T473T1d62
	 #' <@q QQh ..&-
 #' <@  W WF ..&-
 #' :> !W!WH ..&-T473T1d62
	 #' 7;! d'd'N ..&-4Af56&789
	 #' &*BSFAFAR ..&-&789
	 #' &*7HUUrC   