SHOGUN  v3.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KernelLocallyLinearEmbedding.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2011-2013 Sergey Lisitsyn
8  * Copyright (C) 2011-2013 Berlin Institute of Technology and Max-Planck-Society
9  */
10 
12 #ifdef HAVE_EIGEN3
13 #include <shogun/io/SGIO.h>
14 #include <shogun/lib/tapkee/tapkee_shogun.hpp>
15 
16 #ifdef HAVE_PTHREAD
17 #include <pthread.h>
18 #endif
19 
20 using namespace shogun;
21 
24 {
25 }
26 
29 {
30  set_kernel(kernel);
31 }
32 
34 {
35  return "KernelLocallyLinearEmbedding";
36 };
37 
39 {
40 }
41 
43 {
44  ASSERT(features)
45  SG_REF(features);
46 
47  // get dimensionality and number of vectors of data
48  int32_t N = features->get_num_vectors();
49  if (m_k>=N)
50  SG_ERROR("Number of neighbors (%d) should be less than number of objects (%d).\n",
51  m_k, N);
52 
53  // compute kernel matrix
55  m_kernel->init(features,features);
57  m_kernel->cleanup();
58  SG_UNREF(features);
59  return (CFeatures*)embedding;
60 }
61 
63 {
64  TAPKEE_PARAMETERS_FOR_SHOGUN parameters;
65  parameters.n_neighbors = m_k;
66  parameters.eigenshift = m_nullspace_shift;
67  parameters.method = SHOGUN_KERNEL_LOCALLY_LINEAR_EMBEDDING;
68  parameters.target_dimension = m_target_dim;
69  parameters.kernel = kernel;
70  CDenseFeatures<float64_t>* embedding = tapkee_embed(parameters);
71  return embedding;
72 }
73 
74 #endif /* HAVE_EIGEN3 */

SHOGUN Machine Learning Toolbox - Documentation