IBM/lale

Suggest hyperparameter changes during errors

jsntsay opened this issue · 2 comments

For cases where hyperparameter constraints are violated, it may be possible to suggest changes for the user in the error message. A few study participants mentioned that this would be a nice feature to have.

Let a = {'h_1': a_1, ..., 'h_n': a_n} be the actual hyperparams that triggered a schema validation excception. And let d = {'h_1': d_1, ..., 'h_n': d_n} the default hyperparams. Assume d is valid and does not trigger a validation exception. Then we could start by trying the n possible ways of changing one of the a_i to a corresponding d_i, and checking whether that validates. If yes, we can return that as a suggested change to the user. Then we can try the n * (n-1) possible changes of two changes a_i, a_j. I would not continue past two, because of computational complexity and because an explanation involving three or more hyperparams would get complicated anyway.

This is an example error message that is now generated:

Invalid configuration for LogisticRegression(activation='relu', penalty='l1', solver='liblinear', multi_class='multinomial', dual=True) due to argument 'activation' was unexpected.
Some possible fixes include:
- Remove unknown key 'activation' and Set penalty='l2', multi_class='auto'
- Remove unknown key 'activation' and Set dual=False, multi_class='auto'
Schema of arguments and their defaults: {'solver': 'lbfgs', 'penalty': 'l2', 'dual': False, 'C': 1.0, 'tol': 0.0001, 'fit_intercept': True, 'intercept_scaling': 1.0, 'class_weight': None, 'random_state': None, 'max_iter': 100, 'multi_class': 'auto', 'verbose': 0, 'warm_start': False, 'n_jobs': None, 'l1_ratio': None}
Value: {'activation': 'relu', 'penalty': 'l1', 'solver': 'liblinear', 'multi_class': 'multinomial', 'dual': True, 'C': 1.0, 'tol': 0.0001, 'fit_intercept': True, 'intercept_scaling': 1.0, 'class_weight': None, 'random_state': None, 'max_iter': 100, 'verbose': 0, 'warm_start': False, 'n_jobs': None, 'l1_ratio': None}