我在学习XGBoost,得到的MAE和RMSE数值非常大,这怎么可能呢?
这是我在Python中使用的代码
# Create the DMatrix: housing_dmatrixhousing_dmatrix = xgb.DMatrix(data=X, label=y)# Create the parameter dictionary: paramsparams = {"objective":"reg:linear", "max_depth":4}# Perform cross-validation: cv_resultscv_results = xgb.cv(dtrain=housing_dmatrix, params=params, nfold=4, num_boost_round=5, metrics="rmse", as_pandas=True, seed=123)# Print cv_resultsprint(cv_results)# Extract and print final boosting round metricprint((cv_results["test-rmse-mean"]).tail(1)) train-rmse-mean train-rmse-std test-rmse-mean test-rmse-std0 141767.535156 429.452682 142980.429688 1193.7944361 102832.542969 322.473304 104891.392578 1223.1576232 75872.617187 266.469946 79478.935547 1601.3442183 57245.651367 273.625016 62411.921875 2220.1498574 44401.297851 316.422372 51348.281250 2963.378741 51348.28125
回答:
我认为你的问题在于如何理解这些指标。首先,我来解释一下这些缩写的含义:
- MSE代表均方误差,
- RMSE代表均方根误差。
这意味着这两个指标都依赖于预测值的大小。如果你预测的是汽车座位数,范围在2到7之间,那么你的RMSE就会非常大。另一方面,如果你预测的是在1到1亿之间的数值,那么RMSE就会非常低。这就是为什么你应该使用其他指标,比如MAPE(平均绝对百分比误差),它会给你一个在0到1之间的值。
查看这个链接,了解更多关于MAPE的信息以及如何使用scikit-learn来计算它。