def main():
    """
    Just runs some example code.
    """

    # setup the flow
    flow = Flow(name="list files")

    listfiles = ListFiles()
    listfiles.config["dir"] = str(helper.get_data_dir())
    listfiles.config["list_files"] = True
    listfiles.config["list_dirs"] = False
    listfiles.config["recursive"] = False
    listfiles.config["regexp"] = ".*.arff"
    flow.actors.append(listfiles)

    tee = Tee()
    flow.actors.append(tee)

    convert = Convert()
    convert.config["setup"] = conversion.PassThrough()
    tee.actors.append(convert)

    console = Console()
    console.config["prefix"] = "Match: "
    tee.actors.append(console)

    load = LoadDataset()
    load.config["use_custom_loader"] = True
    flow.actors.append(load)

    cross = CrossValidate()
    cross.config["setup"] = Classifier(classname="weka.classifiers.trees.J48",
                                       options=["-C", "0.3"])
    flow.actors.append(cross)

    summary = EvaluationSummary()
    summary.config["matrix"] = True
    flow.actors.append(summary)

    # print flow
    flow.setup()
    print("\n" + flow.tree + "\n")

    # save the flow
    fname = tempfile.gettempdir() + os.sep + "simpleflow.json"
    Flow.save(flow, fname)

    # load flow
    fl2 = Flow.load(fname)

    # output flow
    fl2.setup()
    print("\n" + fl2.tree + "\n")
def main():
    """
    Just runs some example code.
    """

    # setup the flow
    flow = Flow(name="list files")

    listfiles = ListFiles()
    listfiles.config["dir"] = str(helper.get_data_dir())
    listfiles.config["list_files"] = True
    listfiles.config["list_dirs"] = False
    listfiles.config["recursive"] = False
    listfiles.config["regexp"] = ".*.arff"
    flow.actors.append(listfiles)

    tee = Tee()
    flow.actors.append(tee)

    convert = Convert()
    convert.config["setup"] = conversion.PassThrough()
    tee.actors.append(convert)

    console = Console()
    console.config["prefix"] = "Match: "
    tee.actors.append(console)

    load = LoadDataset()
    load.config["use_custom_loader"] = True
    flow.actors.append(load)

    cross = CrossValidate()
    cross.config["setup"] = Classifier(classname="weka.classifiers.trees.J48", options=["-C", "0.3"])
    flow.actors.append(cross)

    summary = EvaluationSummary()
    summary.config["matrix"] = True
    flow.actors.append(summary)

    # print flow
    flow.setup()
    print("\n" + flow.tree + "\n")

    # save the flow
    fname = tempfile.gettempdir() + os.sep + "simpleflow.json"
    Flow.save(flow, fname)

    # load flow
    fl2 = Flow.load(fname)

    # output flow
    fl2.setup()
    print("\n" + fl2.tree + "\n")
def main():
    """
    Just runs some example code.
    """
    """
    Tests some conversions.
    """

    # setup the flow
    helper.print_title("conversions")

    flow = Flow(name="conversions")

    strings = StringConstants()
    strings.config["strings"] = ["weka.classifiers.trees.J48", "weka.classifiers.functions.SMO"]
    flow.actors.append(strings)

    c2a = CommandlineToAny()
    c2a.config["wrapper"] = "weka.classifiers.Classifier"
    convert1 = Convert()
    convert1.config["setup"] = c2a
    flow.actors.append(convert1)

    convert2 = Convert()
    convert2.config["setup"] = AnyToCommandline()
    flow.actors.append(convert2)

    console = Console()
    console.config["prefix"] = "setup: "
    flow.actors.append(console)

    # run the flow
    msg = flow.setup()
    if msg is None:
        print("\n" + flow.tree + "\n")
        msg = flow.execute()
        if msg is not None:
            print("Error executing flow:\n" + msg)
    else:
        print("Error setting up flow:\n" + msg)
    flow.wrapup()
    flow.cleanup()
def main():
    """
    Just runs some example code.
    """
    """
    Tests some conversions.
    """

    # setup the flow
    helper.print_title("conversions")

    flow = Flow(name="conversions")

    strings = StringConstants()
    strings.config["strings"] = [
        "weka.classifiers.trees.J48", "weka.classifiers.functions.SMO"
    ]
    flow.actors.append(strings)

    c2a = CommandlineToAny()
    c2a.config["wrapper"] = "weka.classifiers.Classifier"
    convert1 = Convert()
    convert1.config["setup"] = c2a
    flow.actors.append(convert1)

    convert2 = Convert()
    convert2.config["setup"] = AnyToCommandline()
    flow.actors.append(convert2)

    console = Console()
    console.config["prefix"] = "setup: "
    flow.actors.append(console)

    # run the flow
    msg = flow.setup()
    if msg is None:
        print("\n" + flow.tree + "\n")
        msg = flow.execute()
        if msg is not None:
            print("Error executing flow:\n" + msg)
    else:
        print("Error setting up flow:\n" + msg)
    flow.wrapup()
    flow.cleanup()