首页 > 解决方案 > 在数据帧中打印多层感知器 ANN 预测值

问题描述

我是张量流的初学者,需要将预测值(如果客户是否订阅定期存款)作为多感知 ANN 模型的输出(以数据框格式),对于给定的数据框作为输入。银行活动.. 我们指的是这个示例 https://github.com/ManikandanJeyabal/Workplace/blob/master/ANN/TensorFlow/BankMarketing.py

我们尝试在带有 Python 3.6 的 Azure 虚拟机上的笔记本中运行它

在上面的示例中,我们需要修改下面的源代码以获得预测(以数据框的形式,以便它可以显示为报告。)

plt.plot(mse_his, 'r')
plt.show()
plt.plot(accu_his)
plt.show()

# print the final accuracy
correct_pred = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))
accuracy = tf.reduce_mean(tf.cast(correct_pred, tf.float32))
print("Test Accuracy--> ", (sess.run(accuracy, feed_dict={x: x_test, y_: y_test})))

# print final mean square error
pred_y = sess.run(y, feed_dict={x: x_test})
mse = tf.reduce_mean(tf.square(pred_y - y_test))
print("MSE: %.4f" % sess.run(mse))
print(correct_pred)


print(y_test)  ```

we need to get the output in the form of panadas dataframe along with the predicted columns?

Please guide me here

----------------------------------------------
Updates:
Thank you for the response,McAngus.. 
After the changes in comments below.. I could render the dataframe output but with this output , How can I derive True or False Predicted Value?
[Dataframe Output][1]


  [1]: https://i.stack.imgur.com/f8iJ9.png

标签: tensorflowmachine-learningneural-network

解决方案


如果我理解正确,您希望将结果放入数据框中。从这里你可以pd.DataFrame.from_dict像这样使用:

pd.DataFrame.from_dict({"target": y_test.tolist(), "prediction": pred_y.tolist()})

这将给出列标题targetprediction.


推荐阅读