XGBoost Regressor
Create an XGBoost regressor object.
We'll cover the following
Chapter Goals:
- Learn how to create a scikit-learn style regression model in XGBoost
A. XGBoost linear regression
In addition to scikit-learn style classifiers, XGBoost also provides a scikit-learn style linear regression model with the XGBRegressor
object.
model = xgb.XGBRegressor(max_depth=2)# predefined data and labels (for regression)model.fit(data, labels)# new_data contains 2 new data observationspredictions = model.predict(new_data)print('Predictions:\n{}'.format(repr(predictions)))
Just like the XGBClassifier
object, we can specify the model's parameters with keyword arguments. In the code above, we set the max_depth
parameter (representing the depth of the boosted decision tree) to 2.
Get hands-on with 1300+ tech skills courses.