from Network import Model import numpy as np '''原Interface''' data = np.loadtxt('./data/data.csv', delimiter=',', skiprows=2)[:, 1: 7] # 创建 Model, stride就是代表历史长度,通过更改model.stride就可以实现对模型的选择 # 例如: model.stride = n(n的取值范围5,10,15,20,25,30,35,40,45,50) model = Model(stride=30) #全连接神经网络 模型预测 # data_x是输入,输入的尺寸是(n, 6),n是数据的个数 model.stride = 25 data_x = data[-25:, :] # data_y是输出的预测的结果,输出的矩阵的形状是(n, 4), n是数据的个数 data_y = model.predict_LSTM(data_x) print(data_y) # LSTM 模型预测 # data_x是输入,输入的矩阵形状是(n,stride*6) stride是步长,n是数据的个数 #data_x = [[1,2,3,4,5,6],[1,2,3,4,5,6],[1,2,3,4,5,6],[1,2,3,4,5,6],[1,2,3,4,5,6]] # data_y是输出的预测的结果,输出的矩阵的形状是(4,n), n是数据的个数 #model.stride = 5 data_y = model.predict_Net(data_x) print(type(data_y[0])) ############################################ T_len, H2_len, CH4_len, CO_len = 5,10,5,20
from Network import Model from PSO import optimize from InputParam import InputParam import numpy as np import time data = np.loadtxt('./data/data.csv', delimiter=',', skiprows=2)[:, 1:7] model = Model(stride=30) param = InputParam() best_x = [[28.12421607, 14.41792793], [74.20071455, 9.92461491], [58.43944117, 11.0825983], [69.17058085, 10.75863371], [36.35079316, 11.28547075], [57.59862793, 10.92375781], [27.67301199, 14.30238826], [75.87876121, 13.22701089], [100.0, 16.10638031], [100.0, 13.78599625]] best_y = 26.45409999049893 # 调用optimize #best_x, best_y = optimize(20, data, 2, model, param) print('best_x = ', best_x) print('best_y = ', best_y) model.stride = 10 predict_y = model.predict_Net(best_x) print(predict_y)