NLP Course 3 Week 3: Confusion matrix

Hi @Taisiya_Kopytova

You somehow mixed up two code lines

  1. Check if d>threshold to make predictions
    Here you were only suppose to check if cosine similarity is greater than threshold but you ended up adding the accuracy part of the code to this code line. Also do not hard code the path by introducing res = d > threshold (I KNOW THE HINT FROM PREVIOUS CELLS TELLS YOU TO DO SO.
    INSTEAD OF y_test == res, you only need to use tf.cast(d>threshold with the datatype).

  2. Next your accuracy code is incorrect
    take the average of correct predictions to get the accuracy
    accuracy = tf.math.reduce_mean(y_pred)

You need to use tf.reduce_mean to the tf.cast when your actual target is absolute equal to the prediction with the datatype.

Regards
DP

1 Like