本文整理汇总了Python中wekaexamples.helper.print_title函数的典型用法代码示例。如果您正苦于以下问题:Python print_title函数的具体用法?Python print_title怎么用?Python print_title使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_title函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main():
"""
Just runs some example code.
"""
classifier = Classifier("weka.classifiers.trees.J48")
helper.print_title("Capabilities")
capabilities = classifier.capabilities
print(capabilities)
# load a dataset
iris_file = helper.get_data_dir() + os.sep + "iris.arff"
helper.print_info("Loading dataset: " + iris_file)
loader = Loader("weka.core.converters.ArffLoader")
iris_data = loader.load_file(iris_file)
iris_data.class_is_last()
data_capabilities = Capabilities.for_instances(iris_data)
print(data_capabilities)
print("classifier handles dataset: " + str(capabilities.supports(data_capabilities)))
# disable/enable
helper.print_title("Disable/Enable")
capability = Capability(member="UNARY_ATTRIBUTES")
capabilities.disable(capability)
capabilities.min_instances = 10
print("Removing: " + str(capability))
print(capabilities)
开发者ID:fracpete,项目名称:python-weka-wrapper3-examples,代码行数:28,代码来源:capabilities.py
示例2: 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
示例3: gridsearch
def gridsearch():
"""
Applies GridSearch to a dataset. GridSearch package must be not be installed, as the monolithic weka.jar
already contains this package.
"""
helper.print_title("GridSearch")
# load a dataset
fname = helper.get_data_dir() + os.sep + "bolts.arff"
helper.print_info("Loading train: " + fname)
loader = Loader(classname="weka.core.converters.ArffLoader")
train = loader.load_file(fname)
train.class_is_last()
# classifier
grid = GridSearch(options=["-sample-size", "100.0", "-traversal", "ROW-WISE", "-num-slots", "1", "-S", "1"])
grid.evaluation = "CC"
grid.y = {"property": "kernel.gamma", "min": -3.0, "max": 3.0, "step": 1.0, "base": 10.0, "expression": "pow(BASE,I)"}
grid.x = {"property": "C", "min": -3.0, "max": 3.0, "step": 1.0, "base": 10.0, "expression": "pow(BASE,I)"}
cls = Classifier(
classname="weka.classifiers.functions.SMOreg",
options=["-K", "weka.classifiers.functions.supportVector.RBFKernel"])
grid.classifier = cls
grid.build_classifier(train)
print("Model:\n" + str(grid))
print("\nBest setup:\n" + grid.best.to_commandline())
开发者ID:fracpete,项目名称:python-weka-wrapper-examples,代码行数:27,代码来源:parameter_optimization.py
示例4: 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
示例5: main
def main():
"""
Just runs some example code.
"""
# load a dataset
iris_file = helper.get_data_dir() + os.sep + "iris.arff"
helper.print_info("Loading dataset: " + iris_file)
loader = Loader("weka.core.converters.ArffLoader")
data = loader.load_file(iris_file)
# remove class attribute
data.delete_last_attribute()
# build a clusterer and output model
helper.print_title("Training SimpleKMeans clusterer")
clusterer = Clusterer(classname="weka.clusterers.SimpleKMeans", options=["-N", "3"])
clusterer.build_clusterer(data)
print(clusterer)
# cluster data
helper.print_info("Clustering data")
for index, inst in enumerate(data):
cl = clusterer.cluster_instance(inst)
dist = clusterer.distribution_for_instance(inst)
print(str(index+1) + ": cluster=" + str(cl) + ", distribution=" + str(dist))
开发者ID:fracpete,项目名称:python-weka-wrapper3-examples,代码行数:26,代码来源:cluster_data.py
示例6: main
def main():
"""
Just runs some example code.
"""
helper.print_title("Generate data (Agrawal)")
generator = DataGenerator(
classname="weka.datagenerators.classifiers.classification.Agrawal",
options=["-n", "10", "-r", "agrawal"])
generator.dataset_format = generator.define_data_format()
print(generator.dataset_format)
if generator.single_mode_flag:
for i in xrange(generator.num_examples_act):
print(generator.generate_example())
else:
print(generator.generate_examples())
helper.print_title("Generate data (BayesNet)")
generator = DataGenerator(
classname="weka.datagenerators.classifiers.classification.BayesNet",
options=["-S", "2", "-n", "10", "-C", "10"])
generator.dataset_format = generator.define_data_format()
print(generator.dataset_format)
if generator.single_mode_flag:
for i in xrange(generator.num_examples_act):
print(generator.generate_example())
else:
print(generator.generate_examples())
开发者ID:keypointt,项目名称:python-weka-wrapper-examples,代码行数:28,代码来源:datagenerators.py
示例7: main
def main():
"""
Just runs some example code.
"""
# load a dataset
iris_file = helper.get_data_dir() + os.sep + "iris.arff"
helper.print_info("Loading dataset: " + iris_file)
loader = Loader("weka.core.converters.ArffLoader")
iris_data = loader.load_file(iris_file)
iris_data.class_is_last()
# train classifier
classifier = Classifier("weka.classifiers.trees.J48")
classifier.build_classifier(iris_data)
# save and read object
helper.print_title("I/O: single object")
outfile = tempfile.gettempdir() + os.sep + "j48.model"
serialization.write(outfile, classifier)
model = Classifier(jobject=serialization.read(outfile))
print(model)
# save classifier and dataset header (multiple objects)
helper.print_title("I/O: single object")
serialization.write_all(outfile, [classifier, Instances.template_instances(iris_data)])
objects = serialization.read_all(outfile)
for i, obj in enumerate(objects):
helper.print_info("Object #" + str(i+1) + ":")
if javabridge.get_env().is_instance_of(obj, javabridge.get_env().find_class("weka/core/Instances")):
obj = Instances(jobject=obj)
elif javabridge.get_env().is_instance_of(obj, javabridge.get_env().find_class("weka/classifiers/Classifier")):
obj = Classifier(jobject=obj)
print(obj)
开发者ID:fracpete,项目名称:python-weka-wrapper3-examples,代码行数:34,代码来源:serialization.py
示例8: 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
示例9: 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
示例10: 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
示例11: main
def main():
"""
Just runs some example code.
"""
# setup the flow
helper.print_title("Output actor help")
cv = CrossValidate()
cv.config["setup"] = Classifier(classname="weka.classifiers.trees.J48")
cv.print_help()
开发者ID:keypointt,项目名称:python-weka-wrapper-examples,代码行数:11,代码来源:output_actor_help.py
示例12: main
def main():
"""
Just runs some example code.
"""
# load a dataset
bodyfat_file = helper.get_data_dir() + os.sep + "bodyfat.arff"
helper.print_info("Loading dataset: " + bodyfat_file)
loader = Loader("weka.core.converters.ArffLoader")
bodyfat_data = loader.load_file(bodyfat_file)
bodyfat_data.class_is_last()
# classifier help
helper.print_title("Creating help string")
classifier = Classifier(classname="weka.classifiers.trees.M5P")
classifier.build_classifier(bodyfat_data)
print(classifier)
开发者ID:fracpete,项目名称:python-weka-wrapper3-examples,代码行数:17,代码来源:mp5.py
示例13: 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
示例14: 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
示例15: 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
示例16: 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
示例17: 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
示例18: main
def main():
"""
Just runs some example code.
NB: You have to fill in the following parameters to make it work with MySQL:
- HOSTNAME: the database server IP or hostname (or just 'localhost')
- DBNAME: the name of the database to connect to
- DBUSER: the user for connecting to the database
- DBPW: the password for the database user
- TABLE: the table to retrieve the data from
And also supply the correct path to the MySQL jar in the "main" method below.
"""
# retrieve some data
helper.print_title("Loading data from a database")
iquery = InstanceQuery()
iquery.db_url = "jdbc:mysql://HOSTNAME:3306/DBNAME"
iquery.user = "DBUSER"
iquery.password = "DBPW"
iquery.query = "select * from TABLE"
data = iquery.retrieve_instances()
print(data)
开发者ID:fracpete,项目名称:python-weka-wrapper-examples,代码行数:21,代码来源:database.py
示例19: main
def main():
"""
Just runs some example code.
"""
# load ARFF file
helper.print_title("Loading ARFF file")
loader = Loader(classname="weka.core.converters.ArffLoader")
data = loader.load_file(helper.get_data_dir() + os.sep + "iris.arff")
print(str(data))
# load CSV file
helper.print_title("Loading CSV file")
loader = Loader(classname="weka.core.converters.CSVLoader")
data = loader.load_file(helper.get_data_dir() + os.sep + "iris.csv")
print(str(data))
# load directory
# changes this to something sensible
text_dir = "/some/where"
if os.path.exists(text_dir) and os.path.isdir(text_dir):
helper.print_title("Loading directory: " + text_dir)
loader = TextDirectoryLoader(options=["-dir", text_dir, "-F", "-charset", "UTF-8"])
data = loader.load()
print(unicode(data))
开发者ID:fracpete,项目名称:python-weka-wrapper3-examples,代码行数:25,代码来源:converters.py
示例20: main
def main():
"""
Just runs some example code.
"""
# load a dataset
iris_file = helper.get_data_dir() + os.sep + "iris.arff"
helper.print_info("Loading dataset: " + iris_file)
loader = Loader("weka.core.converters.ArffLoader")
full = loader.load_file(iris_file)
full.class_is_last()
# remove class attribute
data = Instances.copy_instances(full)
data.no_class()
data.delete_last_attribute()
# build a clusterer and output model
helper.print_title("Training SimpleKMeans clusterer")
clusterer = Clusterer(classname="weka.clusterers.SimpleKMeans", options=["-N", "3"])
clusterer.build_clusterer(data)
print("done")
# classes to clusters
evl = ClusterEvaluation()
evl.set_model(clusterer)
evl.test_model(full)
helper.print_title("Cluster results")
print(evl.cluster_results)
helper.print_title("Classes to clusters")
print(evl.classes_to_clusters)
开发者ID:fracpete,项目名称:python-weka-wrapper-examples,代码行数:31,代码来源:classes_to_clusters.py
注:本文中的wekaexamples.helper.print_title函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论