Support Vector Machine (SVM)
Train Support Vector Machine (SVM) to predict categorical outcomes
Finds the optimal hyperplane that separates classes with maximum margin.
When to use:
- Small to medium datasets
- High-dimensional data (many features)
- Clear margin between classes
- Need robust decision boundary
Strengths: Effective in high dimensions, memory efficient, versatile kernels Weaknesses: Slow on large datasets, sensitive to feature scaling, many hyperparameters
Model Parameters
C (default: 1.0) Regularization parameter. Controls trade-off between smooth boundary and classification accuracy.
- Low (0.01-0.1): Smooth boundary, may underfit
- Default (1.0): Balanced
- High (10-100): Tight boundary, may overfit
Kernel Transformation function:
- rbf: Radial basis function (default, handles non-linear)
- linear: For linearly separable data (faster)
- poly: Polynomial kernel (flexible but slow)
- sigmoid: Similar to neural network activation
Gamma Kernel coefficient for rbf/poly/sigmoid:
- scale: 1 / (n_features * X.var()) (default)
- auto: 1 / n_features
- Custom value: Higher = more complex boundary
Degree (for poly kernel) Polynomial degree (default: 3).
Class Weight
- None: Treat all classes equally
- Balanced: Adjust for imbalanced classes
Random State (default: 42) Seed for reproducibility.