Total Pageviews

Thursday, October 1, 2026

🤖 Support Vector Machine (SVM)

🤖 Support Vector Machine (SVM)

Support Vector Machine (SVM) is a supervised machine-learning algorithm used mainly for classification. It can also be used for regression through Support Vector Regression (SVR).

The central idea is to find a decision boundary that separates classes while maintaining an appropriate margin from the nearest observations.

1. What is SVM?

SVM searches for a decision boundary that separates observations belonging to different classes.

Class A Class B Decision Boundary
SVM separates observations using a decision boundary.

2. Hyperplane

The hyperplane is the mathematical decision boundary.

Hyperplane x-axis y
w · x + b = 0

3. Margin

The margin represents the separation between the decision boundary and the closest observations.

Maximum Margin Margin Boundary
Margin = 2 / ||w||

4. Support Vectors

Support vectors are the observations closest to the decision boundary.

Support Vectors Hyperplane

5. Maximum-Margin Principle

Several boundaries may separate the classes. SVM searches for an appropriate boundary with maximum separation from the nearest examples.

Boundary A Maximum-margin boundary

6. Hard Margin SVM

Hard-margin SVM requires the training observations to satisfy the separation constraints.

No training violations

7. Soft Margin SVM

Soft-margin SVM allows some observations to violate the ideal margin.

Violation
Minimize ½ ||w||² + C Σ ξᵢ

8. C Parameter

C controls the penalty associated with margin violations.

Small C Large C Wider tolerance Stricter penalty

9. Linear SVM

Linear SVM uses a straight decision boundary.

Linear Decision Boundary

10. Non-Linear SVM

When a straight line cannot separate the classes effectively, SVM can use a non-linear kernel.

Curved Boundary

11. Kernel Trick

Original Data
→
Kernel
→
Higher Feature Space
→
Linear Separation
Original Space Kernel Feature Space

12. Linear Kernel

K(x,z) = x · z
Vector x Vector z Dot Product

13. Polynomial Kernel

K(x,z) = (γ x · z + r)d
Polynomial Decision Boundary

14. RBF / Gaussian Kernel

K(x,z) = exp(-γ ||x-z||²)
Radial Influence

15. Sigmoid Kernel

K(x,z) = tanh(γ x · z + r)
Sigmoid Curve

16. Gamma Parameter

Low Gamma High Gamma Broader influence Local influence

17. SVM Workflow

Data Preprocess Scale Train SVM Prediction

18. Feature Scaling

SVM models can be affected when features have very different numerical scales.

Before Scaling After Scaling
z = (x - μ) / σ

19. Spam Detection

Email
→
Text Processing
→
TF-IDF
→
SVM
→
Spam / Ham
EMAIL "Win free prize" TF-IDF SVM SPAM

20. Classification Metrics

Accuracy

Correct

Precision

Positive

Recall

21. Confusion Matrix

Predicted Actual True Negative False Positive False Negative True Positive

22. Iris Classification

Setosa Versicolor Virginica

23. Advantages of SVM

📐 Maximum Margin

Uses a margin-based decision principle.

📊 High Dimensions

Can work with high-dimensional feature representations.

🔄 Kernels

Can model non-linear relationships.

📝 Text Data

Useful with sparse text feature representations.

Margin Dimensions Kernels Text

24. Limitations of SVM

Large Data Tuning Scaling
  • Large datasets can increase computational cost.
  • Kernel and hyperparameter selection may require experimentation.
  • Feature scaling is often important.
  • Interpretability may be lower than simple rule-based models.

25. Applications of SVM

SVM Spam Detection Image Classification Medical Data Fraud Detection

26. SVM Classification vs Regression

SVC SVR

27. Important SVM Terminology

SVM Hyperplane Kernel Margin Support Vector

28. Kernel Comparison

Kernel Visual Boundary Main Idea
Linear ──────── Straight boundary
Polynomial ∿∿∿ Polynomial relationship
RBF ◉ Radial similarity
Sigmoid S Sigmoid-shaped relationship

29. Practical SVM Workflow

Dataset Clean Scale Tune Evaluate

30. SVM Parameters at a Glance

SVM C Gamma Degree Kernel

31. SVM Decision Process

Input SVM Model Class

32. Hard Margin vs Soft Margin

Property Hard Margin Soft Margin
Training violations Not allowed Allowed
Slack variables No Yes
Noise tolerance Low Higher
Parameter C Not the main formulation Important
Hard Margin Soft Margin

33. Classification Pipeline

Training Data
→
Feature Engineering
→
Scaling
→
SVM
→
Metrics

34. SVM vs Other Classification Models

SVM Decision Tree KNN Logistic Naive Bayes

35. SVM Mathematical View

w · x + b = 0 -1 boundary +1 boundary
yᵢ(w · xᵢ + b) ≥ 1

36. Support Vector Geometry

Support vector Margin

37. SVM Prediction

New Data Decision Boundary

38. Advantages and Limitations Summary

Advantages ✓ Maximum-margin learning ✓ Kernel support ✓ High-dimensional data Limitations ⚠ Parameter tuning ⚠ Scaling required ⚠ Large-data cost

39. Interview Concept Map

SVM Hyperplane Margin Support Vector Kernel C / Gamma Prediction

40. Complete SVM Concept Diagram

SVM Hyperplane Support Vectors Kernel Margin C / Gamma
Core SVM idea: SVM finds an appropriate separating boundary, identifies the observations that most strongly determine that boundary, and balances margin size with training violations through its optimization parameters.

41. Important Interview Questions

Q1. What is SVM?

A supervised machine-learning algorithm that constructs a decision boundary for classification and can also be extended to regression.

Q2. What is a hyperplane?

A mathematical decision boundary separating observations in feature space.

Q3. What are support vectors?

Observations closest to the decision boundary that strongly influence the fitted SVM boundary.

Q4. What is margin?

The separation between the decision boundary and the nearest observations.

Q5. What is the kernel trick?

A technique that allows SVM to model non-linear relationships using kernel similarity functions.

Q6. What does C do?

C controls the penalty associated with observations violating the desired margin constraints.

Q7. What does gamma do?

Gamma controls the locality of influence for kernels such as RBF.

Q8. Why is scaling important?

Because the geometry used by SVM can be affected when features have very different numerical scales.

No comments:

Post a Comment