Table of Contents

Hyperparameter tuning

Plan for the lecture

Plan for the lecture : models

What framework to use?

They implement the same functionality! (except sklearn)

Tips

Don't spend too much time tuning hyperparameters

Be patient

Average everything

How do we tune hyperparameters

  1. Select the most influential parameters
    - There are tons of parameters and we can't tune all of them
  2. Understand, how exactly they influence the training
  3. Tune them!
    - Manually (change the examine)
    - Automatically (hyperopt, etc)

Hyperparameter optimization software

A lot of libraries to try:

def xgb_score(param):
  # run XGBoost with arameters 'param'
  
def xgb_hyperopt():
  space = {
    'eta': 0.01,
    'max_depth': hp.quniform('max_depth', 10, 30, 1),
    'min_child_weight': hp.quniform('min_child_weight', 0, 100, 1),
    'subsample': hp.quniform('subsample', 0.1, 1.0, 0.1),
    'gamma': hp.quniform('gamma', 0.0, 30, 0.5),
    'colsample_bytree': hp.quniform('colsample_bytree', 0.1, 1.0, 0.1),
    'objective': 'reg:linear',
    'nthread': 28,
    'silent': 1,
    'num_round': 2500,
    'seed': 2441,
    'early_stopping_rounds': 100
  }
  
  best = fmin(xgb_score, space, algo=tpe.suggest, max_evals=1000)

Color-coding legend

  1. Underfitting (bad) (red)
  2. Good fit and generalization (good)
  3. Overfitting (bad) (green)

A parameter in red

  1. Increasing it impedes fitting
  2. Increase it to reduce overfitting
  3. Decrease to allow model fit easier

A parameter in green

  1. Increasing it leads to a better fit (overfit) on train set
  2. Increase it, if model underfits
  3. Decrease if overfits

wl60v5z.jpg

Conclusion

Hyperparameter tuning in general

Models, libraries and hyperparameter optimization

Ref