SHOGUN  6.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
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 using namespace shogun;
16 
19 {
20 }
21 
24 {
25  set_kernel(kernel);
26 }
27 
29 {
30  return "KernelLocallyLinearEmbedding";
31 };
32 
34 {
35 }
36 
38 {
39  ASSERT(features)
40  SG_REF(features);
41 
42  // get dimensionality and number of vectors of data
43  int32_t N = features->get_num_vectors();
44  if (m_k>=N)
45  SG_ERROR("Number of neighbors (%d) should be less than number of objects (%d).\n",
46  m_k, N);
47 
48  // compute kernel matrix
50  m_kernel->init(features,features);
52  m_kernel->cleanup();
53  SG_UNREF(features);
54  return (CFeatures*)embedding;
55 }
56 
58 {
59  TAPKEE_PARAMETERS_FOR_SHOGUN parameters;
60  parameters.n_neighbors = m_k;
61  parameters.eigenshift = m_nullspace_shift;
62  parameters.method = SHOGUN_KERNEL_LOCALLY_LINEAR_EMBEDDING;
63  parameters.target_dimension = m_target_dim;
64  parameters.kernel = kernel;
65  CDenseFeatures<float64_t>* embedding = tapkee_embed(parameters);
66  return embedding;
67 }
68 
virtual bool init(CFeatures *lhs, CFeatures *rhs)
Definition: Kernel.cpp:96
virtual void cleanup()
Definition: Kernel.cpp:171
virtual CFeatures * apply(CFeatures *features)
virtual int32_t get_num_vectors() const =0
#define SG_ERROR(...)
Definition: SGIO.h:128
#define SG_REF(x)
Definition: SGObject.h:52
void set_kernel(CKernel *kernel)
#define ASSERT(x)
Definition: SGIO.h:200
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:53
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.

SHOGUN Machine Learning Toolbox - Documentation