本文整理汇总了Python中Analyzer.Analyzer.createLinearRegressionGraph方法的典型用法代码示例。如果您正苦于以下问题:Python Analyzer.createLinearRegressionGraph方法的具体用法?Python Analyzer.createLinearRegressionGraph怎么用?Python Analyzer.createLinearRegressionGraph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Analyzer.Analyzer
的用法示例。
在下文中一共展示了Analyzer.createLinearRegressionGraph方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Benchmarks
# 需要导入模块: from Analyzer import Analyzer [as 别名]
# 或者: from Analyzer.Analyzer import createLinearRegressionGraph [as 别名]
class Benchmarks(object):
def __init__(self, automaton):
self.exps = []
self.automaton = automaton
self.simulation = Simulation(automaton, False)
self.analyzer = Analyzer(automaton)
self.repeat = 1.0
self.simulation.DEBUG_ITERATIONS = -1
self.directory = "exps"
self.log = False
def setDebug(self,interval):
self.simulation.DEBUG_ITERATIONS = interval
def addExp(self,exp, name):
self.exps.append([name,exp])
def addExps(self,exps):
self.exps += exps
def setRepeat(self,repeat):
self.repeat = repeat
def enableLogScale(self):
self.log = True
def run(self):
"""
Comment for this method
"""
results = []
counter = 0
for exp in self.exps:
experiment = exp[1]
name = exp[0]
counter += 1
arr = []
self.run = types.MethodType(experiment,self,Benchmarks)
innerResult = [0,0,0,0]
for r in range(self.repeat):
self.run()
if r == 0: #to generate data
arr.append(name)
arr.append(repr(self.automaton.rows)+"x"+repr(self.automaton.columns))
arr.append(repr(self.automaton.rmin))
arr.append(repr(self.automaton.rmax))
arr.append(repr(len(self.automaton.getAgents())))
self.analyzer.createLinearRegressionGraph(self.log, save = True, prefixNameFile = self.directory+
"/imgs/figure-"+arr.__str__()+"-repeat-"+str(r))
innerResult = [(x + y) for x, y in zip(innerResult, self.analyzer.getLinearRegressionData(self.log) + [self.simulation.iterations])]
innerResult = [x/self.repeat for x in innerResult]
arr += innerResult
results.append(arr)
print "Finished name:"+name+" ("+str(counter)+ "/" + str(len(self.exps))+")"
self.generateReport(results)
def now(self):
now = datetime.datetime.now()
return now.strftime("%Y-%m-%d-%H-%M").__str__()
def generateReport(self, results):
f = open(self.directory+"/report-"+self.now()+".txt",'w')
text = "Name;Z;rmin;rmax;agents;slope;intercept;r2;inter"
f.write(text+"\n")
for result in results:
text = repr(result[0])+";"+repr(result[1])+";"+repr(result[2])+";"+repr(result[3])+";"
text += repr(result[4])+";"+repr(result[5])+";"+repr(result[6])+";"+repr(result[7])+";"+repr(result[8])
f.write(text+"\n")
f.close()