SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
DimensionReductionPreprocessor.cpp
Go to the documentation of this file.
5 
6 using namespace shogun;
7 
8 namespace shogun
9 {
12 {
13  m_target_dim = 1;
15  m_kernel = new CLinearKernel();
16  m_converter = NULL;
17 
18  initialize();
19 }
20 
23 {
24  SG_REF(converter);
25  m_target_dim = 1;
27  m_kernel = new CLinearKernel();
28  m_converter = converter;
29 
30  initialize();
31 }
32 
34 {
38 }
39 
41 {
42  if (m_converter)
43  {
45  CDenseFeatures<float64_t>* embedding = m_converter->embed(features);
46  SGMatrix<float64_t> embedding_feature_matrix = embedding->steal_feature_matrix();
47  ((CDenseFeatures<float64_t>*)features)->set_feature_matrix(embedding_feature_matrix);
48  delete embedding;
49  return embedding_feature_matrix;
50  }
51  else
52  {
53  SG_WARNING("Converter to process was not set.\n")
54  return ((CDenseFeatures<float64_t>*)features)->get_feature_matrix();
55  }
56 }
57 
58 bool CDimensionReductionPreprocessor::init(CFeatures* data)
59 {
60  return true;
61 }
62 
64 {
65 
66 }
67 
69 
71 {
72  ASSERT(dim>0)
73  m_target_dim = dim;
74 }
75 
77 {
78  return m_target_dim;
79 }
80 
82 {
83  SG_REF(distance);
86 }
87 
89 {
91  return m_distance;
92 }
93 
95 {
96  SG_REF(kernel);
98  m_kernel = kernel;
99 }
100 
102 {
103  SG_REF(m_kernel);
104  return m_kernel;
105 }
106 
107 void CDimensionReductionPreprocessor::initialize()
108 {
109  SG_ADD((CSGObject**)&m_converter, "converter",
110  "embedding converter used to apply to data", MS_AVAILABLE);
111  SG_ADD(&m_target_dim, "target_dim",
112  "target dimensionality of preprocessor", MS_AVAILABLE);
113  SG_ADD((CSGObject**)&m_distance, "distance",
114  "distance to be used for embedding", MS_AVAILABLE);
115  SG_ADD((CSGObject**)&m_kernel, "kernel",
116  "kernel to be used for embedding", MS_AVAILABLE);
117 }
118 }
float distance(CJLCoverTreePoint p1, CJLCoverTreePoint p2, float64_t upper_bound)
Computes the standard linear kernel on CDotFeatures.
Definition: LinearKernel.h:35
EPreprocessorType
Definition: Preprocessor.h:32
Class Distance, a base class for all the distances used in the Shogun toolbox.
Definition: Distance.h:81
class EmbeddingConverter (part of the Efficient Dimensionality Reduction Toolkit) used to construct e...
#define SG_REF(x)
Definition: SGObject.h:51
#define ASSERT(x)
Definition: SGIO.h:201
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:112
Template class DensePreprocessor, base class for preprocessors (cf. CPreprocessor) that apply to CDen...
double float64_t
Definition: common.h:50
#define SG_UNREF(x)
Definition: SGObject.h:52
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual CDenseFeatures< float64_t > * embed(CFeatures *features)
The class Features is the base class of all feature objects.
Definition: Features.h:68
The Kernel base class.
Definition: Kernel.h:158
#define SG_WARNING(...)
Definition: SGIO.h:128
#define SG_ADD(...)
Definition: SGObject.h:81
SGMatrix< ST > steal_feature_matrix()
class EuclideanDistance
virtual SGMatrix< float64_t > apply_to_feature_matrix(CFeatures *features)

SHOGUN Machine Learning Toolbox - Documentation