SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 #include <shogun/io/SGIO.h>
13 #include <shogun/lib/tapkee/tapkee_shogun.hpp>
14 
15 #ifdef HAVE_PTHREAD
16 #include <pthread.h>
17 #endif
18 
19 using namespace shogun;
20 
23 {
24 }
25 
28 {
29  set_kernel(kernel);
30 }
31 
33 {
34  return "KernelLocallyLinearEmbedding";
35 };
36 
38 {
39 }
40 
42 {
43  ASSERT(features)
44  SG_REF(features);
45 
46  // get dimensionality and number of vectors of data
47  int32_t N = features->get_num_vectors();
48  if (m_k>=N)
49  SG_ERROR("Number of neighbors (%d) should be less than number of objects (%d).\n",
50  m_k, N);
51 
52  // compute kernel matrix
54  m_kernel->init(features,features);
56  m_kernel->cleanup();
57  SG_UNREF(features);
58  return (CFeatures*)embedding;
59 }
60 
62 {
63  TAPKEE_PARAMETERS_FOR_SHOGUN parameters;
64  parameters.n_neighbors = m_k;
65  parameters.eigenshift = m_nullspace_shift;
66  parameters.method = SHOGUN_KERNEL_LOCALLY_LINEAR_EMBEDDING;
67  parameters.target_dimension = m_target_dim;
68  parameters.kernel = kernel;
69  CDenseFeatures<float64_t>* embedding = tapkee_embed(parameters);
70  return embedding;
71 }
72 
virtual bool init(CFeatures *lhs, CFeatures *rhs)
Definition: Kernel.cpp:98
virtual void cleanup()
Definition: Kernel.cpp:173
virtual CFeatures * apply(CFeatures *features)
virtual int32_t get_num_vectors() const =0
#define SG_ERROR(...)
Definition: SGIO.h:129
#define SG_REF(x)
Definition: SGObject.h:54
void set_kernel(CKernel *kernel)
#define ASSERT(x)
Definition: SGIO.h:201
class LocallyLinearEmbedding used to embed data using Locally Linear Embedding algorithm described in...
CDenseFeatures< float64_t > * embed_kernel(CKernel *kernel)
#define SG_UNREF(x)
Definition: SGObject.h:55
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
The class Features is the base class of all feature objects.
Definition: Features.h:68
The Kernel base class.
Definition: Kernel.h:159

SHOGUN Machine Learning Toolbox - Documentation