K近邻搜索与尺寸重量 [英] K nearest neighbour search with weights on dimensions

查看:101
本文介绍了K近邻搜索与尺寸重量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

予有在其上的各种传感器放置在不同的位置上的地板上的地板。对于每一个发射装置,传感器的可以的发现它的读数。它可以有6-7传感器在地板上,而有可能是一个特定的读出可能不被一些传感器检测,但通过一些其它的传感器被检测。

I have a floor on which various sensors are placed at different location on the floor. For every transmitting device, sensors may detect its readings. It is possible to have 6-7 sensors on a floor, and it is possible that a particular reading may not be detected by some sensors, but are detected by some other sensors.

对于每一个读我得到的,我想,以确定在地板上,阅读的位置。我们把地板顺理成章地进入砖(5×5英尺的区域)和查找理想的阅读每瓦应为每个传感器设备(基于某种传输路径损耗公式)检测。

For every reading I get, I would like to identify the location of that reading on the floor. We divide floor logically into TILEs (5x5 feet area) and find what ideally the reading at each TILE should be as detected by each sensor device (based on some transmission pathloss equation).

我现在用的是precomputed从'N'感应装置的读数在每瓦在N维空间中的一个点。当我得到一个现实生活中的阅读,我觉得这是阅读的近邻,并分配这个读数到该位置。

I am using the precomputed readings from 'N' sensor device at each TILE as a point in N-dimensional space. When I get a real life reading, I find the nearest neighbours of this reading, and assign this reading to that location.

我想知道是否有一变种K个最近邻居,其中维度可以从考虑中删除。这将特别是有用的,当一个特定的传感器没有报告任何读数。据我所知,投入的权重上的尺寸是不可能与像KD树或R树算法。不过,我想知道是否有可能计算最近的邻居时,放弃一个维度。有没有这样的算法?

I would like to know if there is a variant of K nearest neighbours, where a dimension could be REMOVED from consideration. This will especially be useful, when a particular sensor is not reporting any reading. I understand that putting weightage on a dimension will be impossible with algorithms like kd-tree or R trees. However, I would like to know if it would be possible to discard a dimension when computing nearest neighbours. Is there any such algorithm?

编辑:

如果可以用于k个最近的搜索与不同的查询,其中每个查询都有不同的维度权重相同的R / kd树我想知道的是?我不想构造另一个kd树为每个不同的权重上的尺寸。

What I want to know is if the same R/kd tree could be used for k nearest search with different queries, where each query has different dimension weightage? I don't want to construct another kd-tree for every different weightage on dimensions.

编辑2:

有没有在Python任何库,它允许您指定自定义距离函数,然后搜索k个最近的邻居?从本质上讲,我会想使用不同的自定义距离函数不同的查询。

Is there any library in python, which allows you to specify the custom distance function, and search for k nearest neighbours? Essentially, I would want to use different custom distance functions for different queries.

推荐答案

在经历了很多关于计算器的问题,终于进入了SciPy的kd树源$ C ​​$ C的细节,我意识到通过席琳答案在下面的链接是正确的:

After going through a lot of questions on stackoverflow, and finally going into details of scipy kd tree source code, I realised the answer by "celion" in following link is correct:

<一个href="http://stackoverflow.com/questions/1947805/kd-trees-and-missing-values-vector-comparison/1949834?noredirect=1#comment31213165_1949834">KD-Trees和缺失值(向量比较)

节选:
我认为最好的解决方案,包括让你的手脏了code,你用$ P $工作psumably最近邻搜索计算的树叶和查询向量的点之间的距离。你应该能够修改这个处理,其中点和查询向量的大小不同的情况。例如,如果树中的点在三维中给出,但查询向量是唯一的长度2,则点之间的距离( P0,P1,P2)和所述查询向量(X0,X1)。将

Excerpt:
"I think the best solution involves getting your hands dirty in the code that you're working with. Presumably the nearest-neighbor search computes the distance between the point in the tree leaf and the query vector; you should be able to modify this to handle the case where the point and the query vector are different sizes. E.g. if the points in the tree are given in 3D, but your query vector is only length 2, then the "distance" between the point (p0, p1, p2) and the query vector (x0, x1) would be

开方((P0-X0)^ 2 +(P1-X1)^ 2)

sqrt( (p0-x0)^2 + (p1-x1)^2 )

我并没有深入到你链接到java code,但我可以尝试找到确切位置的变化需要,如果你需要帮助去。

I didn't dig into the java code that you linked to, but I can try to find exactly where the change would need to go if you need help.

克里斯

PS - 你可能不需要上面公式中的开方,因为距离的平方是一般等价物

PS - you might not need the sqrt in the equation above, since distance squared is usually equivalent."

这篇关于K近邻搜索与尺寸重量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆