本文整理汇总了Python中dataset.DataSet.load_from_arff方法的典型用法代码示例。如果您正苦于以下问题:Python DataSet.load_from_arff方法的具体用法?Python DataSet.load_from_arff怎么用?Python DataSet.load_from_arff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dataset.DataSet
的用法示例。
在下文中一共展示了DataSet.load_from_arff方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_training_set
# 需要导入模块: from dataset import DataSet [as 别名]
# 或者: from dataset.DataSet import load_from_arff [as 别名]
def load_training_set(self, filename, encoding='UTF-8'):
"""\
Load the given training data set into memory and strip it if
configured to via the train_part parameter.
"""
log_info('Loading training data set from ' + str(filename) + '...')
train = DataSet()
train.load_from_arff(filename, encoding)
if self.train_part < 1:
train = train.subset(0, int(round(self.train_part * len(train))),
copy=False)
return train
示例2: evaluate
# 需要导入模块: from dataset import DataSet [as 别名]
# 或者: from dataset.DataSet import load_from_arff [as 别名]
def evaluate(self, test_file, encoding='UTF-8', classif_file=None):
"""\
Evaluate on the given test data file. Return accuracy.
If classif_file is set, save the classification results to this file.
"""
test = DataSet()
test.load_from_arff(test_file, encoding)
values = self.classify(test)
golden = self.get_classes(test, dtype=None)
if classif_file is not None:
classif = DataSet()
classif.load_from_vect(test.get_attrib(self.class_attr), values)
classif.rename_attrib(self.class_attr, self.PREDICTED)
test.merge(classif)
test.save_to_arff(classif_file, encoding)
return accuracy_score(golden, values)