def predict(netWork, DS, preData): trainer = BackpropTrainer(netWork, DS, verbose=True, learningrate=0.01) #maxEpochs 即需要的最大收敛迭代次数 trainer.trainUntilConvergence(maxEpochs=1000) #获取预测结果 preValue = n.activate(preData) #设置预测值 if preValue > 0: v = 1 else: v = -1 #将预测结果保存到数据库中 g.save(v, time)
def predict(netWork,DS,preData): trainer = BackpropTrainer(netWork,DS,verbose = True,learningrate = 0.01) #maxEpochs 即需要的最大收敛迭代次数 trainer.trainUntilConvergence(maxEpochs = 1000) #获取预测结果 preValue = n.activate(preData) #设置预测值 if preValue > 0: v = 1 else: v = -1 #将预测结果保存到数据库中 g.save(v,time)
result = {} client = client_factory('CAISO') for day in dayList: temp = getData.get_daily_data(year, month, day, client) if firstIteration: firstIteration = False for category in temp: result[category] = [] # Add one more day in the final result result = getData.concatenate_day(result, temp) time.sleep(1) # Save to csv path = os.path.join(os.path.dirname(__file__), 'csv_result', str(year) + '-' + str(month) + '.csv') getData.write_data_as_csv(result, path) # Plot data plt.figure(figsize=(20, 20), dpi=80) nbPlot = 100 * (len(result) - 1) + 10 for category in result: if not category == 'time': nbPlot += 1 plt.subplot(nbPlot) plt.plot(result['time'], result[category], label=category) plt.xlabel('Time') plt.ylabel('Power (MW)') plt.legend() path = os.path.join(os.path.dirname(__file__), 'graph_result', str(year) + '-' + str(month)) getData.save(path, ext='png', close=True, verbose=True)