Siamese Lab improvement proposal

I think this line in the display_images function (and consequently the coloring) in the C1_W1_Lab_3_siamese-network notebook is quite misleading

if predictions[i] > 0.5: t.set_color('red') # bad predictions in red

as these predictions are not bad (ie incorrect) but just pairs that are predicted to be dissimilar (according to the set threshold of 0.5)

I propose an improvement to the prediction labelling to show:

  1. predicted distance
  2. true label
  3. predicted label

and color in red the ones where the true label is not the same as the predicted label

we can achieve this by replacing the corresponding code in the display_images function with the following code:

    lab_titles = ['dissimilar', 'similar']
    tick_labels = [f'distance = {p:.3f}\ntrue:{lab_titles[int(l)]}\npred:{lab_titles[int(p < 0.5)]}' 
                   for (p, l) in zip(predictions, labels)]
    plt.xticks([28*x+14 for x in range(n)], tick_labels)
    for i,t in enumerate(plt.gca().xaxis.get_ticklabels()):
        if int(predictions[i] < 0.5) != labels[i]: t.set_color('red') # incorrect predictions

This will result in the following final picture (example)

As far as I can see from this Lab(and its been a long time I have done this lab) if pairs have a big distance it means that they are not predicted correctly so the prediction is not good. You may call it dissimilar or else (after all these are based on probability calculations) but for the purpose of our model performance thats a “bad prediction” .

@gent.spah ,
With all the respect, please carefully review the said Lab before making any further statements.
Now you’re trying to convince me (and the topic readers) that if the model predicts that a shoe is far from (ie dissimilar) to pants (column 7 on the previously attached screenshot), it’s making a wrong prediction (and inversely if it predicts that a shoe is far from the other shoe it’s making a right prediction). I would say that one does not need any knowledge of Machine Learning whatsoever to disagree with this: shoe looks like shoe not like pants.
If you don’t trust my words, you can review how the accuracy is calculated in the lab itself to convince yourself that depending on the pair’s label, big distance is a good prediction.