Last active
January 10, 2021 18:30
-
-
Save patrickbrus/5b4badfc3c3c8407da7025b8791c967b to your computer and use it in GitHub Desktop.
Fit a bayesian optimizer and a decsion tree model
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
# Define a model | |
tree = DecisionTreeRegressor(criterion="mse") | |
# Create the Bayesion optimization object | |
opt = BayesSearchCV( | |
tree, | |
{ | |
"max_depth": (5, 15), | |
"splitter": ["best", "random"], | |
}, | |
n_iter=n_iter, | |
cv=n_folds | |
) | |
# Train the model | |
opt.fit(train_x, train_y) | |
model = opt.best_estimator_ | |
# Save the trained model | |
joblib.dump(model, os.path.join(args.model_dir, "model.joblib")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment