The xgboost module has a function DMatrix(). You can use it to create DMatrix object. Here is an example:
import xgboost as xgbfrom sklearn.datasets import load_breast_cancerfrom sklearn.model_selection import train_test_splitfrom sklearn.metrics import roc_auc_score# load breast cancer datadata = load_breast_cancer()X = data.datay = data.targetX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, random_state=1)# create DMatrix objectdtrain = xgb.DMatrix(X_train, y_train)dtest = xgb.DMatrix(X_test)# xgboost paramsparams = { 'max_depth': 6, 'subsample': 0.80, 'silent': 1}# train the modelmodel = xgb.train(params, dtrain)pred = model.predict(dtest)print(roc_auc_score(y_test, pred))