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:



install.packages("kernlab")
library(kernlab)


set.seed(3233)


trainIndex <- caret::createDataPartition(dataset_labeled_fraud$isFraud, p=0.70,kist=FALSE)

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


#clear out the training model
filter <- NULL

filter <- kernlab::ksvm(isFraud~.,data=train,kernel="rbfdot",kpar=list(sigma=0.5),C=3,prob.model=TRUE)


#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)


nrow(dataframe_test_pred_rbfdot)

23300

nrow(test)

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

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to