Tuesday, 28 May 2019

tf.keras.metrics.SpecificityAtSensitivity num_thresholds interpretation

I'm trying to get my head around tf.keras.metrics.SensitivityAtSpecificity. I'm fine with the concept of sensity and specificity in isolation, but I'm unsure how the two are related in this single metric.

More specifically, I'm unsure how to interpret the num_thresholds argument. The example in documentation has num_thresholds=1. Setting num_thresholds greater than 1 with the same input data seems to always return a metric value of 1.0.

def print_metric_value(num_thresholds):
    # other values based on docs example
    m = tf.keras.metrics.SensitivityAtSpecificity(
        0.4, num_thresholds=num_thresholds)
    m.update_state([0, 0, 1, 1], [0, 0.5, 0.3, 0.9])
    print('Result with num_thresholds = %d: %.1f' %
          (num_thresholds, m.result().numpy()))

print_metric_value(1)    # 0.5 - same as docs
print_metric_value(2)    # 1.0
print_metric_value(200)  # 1.0



from tf.keras.metrics.SpecificityAtSensitivity num_thresholds interpretation

No comments:

Post a Comment