Пример #1
0
            def __init__(self):
                super().__init__()

                yes_node, no_node = (self.start().add(DummyAction()).add(
                    Decision(MyModel())).add(yes=YesAction(), no=NoAction()))

                no_node.add(DummyAction())
                self.end()
Пример #2
0
def create_graph():
    """Create a graph which prints hello for each even number x in the input stream,
    using a conditional RuleBasedModel node and a HelloPrinter h1.Action."""
    graph = Graph()
    graph.start() \
        .add(Decision(SimpleRuleBasedModel(), result_field="predictions")) \
        .add(yes=HelloPrinter(), no=NoOp())
    graph.end()
    return graph
Пример #3
0
            def __init__(self):
                super().__init__()

                yes_node, no_node = (self.start().add(Decision(MyModel())).add(
                    yes=YesAction(), no=NoAction()))

                self.end()

                self.nodes.end.transform_output = lambda inputs: {
                    'result': inputs['results'] + inputs['no_results'] * 1000
                }
Пример #4
0
            def __init__(self):
                super().__init__()

                yes_node, no_node = (self.start().add(DummyAction()).add(
                    Decision(MyModel())).add(yes=YesAction(), no=NoAction()))

                no_node.add(DummyAction())
                self.end()

                self.nodes.YesAction.transform_output = lambda inputs: {
                    'yes_sum': inputs['results']
                }
                self.nodes.NoAction.transform_output = lambda inputs: {
                    'no_sum': inputs['results']
                }
Пример #5
0
    def test_render_graph(self):
        class DummyModel(MLModel):
            pass

        g = Graph()
        g.start()

        g.add(DummyModel(), id='m1')\
            .add(Decision(DummyModel(), id='m2'))\
            .add(
                yes=Action(DummyModel(), id='m3'),
                no=Action(DummyModel(), id='m4'),
            )

        g.end()

        g.visualize().to_dot()