0
0
TensorFlowml~10 mins

Classification reports 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 generates a classification report.

TensorFlow
from sklearn.metrics import [1]
Drag options to blanks, or click blank then click option'
Aclassification_report
Baccuracy_score
Cconfusion_matrix
Droc_auc_score
Attempts:
3 left
💡 Hint
Common Mistakes
Importing confusion_matrix instead of classification_report
Using accuracy_score which only gives one metric
2fill in blank
medium

Complete the code to generate predictions from the model on test data.

TensorFlow
y_pred = model.[1](X_test)
Drag options to blanks, or click blank then click option'
Aevaluate
Bpredict
Cfit
Dtransform
Attempts:
3 left
💡 Hint
Common Mistakes
Using evaluate which returns loss and metrics
Using fit which trains the model
3fill in blank
hard

Fix the error in the code to correctly generate a classification report for true and predicted labels.

TensorFlow
report = classification_report(y_true, [1])
print(report)
Drag options to blanks, or click blank then click option'
Ay_pred
Bmodel.predict(X_test)
Cy_true
DX_test
Attempts:
3 left
💡 Hint
Common Mistakes
Passing y_true twice
Passing input features X_test instead of predictions
4fill in blank
hard

Fill both blanks to create a classification report with target names for classes 'cat' and 'dog'.

TensorFlow
report = classification_report(y_true, y_pred, target_names=[1])
print([2])
Drag options to blanks, or click blank then click option'
A['cat', 'dog']
Bclassification_report
Creport
D['dog', 'cat']
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the function name instead of the report variable to print
Swapping class names order incorrectly
5fill in blank
hard

Fill all three blanks to generate predictions, convert probabilities to class labels, and print the classification report.

TensorFlow
y_prob = model.[1](X_test)
y_pred = y_prob.argmax(axis=[2])
print(classification_report(y_true, [3]))
Drag options to blanks, or click blank then click option'
Apredict
B1
Cy_pred
Dpredict_proba
Attempts:
3 left
💡 Hint
Common Mistakes
Using predict instead of predict_proba for probabilities
Using wrong axis in argmax
Printing classification_report with wrong variable