SHOGUN  v3.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  init();
19 }
20 
23 {
24  SG_REF(converter);
25  m_target_dim = 1;
27  m_kernel = new CLinearKernel();
28  m_converter = converter;
29 
30  init();
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 
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 
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 }

SHOGUN Machine Learning Toolbox - Documentation