Improve speed of get_hyperparameters()