为什么使用XGBoost时rmse和mse如此之大?



我正在学习XGBoost, mae和rmse数字如此之大,这怎么可能?

这是我在python中使用的代码

# Create the DMatrix: housing_dmatrix
housing_dmatrix = xgb.DMatrix(data=X, label=y)
# Create the parameter dictionary: params
params = {"objective":"reg:linear", "max_depth":4}
# Perform cross-validation: cv_results
cv_results = xgb.cv(dtrain=housing_dmatrix, params=params, nfold=4, num_boost_round=5, metrics="rmse", as_pandas=True, seed=123)
# Print cv_results
print(cv_results)
# Extract and print final boosting round metric
print((cv_results["test-rmse-mean"]).tail(1))

train-rmse-mean  train-rmse-std  test-rmse-mean  test-rmse-std
0    141767.535156      429.452682   142980.429688    1193.794436
1    102832.542969      322.473304   104891.392578    1223.157623
2     75872.617187      266.469946    79478.935547    1601.344218
3     57245.651367      273.625016    62411.921875    2220.149857
4     44401.297851      316.422372    51348.281250    2963.378741
51348.28125

我认为你的问题是解释指标。首先,我将解释它代表什么:

  • MSE代表均方误差,
  • RMSE代表均方根误差

这意味着两个指标都依赖于预测值的大小。如果你预测一辆车的座位数在2到7之间变化,你的RMSE真的很大。另一方面,如果你预测的是1到1亿之间的变化,RMSE真的很低。这就是为什么您应该使用其他指标的主要原因,例如MAPE(平均绝对百分比误差),将给你的值在0和1之间.

点击这个链接了解更多关于MAPE的信息以及如何使用scikit-learn。

相关内容