Challenge - 5 Problems
Boosting Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
What is the main idea behind boosting in machine learning?
Boosting is a technique used to improve model performance. What best describes its main idea?
Attempts:
2 left
💡 Hint
Think about how boosting tries to fix mistakes step by step.
✗ Incorrect
Boosting builds models one after another. Each new model tries to fix the errors made by the models before it, improving overall accuracy.
❓ Model Choice
intermediate2:00remaining
Which model is commonly used as a weak learner in boosting algorithms?
Boosting algorithms often use a simple model repeatedly. Which of these is typically used?
Attempts:
2 left
💡 Hint
Weak learners are simple and fast to train.
✗ Incorrect
Decision stumps are simple trees with one split, making them weak learners ideal for boosting to combine and improve.
❓ Metrics
advanced2:00remaining
In AdaBoost, how are the weights of training samples updated after each iteration?
AdaBoost adjusts sample weights to focus on hard examples. How exactly are these weights updated?
Attempts:
2 left
💡 Hint
Think about how boosting focuses on mistakes.
✗ Incorrect
AdaBoost increases weights for samples the model got wrong, so the next model pays more attention to them.
🔧 Debug
advanced2:00remaining
What error will this Python snippet raise when implementing a simple boosting weight update?
Consider this code snippet for updating sample weights in boosting:
weights = [0.1, 0.2, 0.3, 0.4]
predictions = [1, 0, 1, 0]
labels = [1, 1, 0, 0]
for i in range(len(weights)):
if predictions[i] != labels[i]
weights[i] *= 1.5
else:
weights[i] *= 0.5
print(weights)
ML Python
weights = [0.1, 0.2, 0.3, 0.4] predictions = [1, 0, 1, 0] labels = [1, 1, 0, 0] for i in range(len(weights)): if predictions[i] != labels[i]: weights[i] *= 1.5 else: weights[i] *= 0.5 print(weights)
Attempts:
2 left
💡 Hint
Check the syntax of the if statement line.
✗ Incorrect
The if statement is missing a colon at the end, causing a SyntaxError.
❓ Predict Output
expert3:00remaining
What is the output of this simplified AdaBoost weight update code?
Given the code below, what is the final list of weights printed?
weights = [0.25, 0.25, 0.25, 0.25]
predictions = [1, 0, 1, 0]
labels = [1, 1, 0, 0]
alpha = 0.7
for i in range(len(weights)):
if predictions[i] != labels[i]:
weights[i] *= (2.718 ** alpha)
else:
weights[i] *= (2.718 ** (-alpha))
print([round(w, 3) for w in weights])
ML Python
weights = [0.25, 0.25, 0.25, 0.25] predictions = [1, 0, 1, 0] labels = [1, 1, 0, 0] alpha = 0.7 for i in range(len(weights)): if predictions[i] != labels[i]: weights[i] *= (2.718 ** alpha) else: weights[i] *= (2.718 ** (-alpha)) print([round(w, 3) for w in weights])
Attempts:
2 left
💡 Hint
Calculate e^0.7 ≈ 2.013 and e^-0.7 ≈ 0.497, then multiply accordingly.
✗ Incorrect
For each index:
- If prediction != label, multiply weight by ~2.013
- Else multiply by ~0.497
Weights start at 0.25.
Index 0: pred=1, label=1 (equal) → 0.25*0.497=0.12425
Index 1: pred=0, label=1 (not equal) → 0.25*2.013=0.50325
Index 2: pred=1, label=0 (not equal) → 0.25*2.013=0.50325
Index 3: pred=0, label=0 (equal) → 0.25*0.497=0.12425
Rounded: [0.124, 0.503, 0.503, 0.124]
Option A matches closest with [0.125, 0.5, 0.5, 0.125].