我正在尝试在单词向量上训练模型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的形状可能不同,但事实并非如此
我在做什么错?
(758079,)
和(758079,)
仅由一个元素组成。因此出现错误:
>>> t = (758079,)
>>> t[0]
758079
>>> t[1]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: tuple index out of range