forever
forever

Reputation: 149

predict function return less samples

I train the model using train function in caret R package. When I test the model in my test data which has 45 samples, the predict function only return the label of the classes for only 43 samples. I attached the rda data which contain the test data and my model. I appreciate your help. test_data+model

Here is the code I use:

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

Regards

Upvotes: 0

Views: 161

Answers (1)

Spacedman
Spacedman

Reputation: 94172

You have missing data in your data frame:

> pdata = data1[,!(colnames(data1) %in% c('lable')) ]

pdata has 45 rows, but:

> ok = complete.cases(pdata)
> sum(ok)
[1] 43

only 43 have complete data.

Which rows have missing data?

> rownames(pdata[!ok,])
[1] "GSM1388233" "GSM1388235"

No warning is given because the documentation says:

 ## S3 method for class 'train'
 predict(object, newdata = NULL, type = "raw",
   na.action = na.omit, ...)

which is saying to omit any rows with missing data - silently.

Upvotes: 3

Related Questions