预测函数 return 更少的样本
predict function return less samples
我使用 caret R 包中的训练函数训练模型。当我在有 45 个样本的测试数据中测试模型时,预测函数仅 return 类 的标签仅适用于 43 个样本。我附上了包含测试数据和我的模型的 rda 数据。我感谢您的帮助。
test_data+model
这是我使用的代码:
dim( test_data[,!(colnames(test_data) %in% c('lable')) ])
45 179
dim(predict(mod, test_data[,!(colnames(test_data) %in% c('lable')) ],type="prob"))
43 2
此致
您的数据框中缺少数据:
> pdata = data1[,!(colnames(data1) %in% c('lable')) ]
pdata
有 45 行,但是:
> ok = complete.cases(pdata)
> sum(ok)
[1] 43
只有43个有完整的数据。
哪些行有缺失数据?
> rownames(pdata[!ok,])
[1] "GSM1388233" "GSM1388235"
没有给出警告,因为文档说:
## S3 method for class 'train'
predict(object, newdata = NULL, type = "raw",
na.action = na.omit, ...)
这表示忽略任何缺少数据的行 - 默默地。
我使用 caret R 包中的训练函数训练模型。当我在有 45 个样本的测试数据中测试模型时,预测函数仅 return 类 的标签仅适用于 43 个样本。我附上了包含测试数据和我的模型的 rda 数据。我感谢您的帮助。 test_data+model
这是我使用的代码:
dim( test_data[,!(colnames(test_data) %in% c('lable')) ])
45 179
dim(predict(mod, test_data[,!(colnames(test_data) %in% c('lable')) ],type="prob"))
43 2
此致
您的数据框中缺少数据:
> pdata = data1[,!(colnames(data1) %in% c('lable')) ]
pdata
有 45 行,但是:
> ok = complete.cases(pdata)
> sum(ok)
[1] 43
只有43个有完整的数据。
哪些行有缺失数据?
> rownames(pdata[!ok,])
[1] "GSM1388233" "GSM1388235"
没有给出警告,因为文档说:
## S3 method for class 'train'
predict(object, newdata = NULL, type = "raw",
na.action = na.omit, ...)
这表示忽略任何缺少数据的行 - 默默地。