0
0
ML Pythonml~20 mins

One-vs-rest and one-vs-one strategies in ML Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
OvR and OvO Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Difference between One-vs-Rest and One-vs-One

Which statement correctly describes the difference between the One-vs-Rest (OvR) and One-vs-One (OvO) strategies for multi-class classification?

AOvR trains classifiers for every pair of classes, while OvO trains one classifier per class against all others.
BOvR and OvO both train one classifier per class but use different loss functions.
COvR uses a single classifier for all classes, while OvO uses multiple classifiers for each class.
DOvR trains one classifier per class against all other classes, while OvO trains classifiers for every pair of classes.
Attempts:
2 left
💡 Hint

Think about how many classifiers are trained in each strategy and what data they use.

Model Choice
intermediate
2:00remaining
Choosing strategy for many classes

You have a dataset with 50 classes and limited computing power. Which multi-class classification strategy is generally more efficient to train?

AOne-vs-Rest, because it trains fewer classifiers (one per class).
BOne-vs-One, because it trains classifiers only on pairs of classes.
CBoth strategies require the same training time regardless of class count.
DOne-vs-One, because it requires less memory for large numbers of classes.
Attempts:
2 left
💡 Hint

Consider how the number of classifiers grows with the number of classes in each strategy.

Predict Output
advanced
2:00remaining
Output of OvR prediction voting

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.

Aclass_B
Bclass_A
Cclass_C
DNo prediction because scores are negative
Attempts:
2 left
💡 Hint

Look for the highest score regardless of sign.

Metrics
advanced
2:00remaining
Calculating number of classifiers in OvO

For a multi-class problem with 7 classes, how many binary classifiers does the One-vs-One strategy train?

A49
B21
C42
D7
Attempts:
2 left
💡 Hint

Use the formula for combinations of 7 classes taken 2 at a time.

🔧 Debug
expert
2:00remaining
Error in OvR prediction code

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)
ARaises ValueError due to multiple max values.
BReturns 'B' because it finds the last max score match.
CReturns 'A' because it finds the first max score match.
DRaises TypeError because max() cannot be used on dict values.
Attempts:
2 left
💡 Hint

Consider how max() and the for loop behave with ties.