def rmse(predictions, targets):
return np.sqrt(((predictions - targets) ** 2).mean())
# Needed packages
from sklearn.metrics import mean_squared_error
# Values to compare
y_true = [[0.5, 1],[-1, 1],[7, -6]]
y_pred = [[0, 2],[-1, 2],[8, -5]]
# Root mean squared error (by using: squared=False)
rmse = mean_squared_error(y_true, y_pred, squared=False)
print(rmse)
def rms(x):
rms = np.sqrt(np.mean(x**2))
return rms