-
-
Save marcosatanaka/f67879deac6300228c623ea789a1eb59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fit_model(X, y): | |
# Gera conjuntos de validação-cruzada para o treinamento de dados | |
cv_sets = ShuffleSplit(X.shape[0] # qt total elementos | |
, n_iter = 10 # qt vezes embaralhar e dividir | |
, test_size = 0.2 | |
, random_state = 123) | |
grid = GridSearchCV(DecisionTreeRegressor() | |
, dict(max_depth = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) | |
, make_scorer(performance_metric) | |
, cv = cv_sets) | |
# Encontrando os melhores parâmetros do estimador | |
grid = grid.fit(X, y) | |
return grid.best_estimator_ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment