0
0
TensorFlowml~10 mins

ROC and AUC curves in TensorFlow - 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 function that computes the ROC AUC score.

TensorFlow
from sklearn.metrics import [1]
Drag options to blanks, or click blank then click option'
Amean_squared_error
Broc_auc_score
Caccuracy_score
Dconfusion_matrix
Attempts:
3 left
💡 Hint
Common Mistakes
Importing accuracy_score instead of roc_auc_score
Importing confusion_matrix which is unrelated to ROC AUC
Importing mean_squared_error which is for regression
2fill in blank
medium

Complete the code to compute the false positive rate and true positive rate for ROC curve.

TensorFlow
fpr, tpr, thresholds = roc_curve(y_true, [1])
Drag options to blanks, or click blank then click option'
Athresholds
By_true
Cy_pred
Dy_scores
Attempts:
3 left
💡 Hint
Common Mistakes
Passing true labels instead of predicted scores
Passing predicted class labels instead of scores
3fill in blank
hard

Fix the error in this TensorFlow code to compute AUC metric during model compilation.

TensorFlow
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=[[1]])
Drag options to blanks, or click blank then click option'
Atf.keras.metrics.AUC()
Btf.keras.metrics.Accuracy()
Ctf.keras.metrics.Precision()
Dtf.keras.metrics.Recall()
Attempts:
3 left
💡 Hint
Common Mistakes
Using Accuracy metric instead of AUC
Using Precision or Recall which are different metrics
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps thresholds to TPR values from ROC curve data.

TensorFlow
threshold_tpr = {thr[1] tpr[2] for thr, tpr in zip(thresholds, tpr)}
Drag options to blanks, or click blank then click option'
A:
B,
C.
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using comma instead of colon between key and value
Using equals sign instead of colon
Adding dot after variable names incorrectly
5fill in blank
hard

Fill all three blanks to create a TensorFlow callback that stops training when AUC reaches 0.95 or higher.

TensorFlow
early_stop = tf.keras.callbacks.EarlyStopping(monitor='[1]', patience=[2], mode='[3]')
Drag options to blanks, or click blank then click option'
Aauc
Bval_loss
Cval_auc
Daccuracy
E5
F10
Gmin
Hmax
Attempts:
3 left
💡 Hint
Common Mistakes
Monitoring 'val_loss' instead of 'val_auc'
Setting patience too high or too low
Using mode 'min' which stops when metric decreases