Challenge - 5 Problems
SVM Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediateWhat is the main goal of a Support Vector Machine?
In simple terms, what does a Support Vector Machine try to do when it learns from data?
Attempts:
2 left
💡 Hint
Think about drawing a line that keeps groups apart as much as possible.
✗ Incorrect
SVM finds the boundary (called hyperplane) that separates classes with the largest margin, helping it generalize well.
❓ Predict Output
intermediateWhat is the output of this SVM prediction code?
Given this Python code using sklearn's SVM, what will be printed?
ML Python
from sklearn import svm X = [[0, 0], [1, 1]] y = [0, 1] clf = svm.SVC(kernel='linear') clf.fit(X, y) pred = clf.predict([[2, 2]]) print(pred[0])
Attempts:
2 left
💡 Hint
The point [2, 2] is closer to which training group?
✗ Incorrect
The model learns to separate points [0,0] as class 0 and [1,1] as class 1. The new point [2,2] is closer to class 1 side.
❓ Hyperparameter
advancedWhich SVM hyperparameter controls the trade-off between margin size and classification error?
In SVM, which parameter lets you decide how much you want to avoid misclassifying training points versus having a wider margin?
Attempts:
2 left
💡 Hint
This parameter is often called the regularization parameter.
✗ Incorrect
The parameter C controls the penalty for misclassification. A small C allows more errors but a wider margin; a large C tries to classify all points correctly.
❓ Metrics
advancedWhich metric is most suitable to evaluate an SVM classifier on imbalanced data?
If your SVM model predicts classes but one class is much rarer than the other, which metric gives a better sense of performance?
Attempts:
2 left
💡 Hint
Think about a metric that balances precision and recall.
✗ Incorrect
F1 Score combines precision and recall, making it better for imbalanced data than accuracy alone.
🔧 Debug
expertWhat error does this SVM code raise?
Consider this code snippet. What error will it raise when run?
ML Python
from sklearn import svm X = [[0, 0], [1, 1], [2, 2]] y = [0, 1] clf = svm.SVC(kernel='linear') clf.fit(X, y)
Attempts:
2 left
💡 Hint
Check if the number of labels matches the number of data points.
✗ Incorrect
The labels list y has 2 elements but X has 3 samples, causing a ValueError about inconsistent sample sizes.
