我尝试了所有可能的解决方案,但仍然收到此错误,已经安装了所有依赖库。
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder
from tqdm import tqdm
import xgboost as xgb
d_train = xgb.DMatrix(X_train, label=y_train)
AttributeError: 'module' object has no attribute 'DMatrix'
您可以使用以下命令强制升级XGBoost:
python -m pip install xgboost --user --upgrade pip
这已为我修复。