Skip to content

Commit 97b6c63

Browse files
committed
Replacing scores with round to avoid rounding errors
1 parent dc71549 commit 97b6c63

File tree

1 file changed

+43
-36
lines changed

1 file changed

+43
-36
lines changed

x-pack/plugin/esql/qa/testFixtures/src/main/resources/knn-function.csv-spec

Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -110,39 +110,37 @@ required_capability: knn_function
110110

111111
from colors metadata _score
112112
| keep rgb_vector, color, _score
113-
| where knn(rgb_vector, [128,128,0], {"k": 140})
114-
| eval round_score = round(_score, 4)
115-
| sort round_score desc, color asc
116-
| keep rgb_vector, round_score
113+
| where knn(rgb_vector, [128,255,0], {"k": 140})
114+
| sort _score desc, color asc
115+
| keep rgb_vector
117116
| limit 5
118117
;
119118

120-
rgb_vector:dense_vector | round_score:double
121-
[128.0, 128.0, 0.0] | 1.0
122-
[107.0, 142.0, 35.0] | 0.0014
123-
[85.0, 107.0, 47.0] | 4.0E-4
124-
[184.0, 134.0, 11.0] | 3.0E-4
125-
[139.0, 69.0, 19.0] | 3.0E-4
119+
rgb_vector:dense_vector
120+
[127.0, 255.0, 0.0]
121+
[124.0, 252.0, 0.0]
122+
[173.0, 255.0, 47.0]
123+
[154.0, 205.0, 50.0]
124+
[50.0, 205.0, 50.0]
126125
;
127126

128127
knnAfterDrop
129128
required_capability: knn_function
130129

131130
from colors metadata _score
132131
| drop color
133-
| where knn(rgb_vector, [128,128,0], {"k": 140})
134-
| eval round_score = round(_score, 4)
135-
| sort round_score desc
136-
| keep rgb_vector, round_score
132+
| where knn(rgb_vector, [128,255,0], {"k": 140})
133+
| sort _score desc
134+
| keep rgb_vector
137135
| limit 5
138136
;
139137

140-
rgb_vector:dense_vector | round_score:double
141-
[184.0, 134.0, 11.0] | 3.0E-4
142-
[128.0, 128.0, 0.0] | 1.0
143-
[154.0, 205.0, 50.0] | 1.0E-4
144-
[85.0, 107.0, 47.0] | 4.0E-4
145-
[107.0, 142.0, 35.0] | 0.0014
138+
rgb_vector:dense_vector
139+
[127.0, 255.0, 0.0]
140+
[124.0, 252.0, 0.0]
141+
[173.0, 255.0, 47.0]
142+
[154.0, 205.0, 50.0]
143+
[50.0, 205.0, 50.0]
146144
;
147145

148146
knnAfterEval
@@ -201,19 +199,21 @@ from colors metadata _score
201199
| where (knn(rgb_vector, [0,255,255], {"k": 140}) or knn(rgb_vector, [128, 0, 255], {"k": 140})) and primary == true
202200
| keep color, rgb_vector, _score
203201
| sort _score desc, color asc
202+
| eval round_score = round(_score)
203+
| drop _score
204204
| limit 10
205205
;
206206

207-
color:text | rgb_vector:dense_vector | _score:double
208-
red | [255.0, 0.0, 0.0] | 2.1994377675582655E-5
209-
yellow | [255.0, 255.0, 0.0] | 1.867113314801827E-5
210-
green | [0.0, 128.0, 0.0] | 2.9579907277366146E-5
211-
cyan | [0.0, 255.0, 255.0] | 1.000016689300537
212-
blue | [0.0, 0.0, 255.0] | 1.1921183613594621E-4
213-
magenta | [255.0, 0.0, 255.0] | 7.578763325000182E-5
214-
black | [0.0, 0.0, 0.0] | 2.6632071239873767E-5
215-
gray | [128.0, 128.0, 128.0] | 6.426929758163169E-5
216-
white | [255.0, 255.0, 255.0] | 3.5320219467394054E-5
207+
color:text | rgb_vector:dense_vector | round_score:double
208+
cyan | [0.0, 255.0, 255.0] | 1.0
209+
blue | [0.0, 0.0, 255.0] | 0.0
210+
magenta | [255.0, 0.0, 255.0] | 0.0
211+
gray | [128.0, 128.0, 128.0] | 0.0
212+
white | [255.0, 255.0, 255.0] | 0.0
213+
green | [0.0, 128.0, 0.0] | 0.0
214+
black | [0.0, 0.0, 0.0] | 0.0
215+
red | [255.0, 0.0, 0.0] | 0.0
216+
yellow | [255.0, 255.0, 0.0] | 0.0
217217
;
218218

219219
knnWithNonPushableConjunction
@@ -222,16 +222,23 @@ required_capability: knn_function
222222
from colors metadata _score
223223
| eval composed_name = locate(color, " ") > 0
224224
| where knn(rgb_vector, [128,128,0], {"k": 140}) and composed_name == false
225-
| eval round_score = round(_score, 4)
225+
| eval round_score = round(_score)
226+
| sort _score desc, color asc
226227
| keep color, composed_name, round_score
227-
| sort round_score desc, color asc
228+
| limit 10
228229
;
229230

230231
color:text | composed_name:boolean | round_score:double
231-
olive | false | 1.0
232-
sienna | false | 3.0E-4
233-
chocolate | false | 1.0E-4
234-
peru | false | 1.0E-4
232+
olive | false | 1.0
233+
sienna | false | 0.0
234+
chocolate | false | 0.0
235+
peru | false | 0.0
236+
brown | false | 0.0
237+
gray | false | 0.0
238+
green | false | 0.0
239+
maroon | false | 0.0
240+
firebrick | false | 0.0
241+
chartreuse | false | 0.0
235242
;
236243

237244
testKnnWithNonPushableDisjunctions

0 commit comments

Comments
 (0)