Example #1
0
    def get_experiment_name(self,
                            setting: SettingABC,
                            experiment_id: str = None) -> str:
        """Gets a unique name for the experiment where `self` is applied to `setting`.

        This experiment name will be passed to `orion` when performing a run of
        Hyper-Parameter Optimization.

        Parameters
        ----------
        - setting : Setting

            The `Setting` onto which this method will be applied. This method will be used when

        - experiment_id: str, optional

            A custom hash to append to the experiment name. When `None` (default), a
            unique hash will be created based on the values of the Setting's fields.

        Returns
        -------
        str
            The name for the experiment.
        """
        if not experiment_id:
            setting_dict = setting.to_dict()
            # BUG: Some settings have non-string keys/value or something?
            d = flatten_dict(setting_dict)
            experiment_id = compute_identity(size=5, **d)
        assert isinstance(setting.dataset,
                          str), "assuming that dataset is a str for now."
        return (
            f"{self.get_name()}-{setting.get_name()}_{setting.dataset}_{experiment_id}"
        )
Example #2
0
 def __eq__(self, other: object):
     if not isinstance(other, tuple):
         return NotImplemented
     elif not len(other) == 2:
         return NotImplemented
     # NOTE: This doesn't do any kind
     other_hp, other_perf = other
     hps_equal = self.hp == other_hp
     if not hps_equal and isinstance(other_hp, dict):
         other_id = compute_identity(**other_hp)
         # this is hairy, but need to check if the dicts would be equal.
         if isinstance(self.hp, dict):
             # This should ideally never be the case, we would hope that
             # people are using HyperParameter objects in the Point tuples.
             hp_id = compute_identity(**self.hp)
         else:
             hp_id = self.hp.id()
         hps_equal = hp_id == other_id
     return hps_equal and self.perf == other[1]
Example #3
0
 def id(self):
     return compute_identity(**self.to_dict())
Example #4
0
 def space_id(cls):
     return compute_identity(**cls.get_orion_space_dict())