Here's an example of how to train and test an XGBoost model in Python:
main.py656 chars24 lines
In this example, we load the breast cancer dataset from scikit-learn, split it into training and testing sets using train_test_split, create an XGBoost model using xgb.XGBClassifier, train the model on the training set using model.fit, test the model on the testing set using model.predict, and evaluate the accuracy of the model using the percentage of correct predictions.
gistlibby LogSnag