【问题标题】:Printing the multi layer Perceptron ANN prediction value in the data frame在数据帧中打印多层感知器 ANN 预测值
【发布时间】:2019-09-28 05:45:34
【问题描述】:

我是张量流的初学者,需要 获取预测值(如果客户将订阅定期存款)作为输出(以数据框格式),用于给定数据框作为输入的多感知 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

【问题讨论】:

    标签: tensorflow machine-learning neural-network


    【解决方案1】:

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

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

    这将为列标题@ 987654324和prediction。

    【讨论】:

    • df = pd.dataframe.from_dict({“target”:y_test,“预测”:predict_y})#dict_test = {“target”:y_test,“预测”:pred_y}#df = pd .dataframe.from_dict(列表(dict_test.items()),列= ['target','prediction'])#df = pd.dataframe.from_dict({“target”:y_test,“预测”:pred_y},东方='index')df.head()。这变成了错误: - >如果使用所有标量值,则必须传递索引 span>
    • 您可能必须将numpy数组转换为列表(我已更新答案)。 span>
    猜你喜欢
    • 2018-10-05
    • 2017-06-28
    • 2017-04-12
    • 2023-03-29
    • 2015-08-14
    • 2018-11-05
    • 2023-03-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多