Support Vector Machine - Can't create an additional predicted value for my data set


#1

I have created two models, one using logistic regression the other using support vector machine. I'll show you what I did for logistic regression, no problems, and then with support vector machine, problems.

Logistic regression - No problem

glm.fit=glm(claim~Auto+Elect_Photo+Groceries+Industrial_Durable+ Others+Restaurant+Retail_Clothing+Retail_Discount+Retail_Materials+Retail_Specialty+amt2+flag_cat30+flag_state30+ merchants,data=fraud.train.visa,family=binomial)
 fraud.train.visa$pred_fraud_log<-predict(glm.fit,newdata=fraud.train.visa,type="response")

Support Vector Machine: - No Problem with svm running, but when I try to create predicted value get errors.

Svm.fit=svm(claim~Auto+Elect_Photo+Groceries+Industrial_Durable+Others+Restaurant+Retail_Clothing+Retail_Discount+Retail_Materials+Retail_Specialty+amt2+flag_cat30+flag_state30+merchants,
 data=fraud.train.visa,kernel="radial",gamma=1,cost=1)

fraud.validate.visa$pred_fraud_SVM<-predict(Svm.fit,newdata=fraud.validate.visa,type="response")
Error in $<-.data.frame(*tmp*, "pred_fraud_SVM", value = numeric(0)) :
 replacement has 0 rows, data has 32815

Thanks


#2

It's difficult to tell what the issue might be since we cannot reproduce the analysis.

To copy from @mara:

Could you please turn this into a self-contained reprex (short for reproducible example)? It will help us help you if we can be sure we're all working with/looking at the same stuff.

install.reprex("reprex")

If you've never heard of a reprex before, you might want to start by reading the tidyverse.org help page. The reprex dos and don'ts are also useful.

What to do if you run into clipboard problems

If you run into problems with access to your clipboard, you can specify an outfile for the reprex, and then copy and paste the contents into the forum.

reprex::reprex(input = "fruits_stringdist.R", outfile = "fruits_stringdist.md")

For pointers specific to the community site, check out the reprex FAQ, linked to below.