Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit50ee33c

Browse files
author
Alena Rybakina
committed
Add aqo_k as custom parameter to define few number of features
for prediction. Its default value is 3. Queries can containa more number of features than 3 especially generic queries.Also add predict_a_few_neibours parameter for switch avalableto predict a few neibors than 3. It is done for not to changethe previous logic of the code
1 parent34ee3be commit50ee33c

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

‎aqo.c‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ boolforce_collect_stat;
4848
*/
4949
boolaqo_show_hash;
5050
boolaqo_show_details;
51+
boolaqo_predict_with_few_neighbors;
5152

5253
/* GUC variables */
5354
staticconststructconfig_enum_entryformat_options[]= {
@@ -72,7 +73,7 @@ intauto_tuning_infinite_loop = 8;
7273
/* Machine learning parameters */
7374

7475
/* The number of nearest neighbors which will be chosen for ML-operations */
75-
intaqo_k=3;
76+
intaqo_k;
7677
doublelog_selectivity_lower_bound=-30;
7778

7879
/*
@@ -237,6 +238,29 @@ _PG_init(void)
237238
NULL
238239
);
239240

241+
DefineCustomIntVariable("aqo.k_neighbors_threshold",
242+
"Set the threshold of number of neighbors for predicting.",
243+
NULL,
244+
&aqo_k,
245+
3,
246+
1,INT_MAX /1000,
247+
PGC_USERSET,
248+
0,
249+
NULL,
250+
NULL,
251+
NULL);
252+
253+
DefineCustomBoolVariable("aqo.predict_with_few_neighbors",
254+
"Make prediction with less neighbors than we should have.",
255+
NULL,
256+
&aqo_predict_with_few_neighbors,
257+
true,
258+
PGC_USERSET,
259+
0,
260+
NULL,
261+
lc_assign_hook,
262+
NULL);
263+
240264
prev_shmem_startup_hook=shmem_startup_hook;
241265
shmem_startup_hook=aqo_init_shmem;
242266
prev_planner_hook=planner_hook;

‎aqo.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ extern double auto_tuning_exploration;
211211
externintauto_tuning_max_iterations;
212212
externintauto_tuning_infinite_loop;
213213
externdoubleauto_tuning_convergence_error;
214+
externboolaqo_predict_with_few_neighbors;
214215

215216
/* Machine learning parameters */
216217

‎machine_learning.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ OkNNr_predict(OkNNrdata *data, double *features)
158158

159159
Assert(data!=NULL);
160160

161+
if (!aqo_predict_with_few_neighbors&&data->rows<aqo_k)
162+
return-1.;
163+
161164
for (i=0;i<data->rows;++i)
162165
distances[i]=fs_distance(data->matrix[i],features,data->cols);
163166

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp