将任何 sklearn 结果映射回原始数据帧 [英] mapping back any sklearn result to the original dataframe

查看:61
本文介绍了将任何 sklearn 结果映射回原始数据帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以原始测试数据为参考,在excel中分析我的随机森林结果的预测值.

I'd like to analyze the predicted values of my random forest results in excel with the original test data as a reference.

当我使用这个时,预测结果出现在一个数组中:

The predicted result comes in an array as i use this:

predict = rf.predict(test[columns])

如何使用 Pandas 将预测结果映射回原始数据集?

how do I map back the predicted results to the original dataset using pandas?

问候,加里耶

推荐答案

EdChum 回答了这个问题.

EdChum's answered the question.

(编辑)他的回答:

您应该能够将其添加回新列:test['prediction'] = rf.predict(test[columns])

You should be able to just add this back as a new column: test['prediction'] = rf.predict(test[columns])

我为延迟道歉.

问候,苏尼尔

这篇关于将任何 sklearn 结果映射回原始数据帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆