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()
def main(): """ Just runs some example code. """ # setup the flow count = 50 helper.print_title("build clusterer incrementally") iris = helper.get_data_dir() + os.sep + "iris.arff" flow = Flow(name="build clusterer 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) remove = Filter(name="remove class attribute") remove.config["setup"] = filters.Filter( classname="weka.filters.unsupervised.attribute.Remove", options=["-R", "last"]) flow.actors.append(remove) inccounter = UpdateStorageValue() inccounter.config["storage_name"] = "counter" inccounter.config["expression"] = "{X} + 1" flow.actors.append(inccounter) train = Train() train.config["setup"] = Clusterer(classname="weka.clusterers.Cobweb") 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()
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()