[R] kernlab ksvm rbfdot kernel - prediction returning fewer rows than provided for input

Tom Woolman twoo|m@n @end|ng |rom ont@rgettek@com
Thu Jun 11 00:49:18 CEST 2020

Hi everyone. I'm using the kernlab ksvm function with the rbfdot  
kernel for a binary classification problem and getting a strange  
result back. The predictions seem to be very accurate judging by the  
training results provided by the algorithm, but I'm unable to generate  
a confusion matrix because there is a difference in the number of  
output records from my model test compared to what was input into the  
test dataframe.

I've used ksvm before but never had this problem.

Here's my sample code:



trainIndex <-  

train <- dataset_labeled_fraud[trainIndex,]
test <- dataset_labeled_fraud[-trainIndex,]

#clear out the training model
filter <- NULL

filter <-  

#clear out the test results
test_pred_rbfdot <- NULL

test_pred_rbfdot <- kernlab::predict(filter,test,type="probabilities")

dataframe_test_pred_rbfdot <- as.data.frame(test_pred_rbfdot)


> 23300


> 24408

# ok, how did I go from 24408 input rows to only 23300 output  
prediction rows? :(

Thanks in advance anyone!

Thomas A. Woolman
PhD Candidate, Technology Management
Indiana State University

More information about the R-help mailing list