偏差分析計算公式及其 matlab 代碼實現(mse、mape、rmse等)

殘差平方和(SSE)

計算公式:

sse

代碼實現:

sse = sum((YReal - YPred).^2);

均方偏差(MSE)

計算公式:

mse

代碼實現:

mse = sqrt(sum((YReal - YPred).^2))./2;

平均絕對偏差(MAE)

計算公式:

mae

代碼實現:

mae = mean(abs(YReal - YPred));

平均絕對百分比偏差(MAPE)

計算公式:

mape

代碼實現

mape = mean(abs((YReal - YPred)./YReal));

均方根偏差(RMSE)

計算公式:

rmse

代碼實現:

rmse = sqrt(mean((YPred-YReal).^2));

決定係數(R2-R-Square)

計算公式:

r2

代碼實現:

r2 = 1 - (sum((YPred - YReal).^2) / sum((YReal - mean(YReal)).^2));

若有錯誤,請在評論區指出,謝謝。git

李培冠博客

歡迎訪問個人我的網站:網站

李培冠博客:lpgit.comcode

相關文章
相關標籤/搜索