Do scopes allow sharing of random variables

15 views
Skip to first unread message

KK

unread,
Mar 26, 2019, 3:36:33 PM3/26/19
to hyperopt-discuss
Hi,

We have been trying to figure out if using scopes or not in a search space affects the search efficiency.
For example, there are multiple ways to define a search space for LogisticRegression as below:

```
    n_jobs = -1
    multi_class = 'multinomial'

    if type == 'non_shared':
        search_space = hp.choice('estimator', [
            {'C': hp.loguniform('C1', 0.03125, 5), 'solver': 'sag', 'n_jobs': n_jobs, 'multi_class': multi_class},
            {'C': hp.loguniform('C2', 0.03125, 5), 'solver': 'lbfgs', 'n_jobs': n_jobs, 'multi_class': multi_class}
        ])
    elif type == 'maybe_shared':
        C = hp.loguniform('C1', 0.03125, 5)
        search_space = hp.choice('estimator',
                                 [scope.LogisticRegression(C=C, solver='sag', n_jobs=n_jobs, multi_class= multi_class),
                                  scope.LogisticRegression(C=C, solver='lbfgs', n_jobs=n_jobs, multi_class= multi_class)
                                  ])
    elif type == 'between_non_and_maybe':
        search_space = hp.choice('estimator',
                                 [scope.LogisticRegression(C=hp.loguniform('C1', 0.03125, 5), solver='sag',
                                                           n_jobs=n_jobs, multi_class= multi_class),
                                  scope.LogisticRegression(C=hp.loguniform('C2', 0.03125, 5), solver='lbfgs',
                                                           n_jobs=n_jobs, multi_class= multi_class)
                                  ])
    elif type == 'def_shared':
        search_space =  {'C': hp.loguniform('C', 0.03125, 5), 'solver': hp.choice('solver', ['sag', 'lbfgs']),
                         'n_jobs': n_jobs, 'multi_class': multi_class}

```
When Hyperopt samples from this search space, we wonder if there is a difference in the number of random variables corresponding to C in the cases above.
If yes, should we expect it to affect the search efficiency?
For cases 'non_shared' and 'def_shared', we have written code to pass the sampled hyper parameter values to LogisticRegression before using it for training.
The documentation did not clarify this point, and running some experiments on MNIST for comparison were not conclusive either. So any pointers to how it is supposed to work are highly appreciated.

Thank you,
KK

Reply all
Reply to author
Forward
0 new messages