mirror of
https://github.com/wassname/seq2seq-time.git
synced 2026-07-21 12:50:53 +08:00
misc
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import numpy as np
|
||||
|
||||
EPSILON = 1e-10
|
||||
|
||||
def _error(actual: np.ndarray, predicted: np.ndarray):
|
||||
""" Simple error """
|
||||
return actual - predicted
|
||||
|
||||
def mse(actual: np.ndarray, predicted: np.ndarray):
|
||||
""" Mean Squared Error """
|
||||
return np.mean(np.square(_error(actual, predicted)))
|
||||
|
||||
def rmse(actual: np.ndarray, predicted: np.ndarray):
|
||||
""" Root Mean Squared Error """
|
||||
return np.sqrt(mse(actual, predicted))
|
||||
|
||||
|
||||
def smape(actual: np.ndarray, predicted: np.ndarray):
|
||||
"""
|
||||
Symmetric Mean Absolute Percentage Error
|
||||
Note: result is NOT multiplied by 100
|
||||
"""
|
||||
return np.mean(2.0 * np.abs(actual - predicted) / ((np.abs(actual) + np.abs(predicted)) + EPSILON))
|
||||
Reference in New Issue
Block a user