12 using namespace Eigen;
15 #include <shogun/lib/external/falconn/lsh_nn_table.h> 17 CLSHKNNSolver::CLSHKNNSolver(
const int32_t k,
const float64_t q,
const int32_t num_classes,
const int32_t min_label,
const SGVector<int32_t> train_labels,
const int32_t lsh_l,
const int32_t lsh_t):
18 CKNNSolver(k, q, num_classes, min_label, train_labels)
30 std::vector<falconn::DenseVector<double>> feats;
37 feats.push_back(temp);
40 falconn::LSHConstructionParameters params
41 = falconn::get_default_parameters<falconn::DenseVector<double>>(features->
get_num_vectors(),
43 falconn::DistanceFunction::EuclideanSquared,
46 if (m_lsh_l && m_lsh_t)
49 auto lsh_table = falconn::construct_table<falconn::DenseVector<double>>(feats, params);
51 lsh_table->set_num_probes(m_lsh_t);
54 std::vector<falconn::DenseVector<double>> query_feats;
63 auto indices =
new std::vector<int32_t> ();
64 lsh_table->find_k_nearest_neighbors(temp, (int_fast64_t)m_k, indices);
65 sg_memcpy(NN.get_column_vector(i), indices->data(),
sizeof(int32_t)*m_k);
73 train_lab[j] = m_train_labels[ NN(j,i) ];
78 output->
set_label(i, out_idx + m_min_label);
Class Distance, a base class for all the distances used in the Shogun toolbox.
#define SG_NOTIMPLEMENTED
ST * get_feature_vector(int32_t num, int32_t &len, bool &dofree)
bool set_label(int32_t idx, float64_t label)
Multiclass Labels for multi-class classification.
static bool cancel_computations()
int32_t get_num_features() const
virtual int32_t get_num_vectors() const
all of classes and functions are contained in the shogun namespace