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