Optimisation des hyperparamètres

Gagner une compétition Kaggle en Python

Yauhen Babakhin

Kaggle Grandmaster

Itérations

Modèle RMSE validation RMSE LB public Rang LB public
Moyenne simple 9,986 9,409 1449 / 1500
Moyenne par groupe 9,978 9,407 1411 / 1500
Gradient Boosting 5,996 4,595 1109 / 1500
Ajout de l’heure 5,553 4,352 1068 / 1500
Ajout de la distance 5,268 4,103 1006 / 1500
... ... ... ...
Gagner une compétition Kaggle en Python

Itérations

Modèle RMSE validation RMSE LB public Rang LB public
Moyenne simple 9,986 9,409 1449 / 1500
Moyenne par groupe 9,978
Gradient Boosting 5,996 4,595 1109 / 1500
Ajout de l’heure 5,553
Ajout de la distance 5,268 4,103 1006 / 1500
... ... ... ...
Gagner une compétition Kaggle en Python

Optimisation des hyperparamètres

 

Type de compétition Feature engineering Optimisation des hyperparamètres
Machine Learning classique +++ +
Deep Learning - +++
Gagner une compétition Kaggle en Python

Régression Ridge

 

Régression linéaire aux moindres carrés

$$Loss = \sum_{i=1}^{N}{(y_i - \hat{y}_i)^2} \to \min$$

Gagner une compétition Kaggle en Python

Régression Ridge

 

Régression linéaire aux moindres carrés

$$Loss = \sum_{i=1}^{N}{(y_i - \hat{y}_i)^2} \to \min$$

Régression Ridge

$$Loss = \sum_{i=1}^{N}{(y_i - \hat{y}_i)^2 + \alpha\sum_{j=1}^{K}{{w_j}^2}} \to \min$$

Gagner une compétition Kaggle en Python

Stratégies d’optimisation des hyperparamètres

 

  • Recherche exhaustive. Choisir une grille prédéfinie de valeurs d’hyperparamètres
  • Recherche aléatoire. Définir l’espace de recherche des hyperparamètres
  • Optimisation bayésienne. Définir l’espace de recherche des hyperparamètres

schéma de recherche exhaustive

schéma de recherche aléatoire

Gagner une compétition Kaggle en Python

Recherche exhaustive

# Possible alpha values
alpha_grid = [0.01, 0.1, 1, 10]

from sklearn.linear_model import Ridge results = {} # For each value in the grid for candidate_alpha in alpha_grid:
# Create a model with a specific alpha value ridge_regression = Ridge(alpha=candidate_alpha)
# Find the validation score for this model
# Save the results for each alpha value results[candidate_alpha] = validation_score
Gagner une compétition Kaggle en Python

Passons à la pratique !

Gagner une compétition Kaggle en Python

Preparing Video For Download...