【发布时间】:2020-08-07 11:33:34
【问题描述】:
一直在努力让它工作并能够找到 xgboost 的可靠指南。在 sklearn 上找不到任何东西,所以我正在尝试拼凑 xgboost 演练中的一些内容。
def gradientBoost():
xg_reg = xgb.XGBRegressor(objective="reg:linear", max_depth=5, n_estimators=100, random_state=42)
xg_reg.fit(x_train, y_train)
preds = xg_reg.predict(x_train)
rmse = np.sqrt(metrics.mean_squared_error(y_train,preds))
print("RMSE: %f" % rmse)
使用此代码我得到一个错误:
y_true and y_pred have a different number of outputs (18!=1)
我知道您看不到我正在使用的数据,但是如果我在 x_train,y_train 上对其进行训练,那么当我尝试获得对我曾经使用过的数据的预测准确性时,尺寸怎么会有所不同训练它?
【问题讨论】:
-
请发布您的
y_train和preds的样本,以及完整 错误跟踪。 -
y_train 是一个 (6475,18) 数组。 preds 是一个 (6475,) 数组。我开始明白我需要使用目标“multi:softmax”,但在使用 num_class 参数时遇到了困难
标签: python machine-learning xgboost