diff --git a/modules/deeplearning/icing_cnn.py b/modules/deeplearning/icing_cnn.py index 15a743edeb2a8c0c768740cc466674bcde99917c..985e7032106bb1821146b576ff42c613970b0054 100644 --- a/modules/deeplearning/icing_cnn.py +++ b/modules/deeplearning/icing_cnn.py @@ -617,12 +617,25 @@ class IcingIntensityNN: for mini_batch_test in tst_ds: self.test_step(mini_batch_test) + recall = self.test_recall.result() + precsn = self.test_precision.result() + f1 = 2 * (precsn * recall) / (precsn + recall) + + tn = self.test_true_neg.result() + tp = self.test_true_pos.result() + fn = self.test_false_neg.result() + fp = self.test_false_pos.result() + + mcc = ((tp * tn) - (fp * fn)) / np.sqrt((tp + fp) * (tp + fn) * (tn + fp) * (tn + fn)) + with self.writer_valid.as_default(): tf.summary.scalar('loss_val', self.test_loss.result(), step=step) tf.summary.scalar('acc_val', self.test_accuracy.result(), step=step) tf.summary.scalar('auc_val', self.test_auc.result(), step=step) tf.summary.scalar('recall_val', self.test_recall.result(), step=step) tf.summary.scalar('prec_val', self.test_precision.result(), step=step) + tf.summary.scalar('f1_val', f1, step=step) + tf.summary.scalar('mcc_val', mcc, step=step) tf.summary.scalar('num_train_steps', step, step=step) tf.summary.scalar('num_epochs', epoch, step=step)