sklearn.metrics.mean_squared_log_error?

sklearn.metrics.mean_squared_log_error(y_true, y_pred, *, sample_weight=None, multioutput='uniform_average')

源碼

均方對數誤差回歸損失

在用戶指南中閱讀更多內容。

參數 說明
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’] or array-like of shape (n_outputs)
定義多個輸出值的匯總。類似數組的值定義了用于平均誤差的權重。
- ‘raw_values’:
如果是多輸出格式的輸入,則返回完整的錯誤集。
- ‘uniform_average’:
所有輸出的誤差均以相同的權重平均。
返回值 說明
loss float or ndarray of floats
非負浮點值(最佳值為0.0)或浮點值數組,每個目標對應一個浮點值。

示例

>>> 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...