#3 print('\n#3,绘制对比曲线图') df2 = pd.DataFrame() df2['xopen'] = df['xopen'] df2['open2'] = df['open2'] print(df2.tail()) df3 = df2.tail(200) df3.plot(rot=15) #4 print('\n#4,计算预测结果') df5 = pd.DataFrame() df5['y_test'] = df2['xopen'] df5['y_pred'] = df2['open2'] a1, df5x = ztq.ai_acc_xed2x(df5['y_test'], df5['y_pred'], ky0=5) print(df5x.tail()) print('\na1,', a1) a1, df5x, a20 = ztq.ai_acc_xed2ext(df5['y_test'], df5['y_pred'], ky0=5) print('\na20,', a20) ''' n_df9,3671,n_dfk,3655 acc-kok: 99.56%, MAE:42.65, MSE:2463.18, RMSE:49.63 y_test y_pred ysub ysub2 y_test_div ysubk date 2017-04-25 3132.918 3185.180 -52.262 52.262 3132.918 1.668 2017-04-26 3131.350 3191.560 -60.210 60.210 3131.350 1.923 2017-04-27 3144.022 3203.079 -59.057 59.057 3144.022 1.878 2017-04-28 3147.228 3205.589 -58.361 58.361 3147.228 1.854
print('\n#3,xed.train.数据') df_train = df.head(dnum2) df_test = df.tail(dnum - dnum2) # x_train, y_train = df_train['x'].values, df_train['y'].values x_test, y_test = df_test['x'].values, df_test['y'].values print('train,', x_train[0], y_train[0]) #4 print('\n#4,model建立神经网络模型') model = zks.mlp01() model.summary() # model.compile(loss='mse', optimizer='sgd', metrics=['accuracy']) # model.save('tmp/mlp01.dat') #5 模型训练 print('\n#5 模型训练 fit') mx = load_model('tmp/mlp01.dat') mx.fit(x_train, y_train, epochs=200, batch_size=128) # mx.save('tmp/mlp02x.dat') #6 整理预测数据 print('\n#6 整理预测数据 ') y_pred = mx.predict(x_test) df_test['y_pred'] = zdat.ds4x(y_pred, df_test.index, True) dacc, _ = ztq.ai_acc_xed2x(df_test.y, df_test['y_pred'], 5, False) print('acc:', dacc)