寻找最接近的匹配最接近

2023-09-11 00:01:49 作者:退一步竟是深渊

我有一个对象的一组参数,如:

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 ; }

什么是最好的(容易)算法发现,在列出的对象最接近的匹配第一个OBJ?

What is the best (easiest) algorithm to find the closest match for the first obj in the listed objects?

推荐答案

您必须试图找到它之前定义的术语最匹配 !!

You must define the term closest match before trying to find it!!

1的一种方法很多人用的是均方误差(或的欧氏距离):

1- One way many people use is Mean Squared Error (or Euclidean Distance) :

计算均方误差为所有对象:

Calculate mean square error for all objects:

Sqr(obj.Param1-obj1.Param1) + Sqr(obj.Param2-obj1.Param2) + ..... // for obj1
Sqr(obj.Param1-obj2.Param1) + Sqr(obj.Param2-obj2.Param2) + ..... // for obj2

和选择一个与最小值...

and choose the one with the minimum value...

2 - 你也可以使用最小绝对误差:

2- You may also use Minimum absolute error :

Abs(obj.Param1-obj1.Param1) + Abs(obj.Param2-obj1.Param2) + ..... // for obj1
Abs(obj.Param1-obj2.Param1) + Abs(obj.Param2-obj2.Param2) + ..... // for obj2

和选择一个与最小值...

and choose the one with the minimum value...

3你也可以申请 k近邻与您所选择的任何标准上述

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