喜欢的点个赞~
代码
import numpy as np
from sklearn import metrics
# 定义MAPE
def mape(y_true, y_pred):
return np.mean(np.abs((y_pred - y_true) / y_true)) * 100%
# MSE
print(metrics.mean_squared_error(y_true, y_pred))
# RMSE
print(np.sqrt(metrics.mean_squared_error(y_true, y_pred)))
# MAE
print(metrics.mean_absolute_error(y_true, y_pred))
# R2
print(metrics.r2_score(y_ture,y_pred))
# MAPE
print(mape(y_true, y_pred))