【问题标题】:Kendall Tau Distance Python Implementation with range [0,1]Kendall Tau 距离 Python 实现,范围 [0,1]
【发布时间】:2018-10-19 08:34:21
【问题描述】:

是否有用于 Kendall Tau 距离度量的 Python 实现,它产生 [0, 1] 范围内而不是 [-1,1] 范围内的分数?后者已经通过 scipy 库提供。

谢谢

【问题讨论】:

    标签: python scipy scoring


    【解决方案1】:

    我无法帮助您提供现有的实现,但也许这对您来说已经足够了。

    您可以毫不费力地将[-1, 1] 映射到[0, 1] 范围。

    代码可能如下所示:

    def map_to_0_1(score):
        return (1+score) / 2
    
    foo_scores = [-1, -0.5, 0, 0.5, 1]
    print('original range scores:     ', foo_scores)
    print('scores mapped to new range:', list(map(map_to_0_1, foo_scores)))
    

    输出:

    original range scores:      [-1, -0.5, 0, 0.5, 1]
    scores mapped to new range: [0.0, 0.25, 0.5, 0.75, 1.0]
    

    这只是一个线性映射,它将输入按比例缩小到[0, 1] 范围,当然你也可以使用不同的非线性映射。

    我希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-17
      • 1970-01-01
      • 2011-02-03
      • 2015-05-22
      • 2015-05-12
      • 2023-03-31
      • 1970-01-01
      • 2019-07-03
      相关资源
      最近更新 更多