我正在尝试使用 xgboost 在分类问题上运行 -using python - ,其中我有一个numpy 矩阵 X(行 = 观察和列 = 特征)中的数据和一个numpy 数组 y 中的标签。因为我的数据很稀疏,所以我想让它使用稀疏版本的 X 来运行,但是当发生错误时,我似乎遗漏了一些东西。
这是我所做的:
# Library import
import numpy as np
import xgboost as xgb
from xgboost.sklearn import XGBClassifier
from scipy.sparse import csr_matrix
# Converting to sparse data and running xgboost
X_csr = csr_matrix(X)
xgb1 = XGBClassifier()
xgtrain = xgb.DMatrix(X_csr, label = y ) #to work with the xgb format
xgtest = xgb.DMatrix(Xtest_csr)
xgb1.fit(xgtrain, y, eval_metric='auc')
dtrain_predictions = xgb1.predict(xgtest)
Run Code Online (Sandbox Code Playgroud)
等等...
现在尝试拟合分类器时出现错误: …