sklearn.metrics.explained_variance_score?
sklearn.metrics.explained_variance_score(y_true, y_pred, *, sample_weight=None, multioutput='uniform_average')
解釋方差回歸得分函數
可能的最高分是1.0,數值越低越好。
在用戶指南中閱讀更多內容。
參數 | 說明 |
---|---|
y_true | array-like of shape (n_samples,) or (n_samples, n_outputs) 真實目標值。 |
y_pred | array-like of shape (n_samples,) or (n_samples, n_outputs) 預測目標值。 |
sample_weight | array-like of shape (n_samples,), optional 樣本權重。 |
multioutput | string in [‘raw_values’| ‘uniform_average’| ‘variance_weighted’] or array-like of shape (n_outputs) 定義多個輸出分數的匯總。類數組值定義用于平均分數的權重。 - ‘raw_values’: 如果是多輸出格式的輸入,則返回完整的得分集。 - ‘uniform_average’: 所有產出的得分均以統一權重平均。 - ‘variance_weighted’: 將所有輸出的分數平均,并按每個單獨輸出的方差加權。 |
返回值 | 說明 |
---|---|
score | float or ndarray of floats 如果‘multioutput’為‘raw_values’,則為解釋變量或ndarray。 |
注
這不是對稱函數。
示例
>>> 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...