XGBoost হলো Gradient Boosting-এর একটি highly optimized এবং regularized implementation।
Tabular Machine Learning problem-এ এটি সবচেয়ে widely used algorithms-এর একটি।
Random Forest vs Boosting
Random Forest-এ trees প্রায় independentভাবে তৈরি করা হয়।
কিন্তু Boosting-এ:
Tree 1
↓
Tree 2 learns remaining errors
↓
Tree 3 improves remaining errors
↓
...
অর্থাৎ trees sequentialভাবে build হয়।
Intuition
ধরুন actual target:
100
প্রথম model predict করল:
70
Error:
+30
Next tree চেষ্টা করবে এই remaining error-এর কিছু অংশ correct করতে।
ধরুন Tree 2 add করল:
+20
New prediction:
70 + 20 = 90
Remaining error:
10
Next tree আবার ওই residual error improve করার চেষ্টা করবে।
Final Model
Boosting model-এর final prediction অনেক weak learners-এর contribution-এর sum।
$$\hat{y} = f_{1}(x) + f_{2}(x) + \ldots + f_{M(x)}$$বাস্তবে learning rate-এর মতো additional scaling-ও থাকে।
Gradient Boosting Idea
Regression-এর simple case-এ new tree residual fit করতে পারে।
কিন্তু general Gradient Boosting-এর deeper idea হলো:
প্রতিটি নতুন learner এমন direction-এ model improve করে যেদিকে loss সবচেয়ে দ্রুত decrease করতে পারে।
এই কারণেই নাম:
Gradient Boosting
XGBoost কেন জনপ্রিয়?
XGBoost-এর কিছু গুরুত্বপূর্ণ strength:
strong predictive performance nonlinear relationship capture করে feature interaction automatically শেখে regularization support করে missing values handle করতে পারে subsampling support করে efficient tree construction tabular data-তে খুব competitive
Important Hyperparameters
learning_rate
n_estimators
max_depth
min_child_weight
subsample
colsample_bytree
reg_alpha
reg_lambda
learning_rate
প্রতিটি নতুন tree final prediction-এ কতটা contribution করবে সেটি control করে।
Smaller learning rate
→ Smaller correction per tree
→ Usually more trees needed
max_depth
প্রতিটি tree কত deep হতে পারবে।
Deep tree:
More complex patterns
More overfitting risk
n_estimators
কতগুলো boosting trees তৈরি হবে।
Too few
→ Underfitting
Too many
→ Overfitting হতে পারে
সাধারণত early stopping useful।
Interview-ready Explanation
XGBoost is an optimized implementation of Gradient Boosting.
Unlike Random Forest, where trees are largely built
independently, boosting builds trees sequentially.
Each new tree attempts to reduce the errors made by the
current ensemble.
XGBoost is especially strong on structured tabular data
because it can model nonlinear relationships and
interactions while also supporting regularization,
subsampling, and efficient tree construction.