26 using namespace shogun;
80 SG_ERROR(
"Number of training vectors does not match number of labels\n");
124 ASSERT(m_k<=distance->get_num_vec_lhs());
129 int32_t* train_lab = NULL;
142 SG_INFO(
"%d test examples\n", num_lab);
150 float64_t tfinish, tparsed, tcreated, tqueried;
167 SG_PRINT(
"\nQuick sort query %d\n", i);
168 for (int32_t j=0; j<
m_k; j++)
184 int32_t out_idx = choose_class(classes, train_lab);
189 SG_PRINT(
">>>> Quick sort applied in %9.4f\n",
199 SG_INFO(
"q != 1.0 not supported with cover tree, using q = 1\n");
209 SG_PRINT(
">>>> JL parsed in %9.4f\n",
221 SG_PRINT(
">>>> Cover trees created in %9.4f\n",
231 SG_PRINT(
">>>> Query finished in %9.4f\n",
237 for ( int32_t i = 0 ; i < res.
index ; ++i )
239 for ( int32_t j = 0 ; j < res[i].
index ; ++j )
241 printf(
"%d ", res[i][j].m_index);
248 for ( int32_t i = 0 ; i < res.
index ; ++i )
251 for ( int32_t j = 0; j <
m_k; ++j )
256 int32_t out_idx = choose_class(classes, train_lab);
286 SG_INFO(
"%d test examples\n", num_lab);
305 if (distances[j]<min_dist)
307 min_dist = distances[j];
348 SG_INFO(
"%d test examples\n", num_lab);
371 for (int32_t j=0; j<
m_k; j++)
373 classes[train_lab[j]]++;
381 if (out_max< classes[c])
413 for ( int32_t i = 0 ; i < res.
index ; ++i )
418 for ( int32_t j = 0 ; j <
m_k ; ++j )
424 res[i][j+1].m_index ];
435 for (int32_t j=0; j<
m_k; j++)
437 classes[train_lab[j]]++;
445 if (out_max< classes[c])
451 output[j*num_lab+res[i][0].m_index]=out_idx+
m_min_label;
467 SG_ERROR(
"No distance assigned!\n");
472 SG_ERROR(
"No vectors on left hand side\n");
504 int32_t CKNN::choose_class(
float64_t* classes, int32_t* train_lab)
509 for (int32_t j=0; j<
m_k; j++)
511 classes[train_lab[j]]+= multiplier;
512 multiplier*= multiplier;
521 if (out_max< classes[j])