本文整理汇总了Python中weka.classifiers.Evaluation.rootMeanSquaredError方法的典型用法代码示例。如果您正苦于以下问题:Python Evaluation.rootMeanSquaredError方法的具体用法?Python Evaluation.rootMeanSquaredError怎么用?Python Evaluation.rootMeanSquaredError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weka.classifiers.Evaluation
的用法示例。
在下文中一共展示了Evaluation.rootMeanSquaredError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: range
# 需要导入模块: from weka.classifiers import Evaluation [as 别名]
# 或者: from weka.classifiers.Evaluation import rootMeanSquaredError [as 别名]
# loop for different values of x using full dataset
data.setClassIndex(data.numAttributes() - 1)
for num in [x * 0.05 for x in range(0, 10)]:
log.write("---------------------------------\nCF: " + str(num) + "\n")
algo = J48()
x = time.time()
algo.buildClassifier(data)
log.write("Time to build classifier: " + str(time.time() - x) + "\n")
algo.setConfidenceFactor(num)
evaluation = Evaluation(data)
output = PlainText() # plain text output for predictions
output.setHeader(data)
buffer = StringBuffer() # buffer to use
output.setBuffer(buffer)
attRange = Range() # no additional attributes output
outputDistribution = Boolean(False) # we don't want distribution
x = time.time()
evaluation.evaluateModel(algo, data, [output, attRange, outputDistribution])
#evaluation.crossValidateModel(algo, data, 10, rand, [output, attRange, outputDistribution])
log.write("Time to evaluate model: " + str(time.time() - x) + "\n")
log.write(evaluation.toSummaryString())
file.write(str(num) + "," + str(evaluation.rootMeanSquaredError()) + "\n")
# create graph
graphfilename = "image/" + str(os.path.splitext(os.path.basename(__file__))[0]) + "_" + \
str(os.path.splitext(os.path.basename(sys.argv[1]))[0]) + "_" + str(num) + ".dot"
graphfile = open(graphfilename, 'wb')
graphfile.write(algo.graph())
graphfile.close()
file.close()
log.close()
示例2: CoverTree
# 需要导入模块: from weka.classifiers import Evaluation [as 别名]
# 或者: from weka.classifiers.Evaluation import rootMeanSquaredError [as 别名]
cover = CoverTree()
cover.setDistanceFunction(EuclideanDistance()) # only Euclidean Distance function
tree_algorithms.append(cover)
data.setClassIndex(data.numAttributes() - 1)
for num in range(1,30,2):
file.write(str(num))
for algoknn in tree_algorithms :
log.write("---------------------------------\nK: " + str(num) + ", Search Algorithm: " + algoknn.__class__.__name__ + "\n")
algo = IBk()
algo.setNearestNeighbourSearchAlgorithm(algoknn)
algo.setKNN(num)
x = time.time()
algo.buildClassifier(data)
log.write("Time to build classifier: " + str(time.time() - x) + "\n")
evaluation = Evaluation(data)
output = PlainText() # plain text output for predictions
output.setHeader(data)
buffer = StringBuffer() # buffer to use
output.setBuffer(buffer)
attRange = Range() # no additional attributes output
outputDistribution = Boolean(False) # we don't want distribution
x = time.time()
#evaluation.evaluateModel(algo, data, [output, attRange, outputDistribution])
evaluation.crossValidateModel(algo, data, 10, rand, [output, attRange, outputDistribution])
log.write("Time to evaluate model: " + str(time.time() - x) + "\n")
log.write(evaluation.toSummaryString())
file.write("," + str(evaluation.rootMeanSquaredError()))
file.write("\n")
file.close()
log.close()