Like many predictive model, SVM will output probability scores and the apply threshold to probability to convert it into positive or negative labels.
As, @Sycorax mentioned in comment, you can adjust the cut-off threshold to adjust the trade-off between false positive and false negative.
Here is some example in R.
library(kernlab)
library(mlbench)
graphics.off()
set.seed(0)
d=mlbench.2dnormals(500)
plot(d)
# using 2nd order polynominal expansion
svp <- ksvm(d$x,d$classes,type="C-svc",kernel="polydot",
kpar=list(degree=2),C=10,prob.model=T)
plot(svp)
p=predict(svp,d$x, type="prob")[,1]
cut_off=0.5
caret::confusionMatrix(d$classes,ifelse(p<cut_off,2,1))
cut_off=0.8
caret::confusionMatrix(d$classes,ifelse(p<cut_off,2,1))
Note when we change cut_off
, the confusion matrix (false postive, false negative etc.) changes
> caret::confusionMatrix(d$classes,ifelse(p<cut_off,2,1))
Confusion Matrix and Statistics
Reference
Prediction 1 2
1 253 16
2 38 193
Accuracy : 0.892
95% CI : (0.8614, 0.9178)
No Information Rate : 0.582
P-Value [Acc > NIR] : < 2.2e-16
Kappa : 0.7813
Mcnemar's Test P-Value : 0.004267
Sensitivity : 0.8694
Specificity : 0.9234
Pos Pred Value : 0.9405
Neg Pred Value : 0.8355
Prevalence : 0.5820
Detection Rate : 0.5060
Detection Prevalence : 0.5380
Balanced Accuracy : 0.8964
'Positive' Class : 1
> cut_off=0.8
> caret::confusionMatrix(d$classes,ifelse(p<cut_off,2,1))
Confusion Matrix and Statistics
Reference
Prediction 1 2
1 223 46
2 10 221
Accuracy : 0.888
95% CI : (0.857, 0.9143)
No Information Rate : 0.534
P-Value [Acc > NIR] : < 2.2e-16
Kappa : 0.7772
Mcnemar's Test P-Value : 2.91e-06
Sensitivity : 0.9571
Specificity : 0.8277
Pos Pred Value : 0.8290
Neg Pred Value : 0.9567
Prevalence : 0.4660
Detection Rate : 0.4460
Detection Prevalence : 0.5380
Balanced Accuracy : 0.8924
'Positive' Class : 1