【发布时间】:2020-01-24 20:02:20
【问题描述】:
我正在尝试在单词向量上训练模型 xgboost。 当我这样做时
model = xgb.XGBClassifier()
model.fit(X_train["comment_preproc"], y_train["label"])
y_predict = model.predict(X_test["comment_preproc"])
我得到了错误
IndexError Traceback (most recent call last)
<ipython-input-26-870161aebeee> in <module>()
1 model = xgb.XGBClassifier()
----> 2 model.fit(X_train["comment_preproc"], y_train["label"])
3 y_predict = model.predict(X_test["comment_preproc"])
/usr/local/lib/python3.6/dist-packages/xgboost/sklearn.py in fit(self, X, y, sample_weight, eval_set, eval_metric, early_stopping_rounds, verbose, xgb_model, sample_weight_eval_set, callbacks)
717 evals = ()
718
--> 719 self._features_count = X.shape[1]
720
721 if sample_weight is not None:
IndexError: tuple index out of range
我以为 X_train 和 y_train 的形状可能不同,但事实并非如此
我做错了什么?
【问题讨论】: