tensorflow-deep-learning
tensorflow-deep-learning copied to clipboard
Error in calculating most_wrong in 08_introduction_to_nlp_in_tensorflow.ipynb (its in video notebook also)
CURRENT CODE
#Create dataframe with validation sentences and best performing model predictions
val_df = pd.DataFrame({"text": val_sentences,
"target": val_labels,
"pred": model_6_pretrained_preds,
"pred_prob": tf.squeeze(model_6_pretrained_pred_probs)})
val_df.head()
# Find the wrong predictions and sort by prediction probabilities
most_wrong = val_df[val_df["target"] != val_df["pred"]].sort_values("pred_prob", ascending=False)
most_wrong[:10]
SUGGESTED NEW CODE
# Create dataframe with validation sentences and best performing model predictions, and prediction errors
val_df = pd.DataFrame({"text": val_sentences,
"target": val_labels,
"pred": model_6_pretrained_preds,
"pred_prob":tf.squeeze(model_6_pretrained_pred_probs),
"pred_error":tf.abs(tf.squeeze(model_6_pretrained_pred_probs)-val_labels)}) #### FIX (need comma on prev line too)
val_df.head()
# Find the wrong predictions and sort by prediction error
most_wrong = val_df[val_df["target"] != val_df["pred"]].sort_values("pred_error", ascending=False)
most_wrong.head(30) #### FIX look at 30 so we see some cases on wrong 1s and wrong 0s
# Check from the bottom as well - we should see least wrong cases - predictions just a little on the wrong side of 0.50
most_wrong[-10:]
thank you for this, will fix this week!