我尝试了所有可能的解决方案,但仍然遇到此错误,已经安装了所有依赖库。
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'
答案 0 :(得分:0)
您可以通过以下方式强制升级XGBoost:
python -m pip install xgboost --user --upgrade pip
这为我修复了它。