# 加载数据 X = data.iloc[:, :-1].values y = data.iloc[:, -1:].values X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42) data_pred = pd.read_excel(r'C:\Users\Lenovo\Desktop\data.xlsx') # 训练模型 input_dim=13 hidden_dim=25 output_dim=1 nn=NeuralNetwork(input_dim, hidden_dim, output_dim) learning_rate=0.0016 num_epochs=2000 loss_history=nn.train(X, y, learning_rate, num_epochs) plt.plot(loss_history) plt.title('loss') plt.xlabel('Epoch') plt.ylabel('MSE')根据此代码续写预测代码
时间: 2024-03-29 22:41:03 浏览: 61
Keras 加载已经训练好的模型进行预测操作
# 预测代码
# 将数据预处理后进行预测
data_pred = data_pred.iloc[:, :-1].values
data_pred = (data_pred - np.mean(data_pred, axis=0)) / np.std(data_pred, axis=0)
y_pred = nn.forward(data_pred)
y_pred = y_pred * np.std(y_train) + np.mean(y_train)
print(y_pred)
阅读全文