\(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 \(D^2\) score of 0.0.
Read more in the User Guide.
Added in version 1.1.
Ground truth (correct) target values.
Estimated target values.
Sample weights.
Defines aggregating of multiple output values. Array-like value defines weights used to average scores.
Returns a full set of errors in case of multioutput input.
Scores of all outputs are averaged with uniform weight.
The \(D^2\) score with an absolute error deviance or ndarray of scores if ‘multioutput’ is ‘raw_values’.
Notes
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
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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4