0
0
ML Pythonml~10 mins

Probability calibration in ML Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the calibration module from scikit-learn.

ML Python
from sklearn.calibration import [1]
Drag options to blanks, or click blank then click option'
ACalibratedClassifierCV
Btrain_test_split
CStandardScaler
DLogisticRegression
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unrelated classes like train_test_split or StandardScaler.
Confusing model classes with calibration classes.
2fill in blank
medium

Complete the code to create a calibrated classifier using sigmoid method.

ML Python
calibrated_clf = CalibratedClassifierCV(base_estimator=clf, method=[1], cv='prefit')
Drag options to blanks, or click blank then click option'
Apolynomial
Bisotonic
Clinear
Dsigmoid
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'isotonic' when sigmoid is required.
Choosing methods not supported by CalibratedClassifierCV.
3fill in blank
hard

Fix the error in the code to correctly fit the calibrated classifier.

ML Python
calibrated_clf.[1](X_calib, y_calib)
Drag options to blanks, or click blank then click option'
Apredict
Bfit
Cpredict_proba
Dscore
Attempts:
3 left
💡 Hint
Common Mistakes
Calling predict or predict_proba before fitting the model.
Using score method which only evaluates performance.
4fill in blank
hard

Fill both blanks to create a dictionary of calibrated probabilities for each class.

ML Python
calibrated_probs = {cls: calibrated_clf.predict_proba(X)[:, [1]] for [2] in calibrated_clf.classes_}
Drag options to blanks, or click blank then click option'
A0
B1
Ccls
Dclass_label
Attempts:
3 left
💡 Hint
Common Mistakes
Using a fixed index like 0 or 1 instead of the loop variable.
Using a variable name not defined in the comprehension.
5fill in blank
hard

Fill all three blanks to compute Brier score loss for calibrated predictions.

ML Python
from sklearn.metrics import [1]
brier_score = [2](y_true, calibrated_clf.[3](X_test)[:, 1])
Drag options to blanks, or click blank then click option'
Aaccuracy_score
Bbrier_score_loss
Cpredict_proba
Dpredict
Attempts:
3 left
💡 Hint
Common Mistakes
Using accuracy_score which measures classification accuracy, not probability calibration.
Using predict instead of predict_proba which returns class labels.