2
$\begingroup$

I am working on lead scoring classification problem, wherein the model i am building would help highlight the customers likely to purchase based on their online activity. Below is the brief snapshot of the data i have:

'data.frame':   889 obs. of  20 variables:
 $ daysInSystem        : num  142 86 102 1 1 153 131 1 1 1 ...
 $ sessionCount        : num  25 1 6 1 1 1 12 1 1 2 ...
 $ maxSessionDuration  : num  2687 105 258 223 1821 ...
 $ totalSessionDuration: num  19059 105 319 223 1821 ...
 $ usedCarPageCount    : num  2 0 0 4 3 2 5 0 0 0 ...
 $ Model.Page.count    : num  155 2 22 1 5 0 40 15 5 7 ...
 $ Variant.Page.count  : num  31 0 0 1 0 0 4 0 0 7 ...
 $ OEM.Page.count      : num  0 0 0 0 0 0 0 0 0 0 ...
 $ OEMCount            : num  11 1 2 1 1 0 3 2 1 1 ...
 $ modelCount          : num  33 1 3 1 1 0 7 10 1 1 ...
 $ carVariantLeadCount : num  45 1 0 1 1 0 1 3 0 0 ...
 $ ORP_LC              : num  49 1 3 4 7 2 10 7 2 1 ...
 $ UPCOMING_ALERT_LC   : num  0 0 0 0 0 0 0 0 0 0 ...
 $ BROCHURE_LC         : num  0 0 0 0 0 0 0 0 0 0 ...
 $ DCB_LC              : num  0 0 0 0 1 0 0 0 0 0 ...
 $ OFFER_LC            : num  0 0 0 0 0 0 0 0 0 0 ...
 $ RECOMENDATION_LC    : num  0 0 0 0 0 0 0 0 0 0 ...
 $ distinctModels      : num  19 3 2 3 4 1 7 5 1 1 ...
 $ distinctBrands      : num  9 2 2 3 3 1 3 5 1 1 ...
 $ TR                  : Factor w/ 2 levels "0","1": 1 1 1 1 1 1 1 1 1 1 ...

"TR" is my dependent or class variable. I am trying to use SVM to create a classification model using e1071 package. Following are codes i am using:

> svm_train <- svm(TR ~ ., data = train_randomsmote, kernel = 'linear', cost = 1)
> svm_train

Call:
svm(formula = TR ~ ., data = train_randomsmote, kernel = "linear", cost = 1)


Parameters:
   SVM-Type:  C-classification 
 SVM-Kernel:  linear 
       cost:  1 
      gamma:  0.05263158 

Number of Support Vectors:  621

> tune.out <- tune(svm, TR~ ., data = train_randomsmote, kernel = 'linear', ranges = list(cost = c(.001,0.01,0,1,5,10,100)))
Error in svm.default(x, y, scale = scale, ..., na.action = na.action) : 
  C <= 0!

My Question is what is the meaning of the error - Error in svm.default(x, y, scale = scale, ..., na.action = na.action) : C <= 0! - and is there any way to solve this. I know C pertains to cost, and is used to indicate the distance between between two classes. But i am not able to understand the error.

Let me know if more details is required. I cannot share the data.

$\endgroup$
1
  • $\begingroup$ The error means what it says. Your list of cost parameters includes 0. To fix the error, don't include 0. $\endgroup$
    – Sycorax
    Nov 8 '18 at 15:16
4
$\begingroup$

The cost parameter ($C$) in an SVM places an upper bound on the norm of the weights. It is a regularisation parameter, where lower means more regularised and greater means less regularised.

Low $C$ means the norm of the weights has to be very small, leading to a simpler model. High $C$ is the opposite. $C=0$ would imply that the norm of the weights must be zero and that there is no model at all, and so svm throws an error. You have a 0 in your gridsearch.

tune.out <- tune(svm, TR~ ., 
                 data = train_randomsmote, 
                 kernel = 'linear', 
                 ranges = list(cost = c(.001,0.01,0,1,5,10,100)))
# Right here -------------------------------------^
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.