tensorflow - 在数据帧中打印多层感知器 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
解决方案
如果我理解正确,您希望将结果放入数据框中。从这里你可以pd.DataFrame.from_dict
像这样使用:
pd.DataFrame.from_dict({"target": y_test.tolist(), "prediction": pred_y.tolist()})
这将给出列标题target
和prediction
.
推荐阅读
- c - 少:使用 execvp() 丢失文件名
- angular - 如何在 Laravel 中更快地加载 Angular 6
- asp.net-core-webapi - Web API .net core 使用 FromQuery 进行属性路由
- arrays - 空手道框架 - 如何计算 json 响应中的数组数量
- php - Laravel 中的 2 条错误消息
- amazon-s3 - 从 S3 Bucket 下载所有对象并将内容发送到 SQS
- sql - 将值拆分为单位、千、百万和十亿到 SQL Server 中的列
- php - Laravel 表单获取非对象
- sql - 检索拥有多于一笔贷款的客户
- soapui - SOAP UI 详细报告