Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Performs cross-validation with XGBoost.
import xgboost as xgb
from sklearn.datasets import load_boston
from sklearn.model_selection import KFold
import numpy as np
data = load_boston()
dtrain = xgb.DMatrix(data.data,data.target)
params = {'objective':'reg:squarederror'}
kf = KFold(n_splits=5,shuffle=True,random_state=42)
results = []
for train_index,test_index in kf.split(data.data):
X_train,X_test = data.data[train_index],data.data[test_index]
y_train,y_test = data.target[train_index],data.target[test_index]
model = xgb.XGBRegressor(objective='reg:squarederror')
model.fit(X_train,y_train)
results.append(model.score(X_test,y_test))
print('CV Scores:',results)XGBoost (Extreme Gradient Boosting) is an optimized, scalable, and high-performance gradient boosting framework based on decision trees, widely used for supervised learning tasks including classification, regression, and ranking.
Origin & Creator
XGBoost was developed by Tianqi Chen and collaborators in 2014 to provide an efficient and scalable gradient boosting library, optimized for performance and accuracy.
Industrial Note
XGBoost is heavily used in Kaggle competitions, finance, healthcare analytics, adtech, recommendation systems, and any scenario needing fast and accurate tree-based predictions.