Which statement correctly describes the difference between the One-vs-Rest (OvR) and One-vs-One (OvO) strategies for multi-class classification?
Think about how many classifiers are trained in each strategy and what data they use.
One-vs-Rest trains one classifier per class, distinguishing that class from all others combined. One-vs-One trains a classifier for every pair of classes, focusing on distinguishing between just two classes at a time.
You have a dataset with 50 classes and limited computing power. Which multi-class classification strategy is generally more efficient to train?
Consider how the number of classifiers grows with the number of classes in each strategy.
One-vs-Rest trains one classifier per class, so with 50 classes it trains 50 classifiers. One-vs-One trains classifiers for every pair of classes, which is 50*49/2 = 1225 classifiers, much more computationally expensive.
Given the following OvR classifiers' decision scores for a sample, what is the predicted class?
scores = {'class_A': -1.2, 'class_B': 0.5, 'class_C': 0.3}OvR predicts the class with the highest decision score.
Look for the highest score regardless of sign.
OvR picks the class with the highest decision score. Here, class_B has the highest score 0.5, so it is predicted.
For a multi-class problem with 7 classes, how many binary classifiers does the One-vs-One strategy train?
Use the formula for combinations of 7 classes taken 2 at a time.
Number of classifiers in OvO is n*(n-1)/2 = 7*6/2 = 21.
What error will this Python code raise?
def predict_ovr(scores):
# scores is a dict of class:score
max_score = max(scores.values())
for cls, score in scores.items():
if score == max_score:
return cls
result = predict_ovr({'A': 0.2, 'B': 0.2, 'C': 0.1})
print(result)Consider how max() and the for loop behave with ties.
The code returns the first class with the max score. Since 'A' and 'B' tie at 0.2, it returns 'A'. No error is raised.