0
0
ML Pythonml~20 mins

Boosting concept in ML Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Boosting Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2: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?
AUsing a single model and tuning its hyperparameters to reduce error.
BTraining a single very deep model to capture all data patterns at once.
CRandomly selecting features to train multiple independent models and averaging their results.
DCombining many weak models sequentially, where each new model focuses on correcting errors of the previous ones.
Attempts:
2 left
💡 Hint
Think about how boosting tries to fix mistakes step by step.
Model Choice
intermediate
2: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?
AK-nearest neighbors with large k
BDeep convolutional neural networks
CDecision stumps (trees with one split)
DSupport vector machines with complex kernels
Attempts:
2 left
💡 Hint
Weak learners are simple and fast to train.
Metrics
advanced
2: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?
AWeights of all samples are kept the same throughout training.
BWeights of misclassified samples are increased, and weights of correctly classified samples are decreased.
CWeights of correctly classified samples are increased, and misclassified samples are decreased.
DWeights are randomly shuffled after each iteration.
Attempts:
2 left
💡 Hint
Think about how boosting focuses on mistakes.
🔧 Debug
advanced
2: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)
ASyntaxError due to missing colon after the if statement
BTypeError because weights list cannot be multiplied by float
CIndexError because of out-of-range index access
DNo error, prints updated weights
Attempts:
2 left
💡 Hint
Check the syntax of the if statement line.
Predict Output
expert
3: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])
A[0.125, 0.5, 0.5, 0.125]
B[0.125, 0.5, 0.125, 0.5]
C[0.5, 0.125, 0.125, 0.5]
D[0.5, 0.125, 0.5, 0.125]
Attempts:
2 left
💡 Hint
Calculate e^0.7 ≈ 2.013 and e^-0.7 ≈ 0.497, then multiply accordingly.