Randomforest分类器输出

发布于 2025-02-04 13:42:30 字数 381 浏览 2 评论 0原文

在我的型号打印出输出后,看起来像这样的东西,

id        val
234       0.99
235       0.3
236       0
237       0.92

我希望Val列是二进制的,因此阈值也是如此。

test[test["val"] < 0.5] = 0
test[test["val"] >= 0.5] = 1

阈值后,由于某种原因,我的输出看起来像这样,

id        val
1         1
0         0
0         0
1         1

我该如何确保ID列不会更改?

After my model prints out the output, it looks something like this

id        val
234       0.99
235       0.3
236       0
237       0.92

i wanted the val column to be binary, so did thresholding.

test[test["val"] < 0.5] = 0
test[test["val"] >= 0.5] = 1

after thresholding, for some reason my output looks like this

id        val
1         1
0         0
0         0
1         1

how do i make sure the id column doesn't change?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

仄言 2025-02-11 13:42:30

您提供的条件仅给出应更改的行。使用loc,并提供应更改的列。

test.loc[test["val"] < 0.5, "val"] = 0
test.loc[test["val"] >= 0.5, "val"] = 1

输出:

    id  val
0  234  1.0
1  235  0.0
2  236  0.0
3  237  1.0

The condition you're providing only gives the rows that should change. Use loc and provide the column that should change as well.

test.loc[test["val"] < 0.5, "val"] = 0
test.loc[test["val"] >= 0.5, "val"] = 1

Output:

    id  val
0  234  1.0
1  235  0.0
2  236  0.0
3  237  1.0
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文