Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

XGBPaclet

Guides

  • XGBPaclet Guide

Tech Notes

  • XGBPaclet Functionality

Symbols

  • XgbModelPredict
  • XgbMeasurement
  • XgbMeasurement
  • XgbTrain
XGBPaclet Functionality
Here are the main functions in XGBPaclet and examples of them in action.
XgbTrain
The function to perform XGBoost Training
XgbMeasurement
The function to load and evaluate the XGBoost model on given data.
More functions will be added or updated in the future versions.
Create a XGBoost Python session
A XGBoost python session is required before using XgbTrain[].
The following code shows how to create a XGBoost python session:
In[1]:=
[◼]
RegisterEnvironment
["xgb"{"xgboost"(*withnumpy*),"scikit-learn==1.5.2","matplotlib"}]
Out[1]=
xgb
In[8]:=
session=
[◼]
StartEnvironment
["xgb"];
​
Prepare dataset for the following examples
Create binary classification training set and validation set for the following examples
In[1]:=
binary`traindata=RandomReal[{-10,10},{100,3}];​​binary`testdata=RandomReal[{-10,10},{100,3}];​​binary`trainlabel=RandomChoice[{"a","b"},{100}];​​binary`testlabel=RandomChoice[{"a","b"},{100}];​​binary`trainset={binary`traindatabinary`trainlabel};​​binary`testset={binary`testdatabinary`testlabel};
​
How to use XgbTrain[] to train a model
Use
XgbTrain[]
to train a model with trainset and XGBoost python session, and store the trained model in the output session:
In[18]:=
XgbTrain
[session,binary`trainset];
Starting the Python Prediction evaluation...
Classification task detected!
shap is not available
pandas is not available
matplotlib is imported
xgboost is imported
sklearn is imported
Auto-generated feature names : ['feat1', 'feat2', 'feat3']
Basic category parameters : {'max_depth': 3, 'eta': 1, 'objective': 'binary:logistic'} ,num_round = 5
Final parameters : {'max_depth': 2, 'eta': 1, 'objective': 'binary:logistic', 'eval_metric': ['logloss']} , num_round = 5
Start training xgb.train()
[0] train-logloss:0.63421
[1] train-logloss:0.59543
[2] train-logloss:0.55549
[3] train-logloss:0.52532
[4] train-logloss:0.50755
End of Training
​
How to use XgbModelPredict[] for the prediction.
XgbMeasurement[]
can evaluate the model in the session and make a prediction on given data:
In[16]:=
result=
XgbMeasurement
[session,binary`trainset];​​result["prediction"]
Classification task detected!
Starting the Python evaluation...
matplotlib is imported
xgboost is imported
sklearn is imported
Auto-generated feature names : ['feat1', 'feat2', 'feat3']
Out[17]=
{b,b,b,a,a,b,a,a,a,b,a,b,a,a,b,b,b,a,a,a,a,b,b,a,a,a,a,a,a,a,a,a,a,a,b,b,a,a,a,a,a,b,a,a,a,a,a,a,a,a,a,b,a,a,a,b,b,a,a,a,a,a,a,a,b,a,b,a,a,a,a,a,a,b,b,a,b,a,a,a,b,a,a,b,b,b,a,b,a,a,a,a,a,b,a,a,a,a,a,b}
​
RelatedGuides
▪
XGBPaclet Guide
""

© 2025 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com