How to compute Spearman correlation in Tensorflow
问题 Problem I need to compute the Pearson and Spearman correlations, and use it as metrics in tensorflow. For Pearson, it's trivial : tf.contrib.metrics.streaming_pearson_correlation(y_pred, y_true) But for Spearman, I am clueless ! What I tried : From this answer : samples = 1 predictions_rank = tf.nn.top_k(y_pred, k=samples, sorted=True, name='prediction_rank').indices real_rank = tf.nn.top_k(y_true, k=samples, sorted=True, name='real_rank').indices rank_diffs = predictions_rank - real_rank