【问题标题】:Why is the output of predict a factor with 0 levels?为什么 predict 的输出是 0 水平的因子?
【发布时间】:2015-12-02 21:45:36
【问题描述】:

我使用e1071 生成了一个朴素贝叶斯分类器,然后运行以下内容

test <- as.data.frame(readRDS('ContactsComplaints2014.rds'))
load(file='data2015.nb.RData')
prediction <- predict(data2015.nb,subset(test[1:3000,], select=-c(didComplain)))

在我输入的终端中

&gt; prediction

得到了

factor(0)
Levels:

为什么?

【问题讨论】:

    标签: r naivebayes


    【解决方案1】:

    您需要将要分类的类的名称标记为as.factor()。然后就可以了。

    【讨论】:

    • 为什么我们需要这样做?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-13
    • 2013-11-26
    • 1970-01-01
    • 2021-03-02
    相关资源
    最近更新 更多