Python 保存模型的结果

Python 保存模型的结果,python,save,lstm,resultset,autoencoder,Python,Save,Lstm,Resultset,Autoencoder,我使用lstm应用了自动编码器,并尝试将预测结果保存在csv文件中。 如何将autoencouder lstm的结果与原始数据集一起保存在csv文件中 #Removing timesteps in prediction result prediction_result = [] prediction_input = [] for i in range(len(prediction_sequence)): prediction_input.append(X_test_sequence[i,

我使用lstm应用了自动编码器,并尝试将预测结果保存在csv文件中。 如何将autoencouder lstm的结果与原始数据集一起保存在csv文件中

#Removing timesteps in prediction result
prediction_result = []
prediction_input = []
for i in range(len(prediction_sequence)):
    prediction_input.append(X_test_sequence[i, 0, :])
    prediction_result.append(prediction_sequence[i, 0, :])
prediction_input, prediction_result = np.array(prediction_input), np.array(prediction_result)

reconstruction_error = []
for i in range(len(prediction_result)):
    current_record = []
    for j in range(len(prediction_result[0])):
        current_record.append(np.mean(np.power(prediction_input[i, j] - prediction_result[i, j], 2)))
    reconstruction_error.append(np.array(current_record))
outputFileName = "ReconstructionError_" + modelName + ".csv"
np.savetxt(outputFileName, np.array(reconstruction_error), delimiter=',', fmt="%s" )
print("Your file has been saved in thsi same folder under the name : " + outputFileName)

                                      
from sklearn.metrics import roc_curve, auc
import matplotlib.pyplot as plt
import pandas as pd

data = pd.DataFrame(X_test[0:_nSamplesPred-_nTimesteps, :])
data_n = pd.DataFrame(X_test)
data_n = data_n.astype('float32')

dist = np.zeros(_nSamplesPred-_nTimesteps)
for i, x in enumerate(data_n.iloc[0:_nSamplesPred-_nTimesteps, :].values):
    dist[i] = np.linalg.norm(prediction_result[i, :])