def sample(self): """Sample a completely configured component. Choose a path from tree and set values to parameters according to the given sampling functions. Returns ------- A component """ config = self._sample_cfg() # Fill config with values from internal nodes. if self.nodes: child_node = choice(self.nodes) config.update(child_node.partial_sample()) return materialize(self.name, self.path, config)
def partial_sample(self): """Sample a partial config. It is not enough to make a component. Returns ------- A dict containing the partial config. """ config = {} # Fill config with values from child nodes. if self.children: child_node = choice(self.children) config.update(child_node.partial_sample()) # Complete args with current node values, possibly overriding some # values from children nodes (this happens with frozen cs()). for name, param in self.params.items(): config[name] = param.sample() return config
def sample(self): from pjml.config.description.distributions import choice cs = choice(self.components) return cs.sample()
def sample(self): return choice(self.transformers)
def sample(self): return choice(self.components)