且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SciPy KDTree 距离单位?

更新时间:2023-02-26 16:59:55

当测量值是单位无法相互转换的事物(例如时间和距离)时,它不会返回任何可解释的单位.它返回 sqrt(feet**2 + feet**2 + sec**2),它不是一个度量单位.这是欧几里得范数,但在这种情况下是在一个抽象空间上.

It doesn't return any interpretable unit when the measurements are of things in which units can't be converted to each other (time and distance, for example). It's returning sqrt(feet**2 + feet**2 + sec**2), which is not a unit of measure. It's the Euclidean norm, but over an abstract space in this case.

顺便说一下,这不是一个真正的 Python 问题.scipy 只是操纵你给它的数字,不知道单位.这更像是一个如何解释数学的问题,例如,如果你想把一个 5' x 5' 的盒子比一个 6' x 6' 的盒子更接近"一个 7' x 7' 的盒子,因为你碰巧在几秒钟内测量它们,并在几小时后测量第三个盒子.只有您知道您的数据以及哪些特征对于构建相似度评分真正重要.在我刚刚给出的情况下,这是没有意义的.如果您根据体型和*** 100 米时间对短跑运动员的相似性进行排名,那么这可能是有道理的.

This isn't really a Python question, by the way. scipy is just manipulating the numbers you give it and doesn't know the units. It's more a question of how to interpret math, for instance, if you want to think of a 5' x 5' box as 'closer' to a 7' x 7' box than a 6' x 6' box because you happened to measure them within seconds of each other and measured the third box hours later. Only you know your data and what features really count for building a similarity score. In the case I just gave, it doesn't make sense. If you're ranking similarity of sprinters based on both body size and best 100m time, then it probably makes sense.