• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python control.Flow类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中weka.flow.control.Flow的典型用法代码示例。如果您正苦于以下问题:Python Flow类的具体用法?Python Flow怎么用?Python Flow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Flow类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: main

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

    # setup the flow
    flow = Flow(name="math expression")

    outer = ForLoop()
    outer.config["max"] = 100
    flow.actors.append(outer)

    expr = MathExpression()
    expr.config["expression"] = "math.sqrt({X})"
    flow.actors.append(expr)

    console = Console()
    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()
开发者ID:fracpete,项目名称:python-weka-wrapper-examples,代码行数:30,代码来源:math_expression.py


示例2: main

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

    # setup the flow
    helper.print_title("Plot dataset")
    iris = helper.get_data_dir() + os.sep + "iris.arff"

    flow = Flow(name="plot dataset")

    filesupplier = FileSupplier()
    filesupplier.config["files"] = [iris]
    flow.actors.append(filesupplier)

    loaddataset = LoadDataset()
    flow.actors.append(loaddataset)

    branch = Branch()
    flow.actors.append(branch)

    seq = Sequence(name="matrix plot")
    branch.actors.append(seq)

    mplot = MatrixPlot()
    mplot.config["percent"] = 50.0
    mplot.config["wait"] = False
    seq.actors.append(mplot)

    seq = Sequence(name="line plot")
    branch.actors.append(seq)

    copy = Copy()
    seq.actors.append(copy)

    flter = Filter()
    flter.config["setup"] = filters.Filter(
        classname="weka.filters.unsupervised.attribute.Remove", options=["-R", "last"])
    flter.config["keep_relationname"] = True
    seq.actors.append(flter)

    lplot = LinePlot()
    lplot.config["percent"] = 50.0
    lplot.config["wait"] = True
    seq.actors.append(lplot)

    # 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()
开发者ID:fracpete,项目名称:python-weka-wrapper3-examples,代码行数:60,代码来源:plot_dataset.py


示例3: main

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

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

    listfiles = ListFiles()
    listfiles.config["dir"] = str(tempfile.gettempdir())
    listfiles.config["list_files"] = True
    listfiles.config["list_dirs"] = False
    listfiles.config["recursive"] = False
    listfiles.config["regexp"] = ".*r.*"
    # listfiles.print_help()
    flow.actors.append(listfiles)

    console = Console()
    console.config["prefix"] = "Match: "
    # console.print_help()
    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()
开发者ID:fracpete,项目名称:python-weka-wrapper3-examples,代码行数:34,代码来源:list_file.py


示例4: load_incremental

def load_incremental():
    """
    Loads a dataset incrementally.
    """

    # setup the flow
    helper.print_title("Load dataset (incremental)")
    iris = helper.get_data_dir() + os.sep + "iris.arff"

    flow = Flow(name="load dataset")

    filesupplier = FileSupplier()
    filesupplier.config["files"] = [iris]
    flow.actors.append(filesupplier)

    loaddataset = LoadDataset()
    loaddataset.config["incremental"] = True
    flow.actors.append(loaddataset)

    console = Console()
    flow.actors.append(console)

    # run the flow
    msg = flow.setup()
    if msg is None:
        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()
开发者ID:fracpete,项目名称:python-weka-wrapper3-examples,代码行数:32,代码来源:load_dataset.py


示例5: load_custom_loader

def load_custom_loader():
    """
    Loads a dataset using a custom loader.
    """

    # setup the flow
    helper.print_title("Load dataset (custom loader)")
    iris = helper.get_data_dir() + os.sep + "iris.csv"

    flow = Flow(name="load dataset")

    filesupplier = FileSupplier()
    filesupplier.config["files"] = [iris]
    flow.actors.append(filesupplier)

    loaddataset = LoadDataset()
    loaddataset.config["incremental"] = False
    loaddataset.config["use_custom_loader"] = True
    loaddataset.config["custom_loader"] = Loader(classname="weka.core.converters.CSVLoader")
    flow.actors.append(loaddataset)

    console = Console()
    flow.actors.append(console)

    # run the flow
    msg = flow.setup()
    if msg is None:
        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()
开发者ID:fracpete,项目名称:python-weka-wrapper3-examples,代码行数:34,代码来源:load_dataset.py


示例6: main

def main():
    """
    Just runs some example code.
    """
    """
    Loads data from a database.
    """

    # setup the flow
    helper.print_title("Load from database")

    flow = Flow(name="load from database")

    loaddatabase = LoadDatabase()
    loaddatabase.config["db_url"] = "jdbc:mysql://HOSTNAME:3306/DBNAME"
    loaddatabase.config["user"] = "DBUSER"
    loaddatabase.config["password"] = "DBPW"
    loaddatabase.config["query"] = "select * from TABLE"
    flow.actors.append(loaddatabase)

    console = Console()
    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()
开发者ID:fracpete,项目名称:python-weka-wrapper3-examples,代码行数:34,代码来源:load_database.py


示例7: main

def main():
    """
    Just runs some example code.
    """
    # setup the flow
    helper.print_title("Generate dataset")

    flow = Flow(name="generate dataset")

    generator = DataGenerator()
    generator.config["setup"] = datagen.DataGenerator(classname="weka.datagenerators.classifiers.classification.Agrawal")
    flow.actors.append(generator)

    console = Console()
    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()
开发者ID:fracpete,项目名称:python-weka-wrapper-examples,代码行数:27,代码来源:generate_dataset.py


示例8: main

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

    # setup the flow
    flow = Flow(name="update storage value")

    start = Start()
    flow.actors.append(start)

    init = InitStorageValue()
    init.config["storage_name"] = "max"
    init.config["value"] = "int(1)"
    flow.actors.append(init)

    trigger = Trigger()
    flow.actors.append(trigger)

    outer = ForLoop()
    outer.name = "outer"
    outer.config["max"] = 3
    trigger.actors.append(outer)

    trigger2 = Trigger()
    trigger.actors.append(trigger2)

    inner = ForLoop()
    inner.name = "inner"
    inner.config["max"] = "@{max}"
    trigger2.actors.append(inner)

    console = Console()
    trigger2.actors.append(console)

    update = UpdateStorageValue()
    update.config["storage_name"] = "max"
    update.config["expression"] = "{X} + 2"
    trigger.actors.append(update)

    # 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()
开发者ID:fracpete,项目名称:python-weka-wrapper3-examples,代码行数:51,代码来源:update_storage_value.py


示例9: main

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

    # setup the flow
    flow = Flow(name="combine storage")

    outer = ForLoop()
    outer.name = "outer"
    outer.config["max"] = 3
    flow.actors.append(outer)

    ssv = SetStorageValue()
    ssv.config["storage_name"] = "max"
    flow.actors.append(ssv)

    trigger = Trigger()
    flow.actors.append(trigger)

    inner = ForLoop()
    inner.name = "inner"
    inner.config["max"] = "@{max}"
    trigger.actors.append(inner)

    ssv2 = SetStorageValue()
    ssv2.config["storage_name"] = "inner"
    trigger.actors.append(ssv2)

    trigger2 = Trigger()
    trigger.actors.append(trigger2)

    combine = CombineStorage()
    combine.config["format"] = "@{max} / @{inner}"
    trigger2.actors.append(combine)

    console = Console()
    trigger2.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()
开发者ID:fracpete,项目名称:python-weka-wrapper3-examples,代码行数:50,代码来源:combine_storage.py


示例10: main

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")
开发者ID:fracpete,项目名称:python-weka-wrapper3-examples,代码行数:53,代码来源:load_save_flow.py


示例11: main

def main():
    """
    Just runs some example code.
    """
    """
    Loads/filters a dataset incrementally and saves it to a new file.
    """

    # setup the flow
    helper.print_title("Load/filter/save dataset (incrementally)")
    iris = helper.get_data_dir() + os.sep + "iris.arff"

    flow = Flow(name="Load/filter/save dataset (incrementally)")

    filesupplier = FileSupplier()
    filesupplier.config["files"] = [iris]
    flow.actors.append(filesupplier)

    loaddataset = LoadDataset()
    loaddataset.config["incremental"] = True
    flow.actors.append(loaddataset)

    flter = Filter()
    flter.config["setup"] = filters.Filter(
        classname="weka.filters.unsupervised.attribute.Remove", options=["-R", "last"])
    flow.actors.append(flter)

    rename = RenameRelation()
    rename.config["name"] = "iris-reduced"
    flow.actors.append(rename)

    dumper = InstanceDumper()
    dumper.config["output"] = tempfile.gettempdir() + os.sep + "out.arff"
    flow.actors.append(dumper)

    # 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()
开发者ID:fracpete,项目名称:python-weka-wrapper-examples,代码行数:46,代码来源:dump_instances.py


示例12: main

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

    # setup the flow
    helper.print_title("build and save clusterer")
    iris = helper.get_data_dir() + os.sep + "iris_no_class.arff"

    flow = Flow(name="build and save clusterer")

    filesupplier = FileSupplier()
    filesupplier.config["files"] = [iris]
    flow.actors.append(filesupplier)

    loaddataset = LoadDataset()
    flow.actors.append(loaddataset)

    train = Train()
    train.config["setup"] = Clusterer(classname="weka.clusterers.SimpleKMeans")
    flow.actors.append(train)

    pick = ContainerValuePicker()
    pick.config["value"] = "Model"
    flow.actors.append(pick)

    console = Console()
    pick.actors.append(console)

    writer = ModelWriter()
    writer.config["output"] = str(tempfile.gettempdir()) + os.sep + "simplekmeans.model"
    flow.actors.append(writer)

    # 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()
开发者ID:fracpete,项目名称:python-weka-wrapper3-examples,代码行数:44,代码来源:build_save_clusterer.py


示例13: incremental

def incremental():
    """
    Just runs some example code.
    """
    """
    Loads/filters a dataset incrementally.
    """

    # setup the flow
    helper.print_title("Filter datasets (incrementally)")
    iris = helper.get_data_dir() + os.sep + "iris.arff"
    anneal = helper.get_data_dir() + os.sep + "anneal.arff"

    flow = Flow(name="filter datasets (incrementally)")

    filesupplier = FileSupplier()
    filesupplier.config["files"] = [iris, anneal]
    flow.actors.append(filesupplier)

    loaddataset = LoadDataset()
    loaddataset.config["incremental"] = True
    flow.actors.append(loaddataset)

    flter = Filter()
    flter.config["setup"] = filters.Filter(
        classname="weka.filters.unsupervised.attribute.Remove", options=["-R", "1"])
    flter.config["keep_relationname"] = True
    flow.actors.append(flter)

    console = Console()
    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()
开发者ID:fracpete,项目名称:python-weka-wrapper3-examples,代码行数:43,代码来源:filter_datasets.py


示例14: main

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

    # setup the flow
    helper.print_title("Cross-validate clusterer")
    iris = helper.get_data_dir() + os.sep + "iris.arff"

    flow = Flow(name="cross-validate clusterer")

    filesupplier = FileSupplier()
    filesupplier.config["files"] = [iris]
    flow.actors.append(filesupplier)

    loaddataset = LoadDataset()
    flow.actors.append(loaddataset)

    flter = Filter()
    flter.name = "Remove class"
    flter.config["filter"] = filters.Filter(
        classname="weka.filters.unsupervised.attribute.Remove", options=["-R", "last"])
    flow.actors.append(flter)

    cv = CrossValidate()
    cv.config["setup"] = Clusterer(classname="weka.clusterers.EM")
    flow.actors.append(cv)

    console = Console()
    console.config["prefix"] = "Loglikelihood: "
    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()
开发者ID:fracpete,项目名称:python-weka-wrapper-examples,代码行数:43,代码来源:crossvalidate_clusterer.py


示例15: main

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()
开发者ID:fracpete,项目名称:python-weka-wrapper3-examples,代码行数:42,代码来源:conversions.py


示例16: main

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

    # setup the flow
    flow = Flow(name="stopping the flow")

    outer = ForLoop()
    outer.config["max"] = 10
    flow.actors.append(outer)

    ssv = SetStorageValue()
    ssv.config["storage_name"] = "current"
    flow.actors.append(ssv)

    tee = Tee()
    tee.config["condition"] = "@{current} == 7"
    flow.actors.append(tee)

    stop = Stop()
    tee.actors.append(stop)

    console = Console()
    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()
开发者ID:fracpete,项目名称:python-weka-wrapper3-examples,代码行数:37,代码来源:stop_flow.py


示例17: main

def main():
    """
    Just runs some example code.
    """
    """
    Displays a dataset as matrixplot.
    """

    # setup the flow
    helper.print_title("Matrix plot")
    iris = helper.get_data_dir() + os.sep + "iris.arff"

    flow = Flow(name="matrix plot")

    filesupplier = FileSupplier()
    filesupplier.config["files"] = [iris]
    flow.actors.append(filesupplier)

    loaddataset = LoadDataset()
    flow.actors.append(loaddataset)

    plot = MatrixPlot()
    plot.config["percent"] = 50.0
    flow.actors.append(plot)

    # 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()
开发者ID:fracpete,项目名称:python-weka-wrapper-examples,代码行数:36,代码来源:dataset_matrixplot.py


示例18: main

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

    # setup the flow
    helper.print_title("cluster data")
    iris = helper.get_data_dir() + os.sep + "iris_no_class.arff"
    clsfile = str(tempfile.gettempdir()) + os.sep + "simplekmeans.model"

    flow = Flow(name="cluster data")

    start = Start()
    flow.actors.append(start)

    build_save = Trigger()
    build_save.name = "build and save clusterer"
    flow.actors.append(build_save)

    filesupplier = FileSupplier()
    filesupplier.config["files"] = [iris]
    build_save.actors.append(filesupplier)

    loaddataset = LoadDataset()
    build_save.actors.append(loaddataset)

    ssv = SetStorageValue()
    ssv.config["storage_name"] = "data"
    build_save.actors.append(ssv)

    train = Train()
    train.config["setup"] = Clusterer(classname="weka.clusterers.SimpleKMeans")
    build_save.actors.append(train)

    ssv = SetStorageValue()
    ssv.config["storage_name"] = "model"
    build_save.actors.append(ssv)

    pick = ContainerValuePicker()
    pick.config["value"] = "Model"
    build_save.actors.append(pick)

    console = Console()
    console.config["prefix"] = "built: "
    pick.actors.append(console)

    writer = ModelWriter()
    writer.config["output"] = clsfile
    build_save.actors.append(writer)

    pred_serialized = Trigger()
    pred_serialized.name = "make predictions (serialized model)"
    flow.actors.append(pred_serialized)

    filesupplier = FileSupplier()
    filesupplier.config["files"] = [iris]
    pred_serialized.actors.append(filesupplier)

    loaddataset = LoadDataset()
    loaddataset.config["incremental"] = True
    pred_serialized.actors.append(loaddataset)

    predict = Predict()
    predict.config["model"] = clsfile
    pred_serialized.actors.append(predict)

    console = Console()
    console.config["prefix"] = "serialized: "
    pred_serialized.actors.append(console)

    pred_storage = Trigger()
    pred_storage.name = "make predictions (model from storage)"
    flow.actors.append(pred_storage)

    filesupplier = FileSupplier()
    filesupplier.config["files"] = [iris]
    pred_storage.actors.append(filesupplier)

    loaddataset = LoadDataset()
    loaddataset.config["incremental"] = True
    pred_storage.actors.append(loaddataset)

    predict = Predict()
    predict.config["storage_name"] = "model"
    pred_storage.actors.append(predict)

    console = Console()
    console.config["prefix"] = "storage: "
    pred_storage.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()
#.........这里部分代码省略.........
开发者ID:fracpete,项目名称:python-weka-wrapper-examples,代码行数:101,代码来源:cluster_data.py


示例19: main

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

    # setup the flow
    count = 50
    helper.print_title("build classifier incrementally")
    iris = helper.get_data_dir() + os.sep + "iris.arff"

    flow = Flow(name="build classifier incrementally")

    filesupplier = FileSupplier()
    filesupplier.config["files"] = [iris]
    flow.actors.append(filesupplier)

    initcounter = InitStorageValue()
    initcounter.config["storage_name"] = "counter"
    initcounter.config["value"] = 0
    flow.actors.append(initcounter)

    loaddataset = LoadDataset()
    loaddataset.config["incremental"] = True
    flow.actors.append(loaddataset)

    select = ClassSelector()
    select.config["index"] = "last"
    flow.actors.append(select)

    inccounter = UpdateStorageValue()
    inccounter.config["storage_name"] = "counter"
    inccounter.config["expression"] = "{X} + 1"
    flow.actors.append(inccounter)

    train = Train()
    train.config["setup"] = Classifier(classname="weka.classifiers.bayes.NaiveBayesUpdateable")
    flow.actors.append(train)

    pick = ContainerValuePicker()
    pick.config["value"] = "Model"
    pick.config["switch"] = True
    flow.actors.append(pick)

    tee = Tee(name="output model every " + str(count) + " instances")
    tee.config["condition"] = "@{counter} % " + str(count) + " == 0"
    flow.actors.append(tee)

    trigger = Trigger(name="output # of instances")
    tee.actors.append(trigger)

    getcounter = GetStorageValue()
    getcounter.config["storage_name"] = "counter"
    trigger.actors.append(getcounter)

    console = Console()
    console.config["prefix"] = "# of instances: "
    trigger.actors.append(console)

    console = Console(name="output model")
    tee.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()
开发者ID:keypointt,项目名称:python-weka-wrapper-examples,代码行数:72,代码来源:build_classifier_incrementally.py


示例20: main

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

    # setup the flow
    helper.print_title("Attribute selection")
    iris = helper.get_data_dir() + os.sep + "iris.arff"

    flow = Flow(name="attribute selection")

    filesupplier = FileSupplier()
    filesupplier.config["files"] = [iris]
    flow.actors.append(filesupplier)

    loaddataset = LoadDataset()
    loaddataset.config["incremental"] = False
    flow.actors.append(loaddataset)

    attsel = AttributeSelection()
    attsel.config["search"] = ASSearch(classname="weka.attributeSelection.BestFirst")
    attsel.config["eval"] = ASEvaluation(classname="weka.attributeSelection.CfsSubsetEval")
    flow.actors.append(attsel)

    results = Tee()
    results.name = "output results"
    flow.actors.append(results)

    picker = ContainerValuePicker()
    picker.config["value"] = "Results"
    picker.config["switch"] = True
    results.actors.append(picker)

    console = Console()
    console.config["prefix"] = "Attribute selection results:"
    results.actors.append(console)

    reduced = Tee()
    reduced.name = "reduced dataset"
    flow.actors.append(reduced)

    picker = ContainerValuePicker()
    picker.config["value"] = "Reduced"
    picker.config["switch"] = True
    reduced.actors.append(picker)

    console = Console()
    console.config["prefix"] = "Reduced dataset:\n\n"
    reduced.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()
开发者ID:fracpete,项目名称:python-weka-wrapper3-examples,代码行数:61,代码来源:attribute_selection.py



注:本文中的weka.flow.control.Flow类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python helper.get_data_dir函数代码示例发布时间:2022-05-26
下一篇:
Python filters.Filter类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap