当前位置: 首页>>代码示例>>Python>>正文


Python Evaluation.rootMeanSquaredError方法代码示例

本文整理汇总了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()
开发者ID:RayMick,项目名称:cs7641-weka-jython,代码行数:32,代码来源:j48_tree_tunable.py

示例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()
开发者ID:RayMick,项目名称:cs7641-weka-jython,代码行数:32,代码来源:k_nearest_neighbor_tunable.py


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