How to find closest matching items for a given query?

31 Views Asked by At

Given 3 items i with probability values: p of belonging to 3 classes c as:

i1 = c1(p=1),c2(p=0),c3(p=1)

i2 = c1(p=1),c2(p=0.6),c3(p=0)

i3 = c1(p=0.9),c2(p=0.6),c3(p=0.1)

How to calculate each products probability score match to below query ?:

q = c1(p=1),c2(p=1),c3(p=0)

I am thinking to solve it by by computing one value for each i that could be compared with value produced by the query as:

val i1 = (1 * 100) + (0 * 1000) +  (0 * 10000)
val i2 = (1 * 100) + (0.6 * 1000) +  (0 * 10000)
val i3 = (0.9 * 100) + (0.6 * 1000) +  (0.1 * 10000)     

val q = (1 * 100) + (1 * 1000) +  (0 * 10000)  

with results as:

i1: Int = 100
i2: Double = 700.0
i3: Double = 1690.0
q: Int = 1100

and then compare the values, am I on a right track ?