what is the purpose of the ‘c’ hyperparameter in svm? in python

The hyperparameter 'C' in SVM (Support Vector Machine) is used to control the trade-off between having a smooth decision boundary and classifying the training points correctly.

Here is an example of how 'C' hyperparameter can be used in the SVC (Support Vector Classification) function in Python from the scikit-learn library:

main.py
from sklearn import svm

# Create an SVM classifier with a specific value of C
clf = svm.SVC(C=1.0)
100 chars
5 lines

In this example, the 'C' hyperparameter is set to 1.0, but you can experiment with different values to see how it affects the model's performance. A smaller value of 'C' allows for a softer margin, potentially increasing the bias but reducing the variance, whereas a larger value of 'C' enforces a harder margin, potentially overfitting the data.


gistlibby LogSnag