寻找最接近的匹配
我有一个带有一组参数的对象,例如:
var obj = new {Param1 = 100; Param2 = 212; Param3 = 311; param4 = 11; Param5 = 290;}
在另一边,我有一个对象列表:
var obj1 = new {Param1 = 1221 ; Param2 = 212 ; Param3 = 311 ; param4 = 11 ; Param5 = 290 ; }
var obj3 = new {Param1 = 35 ; Param2 = 11 ; Param3 = 319 ; param4 = 211 ; Param5 = 790 ; }
var obj4 = new {Param1 = 126 ; Param2 = 218 ; Param3 = 2 ; param4 = 6 ; Param5 = 190 ; }
var obj5 = new {Param1 = 213 ; Param2 = 121 ; Param3 = 61 ; param4 = 11 ; Param5 = 29 ; }
var obj7 = new {Param1 = 161 ; Param2 = 21 ; Param3 = 71 ; param4 = 51 ; Param5 = 232 ; }
var obj9 = new {Param1 = 891 ; Param2 = 58 ; Param3 = 311 ; param4 = 21 ; Param5 = 590 ; }
var obj11 = new {Param1 = 61 ; Param2 = 212 ; Param3 = 843 ; param4 = 89 ; Param5 = 210 ; }
在列出的对象中找到第一个 obj 最接近的匹配的最佳(最简单)算法是什么?
I Have an object with a set of parameters like:
var obj = new {Param1 = 100; Param2 = 212; Param3 = 311; param4 = 11; Param5 = 290;}
On the other side i have a list of object:
var obj1 = new {Param1 = 1221 ; Param2 = 212 ; Param3 = 311 ; param4 = 11 ; Param5 = 290 ; }
var obj3 = new {Param1 = 35 ; Param2 = 11 ; Param3 = 319 ; param4 = 211 ; Param5 = 790 ; }
var obj4 = new {Param1 = 126 ; Param2 = 218 ; Param3 = 2 ; param4 = 6 ; Param5 = 190 ; }
var obj5 = new {Param1 = 213 ; Param2 = 121 ; Param3 = 61 ; param4 = 11 ; Param5 = 29 ; }
var obj7 = new {Param1 = 161 ; Param2 = 21 ; Param3 = 71 ; param4 = 51 ; Param5 = 232 ; }
var obj9 = new {Param1 = 891 ; Param2 = 58 ; Param3 = 311 ; param4 = 21 ; Param5 = 590 ; }
var obj11 = new {Param1 = 61 ; Param2 = 212 ; Param3 = 843 ; param4 = 89 ; Param5 = 210 ; }
What is the best (easiest) algorithm to find the closest match for the first obj in the listed objects?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在尝试查找之前,您必须定义术语最接近的匹配!
1-许多人使用的一种方法是均方误差(或欧几里得距离) :
计算所有对象的均方误差:
并选择具有最小值的一个...
2-您还可以使用最小绝对误差:
并选择最小值...
3-您还可以根据您拥有的任何条件应用k-最近邻上面选择的
这一切都取决于这些参数的属性...
有关更多阅读,您可以查看 分类列表算法
You must define the term closest match before trying to find it!!
1- One way many people use is Mean Squared Error (or Euclidean Distance) :
Calculate mean square error for all objects:
and choose the one with the minimum value...
2- You may also use Minimum absolute error :
and choose the one with the minimum value...
3- Also you can apply k-nearest neighbour with any criteria you have chosen above
It all depends on the properties of these parameters...
For more reading you may look at List of Classification algorithms
我想,要看情况。我想到了几种可能性:
当然,还有数千种可能性,因此您必须指定您到底想要什么!
Depends, i guess. Several possibilities come to my mind:
of course, there are thousand more possibilities, therefore you have to specify, what you want exactly!
您还可以使用欧几里得距离。
本质上,您假设每个对象都是 5 维中的一个点,并寻找最近的点(即:距离最短)。
You could also use the Euclidean Distance.
Essentially you pretend each object is a point in 5 dimensions and look for the point that's closest (i.e.: has the shortest distance).