mean_squared_log_error# (均方對數誤差)#

sklearn.metrics.mean_squared_log_error(y_true, y_pred, *, sample_weight=None, multioutput='uniform_average')[原始碼]#

均方對數誤差迴歸損失。

請參閱使用者指南以獲取更多資訊。

參數:
y_truearray-like,形狀為 (n_samples,) 或 (n_samples, n_outputs)

真實(正確)的目標值。

y_predarray-like,形狀為 (n_samples,) 或 (n_samples, n_outputs)

預估的目標值。

sample_weightarray-like,形狀為 (n_samples,),預設值為 None

樣本權重。

multioutput{‘raw_values’, ‘uniform_average’} 或 array-like,形狀為 (n_outputs,),預設值為 ‘uniform_average’

定義多個輸出值的聚合方式。類陣列值定義用於平均誤差的權重。

‘raw_values’

當輸入為多輸出格式時,返回完整的誤差集。

‘uniform_average’

所有輸出的誤差均勻加權平均。

返回:
lossfloat 或 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...