What is the main goal of a Support Vector Machine (SVM)?
The main goal of an SVM is to find the best boundary (called a hyperplane) that separates different groups (classes) in the data with the largest possible margin.
Click to reveal answer
beginner
What is a 'margin' in the context of SVM?
The margin is the distance between the hyperplane and the closest data points from each class. SVM tries to maximize this margin to improve the model's ability to generalize.
Click to reveal answer
beginner
What are 'support vectors' in SVM?
Support vectors are the data points closest to the hyperplane. They are critical because they define the position and orientation of the hyperplane.
Click to reveal answer
intermediate
How does SVM handle data that is not linearly separable?
SVM uses a technique called the 'kernel trick' to transform data into a higher dimension where it can be separated by a hyperplane, even if it is not separable in the original space.
Click to reveal answer
intermediate
What is the role of the 'C' parameter in SVM?
The 'C' parameter controls the trade-off between having a wide margin and correctly classifying training points. A small C allows more misclassifications but a wider margin, while a large C tries to classify all points correctly but may have a smaller margin.
Click to reveal answer
What does SVM try to maximize when finding the best hyperplane?
AThe training data size
BThe number of support vectors
CThe number of features
DThe margin between classes
✗ Incorrect
SVM aims to maximize the margin, which is the distance between the hyperplane and the nearest data points of each class.
Which points influence the position of the SVM hyperplane?
ARandom points
BAll data points
COnly the support vectors
DPoints farthest from the hyperplane
✗ Incorrect
Only the support vectors, the closest points to the hyperplane, determine its position.
What technique does SVM use to handle non-linear data?
AKernel trick
BGradient descent
CDecision trees
DRandom forests
✗ Incorrect
The kernel trick transforms data into a higher dimension to make it linearly separable.
What happens if the 'C' parameter in SVM is set very high?
AThe model allows more misclassifications
BThe model tries to classify all training points correctly
CThe margin becomes wider
DThe model ignores support vectors
✗ Incorrect
A high 'C' value forces the model to classify all training points correctly, possibly at the cost of a smaller margin.
Which of the following is NOT true about support vectors?
AThey are always misclassified points
BThey define the margin width
CThey are the closest points to the hyperplane
DThey influence the hyperplane position
✗ Incorrect
Support vectors are not necessarily misclassified; they are the closest points to the hyperplane from each class.
Explain in your own words how SVM finds the best boundary to separate two groups.
Think about the line or plane that best divides the groups with the biggest gap.
You got /4 concepts.
Describe how the kernel trick helps SVM deal with data that is not linearly separable.
Imagine bending or stretching the space so groups can be separated by a straight line.
You got /4 concepts.
Practice
(1/5)
1. What is the main goal of a Support Vector Machine (SVM) in machine learning?
easy
A. To cluster data points into groups without labels
B. To reduce the number of features in the dataset
C. To find the best boundary that separates different classes
D. To generate random predictions for data points
Solution
Step 1: Understand SVM's purpose
SVM aims to separate data points into classes by drawing a boundary.
Step 2: Identify the best boundary
SVM finds the boundary (called hyperplane) that maximizes the margin between classes.
Final Answer:
To find the best boundary that separates different classes -> Option C
Quick Check:
SVM goal = best separating boundary [OK]
Hint: SVM separates classes with the widest margin [OK]
Common Mistakes:
Confusing SVM with clustering methods
Thinking SVM reduces features
Believing SVM makes random predictions
2. Which of the following is the correct way to import the SVM classifier from scikit-learn in Python?
The SVM classifier is called SVC and is imported from sklearn.svm as 'from sklearn.svm import SVC'.
Final Answer:
from sklearn.svm import SVC -> Option B
Quick Check:
Correct import = from sklearn.svm import SVC [OK]
Hint: Use 'from sklearn.svm import SVC' to import SVM [OK]
Common Mistakes:
Using wrong import order
Trying to import class directly without module
Using invalid syntax like 'import svm from sklearn'
3. What will be the output of the following Python code using SVM?
from sklearn.svm import SVC
import numpy as np
X = np.array([[0, 0], [1, 1]])
y = [0, 1]
model = SVC(kernel='linear')
model.fit(X, y)
pred = model.predict([[2, 2]])
print(pred)
medium
A. [0]
B. Error
C. [2]
D. [1]
Solution
Step 1: Understand training data and labels
Training points: [0,0] labeled 0 and [1,1] labeled 1.
Step 2: Predict label for [2,2]
[2,2] is closer to class 1 side since it lies beyond [1,1]. So prediction is 1.
Final Answer:
[1] -> Option D
Quick Check:
Point [2,2] predicted class = 1 [OK]
Hint: Points near class 1 get label 1 [OK]
Common Mistakes:
Predicting label 0 for point far from class 0
Expecting error due to small data
Confusing kernel effect on prediction
4. Identify the error in this SVM code snippet:
from sklearn.svm import SVC
X = [[1, 2], [2, 3], [3, 4]]
y = [0, 1]
model = SVC()
model.fit(X, y)
medium
A. Mismatch in number of samples and labels
B. Wrong import statement
C. Kernel parameter missing
D. Predict method not called
Solution
Step 1: Check data and label lengths
X has 3 samples but y has only 2 labels, causing mismatch.
Step 2: Understand fit requirements
fit() requires equal number of samples and labels to train properly.
Final Answer:
Mismatch in number of samples and labels -> Option A
Quick Check:
Samples count != labels count causes error [OK]
Hint: Samples and labels must match in length [OK]
Common Mistakes:
Ignoring length mismatch
Thinking kernel is mandatory
Expecting error without calling predict
5. You have a dataset with two classes that are not linearly separable. Which SVM kernel should you choose to improve classification?
hard
A. RBF (Radial Basis Function) kernel
B. Polynomial kernel
C. Linear kernel
D. Sigmoid kernel
Solution
Step 1: Understand data separability
Non-linearly separable data means a straight line can't separate classes well.
Step 2: Choose kernel for complex boundaries
RBF kernel maps data into higher dimension to separate complex shapes effectively.
Final Answer:
RBF (Radial Basis Function) kernel -> Option A
Quick Check:
Non-linear data needs RBF kernel [OK]
Hint: Use RBF kernel for non-linear data [OK]
Common Mistakes:
Choosing linear kernel for non-linear data
Confusing polynomial and RBF kernels
Ignoring kernel choice impact
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.