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 = [352.57]
>>> y_pred = [2.5548]
>>> mean_squared_log_error(y_true, y_pred)
0.039...
>>> y_true = [[0.51], [12], [76]]
>>> y_pred = [[0.52], [12.5], [88]]
>>> mean_squared_log_error(y_true, y_pred)
0.044...
>>> mean_squared_log_error(y_true, y_pred, multioutput='raw_values')
array([0.004624280.08377444])
>>> mean_squared_log_error(y_true, y_pred, multioutput=[0.30.7])
0.060...