Example #1
0
    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
Example #3
0
 def sample(self):
     from pjml.config.description.distributions import choice
     cs = choice(self.components)
     return cs.sample()
Example #4
0
 def sample(self):
     return choice(self.transformers)
Example #5
0
 def sample(self):
     return choice(self.components)