0

Pycaret automatically searches the best parameters. For example, the codes below will allocate 5 automatically tuned models to 'tuned_top5'.

from pycaret.classification import *
setup(data=train, train_size=.9, target='my_target_feature')
tuned_top5 = [tune_model(model) for model in top5]

However, this is not enough for me. I want to know the exact names and values of hyperparameters. For instance, if this code tune max_depth to 9, I want "max_depth=9" or similar outcome to be printed.

Is there any way to do this?

J Kim
  • 1
  • 1
  • 2

3 Answers3

3

You can pull out the names of the parameters from the models and print them out directly:

print(tuned_top5.get_all_params())

If you are only interested in a single parameter, or a short list of parameters then pull them out individually to print.

params = tuned_top5.get_all_params()
print("max depth = ', params['max_depth'])
David
  • 3,251
  • 18
  • 28
Emera
  • 31
  • 2
  • 2
    It is always better to add a description to the code you post, so it is well explained and informative. – Ruli Jan 21 '21 at 11:40
0

I dont know is it your question but;

best=compare_models(exclude=['ransac'])

best variable gets most succesfully model for regression its default r2 so just use;

print(best)

so you can see which parameters used by this model.you can also see all hypermeters when you save models or you can print model you manually created with pycaret. I hope it helps you.

elandil2
  • 25
  • 1
  • 3
0

You can use

tuned_best_model.get_params

And it will give you the list with the hyperparameters that were chosen in the tuning.

I hope it helps you.

Jplavorr
  • 83
  • 4