Machine Learning model-এর configuration বুঝতে গেলে প্রথমে parameters এবং hyperparameters-এর difference বুঝতে হবে।
দুইটিই model-এর behavior control করে, কিন্তু শেখার process আলাদা।
Learned Parameters
Learned Parameters হলো সেই values যা model training data থেকে নিজে learn করে।
উদাহরণ:
Linear Regression
→ Coefficients
Logistic Regression
→ Coefficients
Neural Network
→ Weights and Biases
ধরুন Linear Regression:
$$y = \beta_{0} + \beta_{1}x$$এখানে:
β₀
β₁
training process-এর সময় learn হয়।
Hyperparameters
Hyperparameters হলো model training-এর configuration।
এগুলো model সাধারণত training data থেকে directly learn করে না।
আমরা training শুরু করার আগে বা tuning process-এর মাধ্যমে choose করি।
Random Forest-এর example:
n_estimators
max_depth
min_samples_split
min_samples_leaf
max_features
XGBoost:
learning_rate
max_depth
subsample
colsample_bytree
n_estimators
Neural Network:
learning_rate
batch_size
number_of_layers
hidden_units
dropout
কেন Hyperparameter Tuning দরকার?
একই algorithm different hyperparameter-এর জন্য dramatically different performance দিতে পারে।
উদাহরণ:
Decision Tree
max_depth = 2
→ Too simple
→ Underfitting
max_depth = 50
→ Too complex
→ Overfitting
max_depth = 8
→ Maybe good balance
তাই suitable configuration খুঁজে বের করতে tuning করা হয়।
Grid Search
Grid Search-এ predefined values-এর সব possible combination try করা হয়।
উদাহরণ:
max_depth:
[3, 5, 7]
learning_rate:
[0.01, 0.1]
n_estimators:
[100, 300]
Total combinations:
3 × 2 × 2
= 12 experiments
সব 12টি combination evaluate করা হবে।
Grid Search-এর সুবিধা
simple
systematic
small search space-এ useful
Problem:
Search space বড় হলে
→ Number of combinations explode করে
উদাহরণ:
10 hyperparameters
×
10 possible values each
theoretically:
$$10^{10}$$combinations হতে পারে।
তাই Grid Search expensive হয়ে যায়।
Random Search
Random Search search space থেকে random hyperparameter combinations choose করে।
উদাহরণ:
1000 possible combinations আছে
সব try না করে
random 50 combinations try করলাম
Large search space-এ এটি অনেক সময় Grid Search-এর চেয়ে efficient।
বিশেষ করে যখন সব hyperparameter equally important নয়।
Intuition
ধরুন:
learning_rate
performance-এর জন্য খুব important।
কিন্তু:
some_other_parameter
কম important।
Grid Search কম useful parameter-এর অনেক value-ও systematically try করবে।
Random Search wider range explore করতে পারে।
Bayesian Optimization
Bayesian Optimization previous experiments-এর results ব্যবহার করে future experiment intelligently choose করে।
Conceptually:
Try Configuration A
↓
Observe Score
Try Configuration B
↓
Observe Score
Learn which region looks promising
↓
Try better configuration
অর্থাৎ previous experiments থেকে learn করে next promising hyperparameter set select করা হয়।
Popular tools:
Optuna
Hyperopt
Ray Tune
Validation কোথায় হবে?
Hyperparameters tune করতে হবে:
Validation Set
বা:
Cross-Validation
ব্যবহার করে।
Test set tuning-এর জন্য ব্যবহার করা উচিত নয়।
কেন Test Set ব্যবহার করা যাবে না?
যদি repeatedly test performance দেখে hyperparameter পরিবর্তন করেন, তাহলে indirectly আপনি test set-এর উপরও optimize করছেন।
তখন test set আর truly unseen থাকে না।
Correct flow:
Training Set
→ Learn parameters
Validation Set / CV
→ Tune hyperparameters
Test Set
→ Final unbiased evaluation
Hyperparameter Tuning ≠ Model Training
এটাও common confusion।
Model training:
Weights / coefficients learn করে
Hyperparameter tuning:
Best training configuration খুঁজে
Interview-ready Explanation
Model parameters are learned directly from training data,
such as regression coefficients or neural network weights.
Hyperparameters control how the model is trained,
such as tree depth, learning rate, or number of estimators.
Hyperparameter tuning searches for configurations that
perform well on validation data.
Grid Search evaluates predefined combinations,
Random Search samples combinations randomly,
and Bayesian Optimization uses previous experiments
to choose promising configurations.
The test set should not be used for hyperparameter tuning.