如何验证广义线性回归模型的性能

How to validate performance of generalized linear regression model

我正在尝试验证具有连续输出的广义线性模型的性能。通过研究,我发现验证连续模型性能的最有效方法是使用 rsquared、adjusted rsquared 和 RMSE 方法(如果我错了请纠正我)而不是使用混淆矩阵方法(准确度、精度、f1 等) .) 用于二项式模型。

如何根据实际值与预测值找到模型的平方值。以下是我的 glm 模型的代码,数据已分为训练和测试。

对此很陌生,所以愿意接受建议。

#GENERALISED LINEAR MODEL
LR_swim <- glm(racetime_mins ~ event_month +gender + place +
             clocktime_mins +handicap_mins +
              Wind_Speed_knots+ 
             Air_Temp_Celsius +Water_Temp_Celsius +Wave_Height_m,
               data = SwimmingTrain, 
           family=gaussian(link = "identity"))
          summary(LR_swim)

#Predict Race_Time 
pred_LR <- predict(LR_swim, SwimmingTest, type ="response")
pred_LR

这样的性能指标可以用一行简单的 R 代码来实现。所以,对于一些虚拟数据:

preds <- c(1.0, 2.0, 9.5)
actuals <- c(0.9, 2.1, 10.0)

mean squared error (MSE) 就是

mean((preds-actuals)^2)
# [1] 0.09

mean absolute error (MAE)

mean(abs(preds-actuals))
# [1] 0.2333333

root mean squared error (RMSE) 只是 MSE 的平方根,即:

sqrt(mean((preds-actuals)^2))
# [1] 0.3

最后两个度量还有一个额外的优势,即与您的原始数据具有相同的规模(MSE 不是这种情况)。