Last active
August 1, 2020 13:39
-
-
Save pycaret/5b2efc98acc9a1343fa1ea49374bfa6a 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
# import classification module | |
from pycaret.classification import * | |
# init setup | |
clf1 = setup(data, target = 'name-of-target') | |
# train a decision tree model | |
dt = create_model('dt') | |
# tune hyperparameters of decision tree | |
tuned_dt = tune_model(dt) | |
# tune hyperparameters with increased n_iter | |
tuned_dt = tune_model(dt, n_iter = 50) | |
# tune hyperparameters to optimize AUC | |
tuned_dt = tune_model(dt, optimize = 'AUC') #default is 'Accuracy' | |
# tune hyperparameters with custom_grid | |
params = {"max_depth": np.random.randint(1, (len(data.columns)*.85),20), | |
"max_features": np.random.randint(1, len(data.columns),20), | |
"min_samples_leaf": [2,3,4,5,6], | |
"criterion": ["gini", "entropy"] | |
} | |
tuned_dt_custom = tune_model(dt, custom_grid = params) | |
# tune multiple models dynamically | |
top3 = compare_models(n_select = 3) | |
tuned_top3 = [tune_model(i) for i in top3] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment