Skip to content

Instantly share code, notes, and snippets.

@gabraganca
Created April 5, 2019 11:47
Show Gist options
  • Save gabraganca/4c8669c8be4a95065bb3a58dfa2377ef to your computer and use it in GitHub Desktop.
Save gabraganca/4c8669c8be4a95065bb3a58dfa2377ef to your computer and use it in GitHub Desktop.
# Define a grade de hiperparâmetros
param_grid = {
'n_factors': [10, 100, 200, 400],
'lr_all': [0.002, 0.005, 0.007, 0.009],
'n_epochs':[20, 100, 200, 400]
}
# Ajusta os modelos na grade com Validação Cruzada
gs = GridSearchCV(SVD, param_grid, measures=['mae', 'rmse'], cv=5, n_jobs=-1)
gs.fit(data)
# Mostra os melhores parãmetros encontrados para MAE e RMSE
## RMSE
print(f"RMSE:{gs.best_score['rmse']:.3f}")
print(gs.best_params['rmse'])
## MAE
print(f"MAE:{gs.best_score['mae']:.3f}")
print(gs.best_params['mae'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment