sensorutils.metrics
Note
可能ならsklearn.metrics
を使用したほうが良い
mae(true, pred, axis=None)
Calc Mean Absolute Error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true |
ndarray |
true data. |
required |
pred |
ndarray |
predicted data. |
required |
Examples:
>>> a = np.random.randn(2, 3, 4)
>>> b = np.random.randn(2, 3, 4)
>>> mae(a, b)
>>> mae(a, b, axis=2)
Returns:
Type | Description |
---|---|
Union[float, numpy.ndarray] |
MAE |
mape(true, pred, axis=None)
Calc Mean Absolute Persentage Error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true |
ndarray |
true data. |
required |
pred |
ndarray |
predicted data. |
required |
Examples:
>>> a = np.random.randn(2, 3, 4)
>>> b = np.random.randn(2, 3, 4)
>>> mape(a, b)
>>> mape(a, b, axis=2)
Returns:
Type | Description |
---|---|
Union[float, numpy.ndarray] |
MAPE |
mse(true, pred, axis=None)
Calc Mean Squared Error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true |
ndarray |
true data. |
required |
pred |
ndarray |
predicted data. |
required |
Examples:
>>> a = np.random.randn(2, 3, 4)
>>> b = np.random.randn(2, 3, 4)
>>> mse(a, b)
>>> mse(a, b, axis=2)
Returns:
Type | Description |
---|---|
Union[float, numpy.ndarray] |
MSE |
rmse(true, pred, axis=None)
Calc Root Mean Squared Error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true |
ndarray |
true data. |
required |
pred |
ndarray |
predicted data. |
required |
Examples:
>>> a = np.random.randn(2, 3, 4)
>>> b = np.random.randn(2, 3, 4)
>>> rmse(a, b)
>>> rmse(a, b, axis=2)
Returns:
Type | Description |
---|---|
Union[float, numpy.ndarray] |
RMSE |
rmspe(true, pred, axis=None)
Calc Root Mean Squared Persentage Error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true |
ndarray |
true data. |
required |
pred |
ndarray |
predicted data. |
required |
Examples:
>>> a = np.random.randn(2, 3, 4)
>>> b = np.random.randn(2, 3, 4)
>>> rmspe(a, b)
>>> rmspe(a, b, axis=2)
Returns:
Type | Description |
---|---|
Union[float, numpy.ndarray] |
RMSPE |
rmsle(true, pred, axis=None)
Calc root mean squared logarithmic error.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true |
ndarray |
clean data |
required |
pred |
ndarray |
with noise |
required |
axis |
Optional[int] |
mean axis |
None |
Examples:
>>> a = np.random.randn(2, 3, 4)
>>> b = np.random.randn(2, 3, 4)
>>> rmsle(a, b)
>>> rmsle(a, b, axis=2)
Returns:
Type | Description |
---|---|
Union[float, numpy.ndarray] |
RMSLE |
r2(true, pred)
Calc r2 score(coefficient of determination).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true |
ndarray |
clean data |
required |
pred |
ndarray |
with noise |
required |
Examples:
>>> a = np.random.randn(2, 3, 4)
>>> b = np.random.randn(2, 3, 4)
>>> r2(a, b)
Returns:
Type | Description |
---|---|
float |
coefficient of determination |
snr(true, pred, axis=None)
Calc Signal to Noise Ratio.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true |
ndarray |
clean data |
required |
pred |
ndarray |
with noise |
required |
axis |
Optional[int] |
mean axis (default=None) |
None |
Examples:
>>> a = np.random.randn(2, 3, 4)
>>> b = np.random.randn(2, 3, 4)
>>> snr(a, b)
>>> snr(a, b, axis=2)
Returns:
Type | Description |
---|---|
Union[float, numpy.ndarray] |
SNR |
lsd(true_spec, pred_spec, axis=None)
Calc Log Spectral Distance.
\(S(\omega)\)と\(\tilde{S}(\omega)\) は,それぞれ原波形と雑音抑圧波形の対数スペクトル.
複数の短時間スペクトルの距離は各スペクトルで距離を算出した後,平均を取ること.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
true_spec |
ndarray |
spectral 1 |
required |
pred_spec |
ndarray |
spectral 2 |
required |
axis |
Optional[int] |
Not use |
None |
Examples:
>>> a = np.random.randn(2, 3, 4)
>>> b = np.random.randn(2, 3, 4)
>>> lsd(a, b).shape
Returns:
Type | Description |
---|---|
Union[float, numpy.ndarray] |
LSD |