Optimizing Over Multiple Models

Searching for a good configuration for multiple models at the same time is possible using conditional search spaces. A conditional search space is defined by a list of dictionaries each containing one or more non-chocolate.Distribution parameter.

Sharing Parameters Between Models

In the last example, all SVMs share parameter C. Some optimizers might take advantage of this information to optimize this parameters across all SVM types thus accelerating convergence to an optimal configuration. Furthermore, the SVC algorithm and parameter gamma are shared for "rbf" and "poly" kernels. We can rewrite the last search space using nested dictionaries to represent the multiple condition levels.

space = {"algo" : {SVC : {"gamma" : choco.log(low=-9, high=3, base=10)},
                          "kernel" : {"rbf" : None,
                                      "poly" : {"degree" : choco.quantized_uniform(low=1, high=5, step=1),
                                                "coef0" : choco.uniform(low=-1, high=1)}},
                   LinearSVC : {"penalty" : choco.choice(["l1", "l2"])}},
         "C" : choco.log(low=-2, high=10, base=10)}

We can still add complexity to the search space by combining multiple dictionaries at the top level, if for example a configuration does not name an "algo" parameter.

space = [{"algo" : {SVC : {"gamma" : choco.log(low=-9, high=3, base=10)},
                           "kernel" : {"rbf" : None,
                                      "poly" : {"degree" : choco.quantized_uniform(low=1, high=5,  step=1),
                                                 "coef0" : choco.uniform(low=-1, high=1)}},
                    LinearSVC : {"penalty" : choco.choice(["l1", "l2"])}},
          "C" : choco.log(low=-2, high=10, base=10)},

         {"type" : "an_other_optimizer", "param" : choco.uniform(low=-1, high=1)}]

The remaining of the exploration is identical to the previous section.