部分代码:
def data_load():
column_length = 24*6
data = pd.read_csv('data/a.csv').values
row = data.shape[0]
#num_train = int(row * 0.8)
num_train = int(row)-8 #训练集的数目
x_train = data[:num_train, :column_length]
y_train = data[:num_train, -out_size:]
x_test = data[num_train:, :column_length]
y_test = data[num_train:, -out_size:]
ss_X = StandardScaler().fit(x_train)
ss_Y = StandardScaler().fit(y_train)
x_train = ss_X.transform(x_train).reshape(x_train.shape[0], column_length, -1)
y_train = ss_Y.transform(y_train)
x_test = ss_X.transform(x_test).reshape(x_test.shape[0], column_length, -1)
y_test = ss_Y.transform(y_test)
return x_train, y_train, x_test, y_test, ss_Y
#完整代码,见同名公众号
损失:
预测对比