SHOGUN  v2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
InferenceMethod.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  * Copyright (C) 2012 Jacob Walker
8  */
9 
11 #ifdef HAVE_EIGEN3
17 
18 using namespace shogun;
19 
21 {
22  init();
23 
24  m_kernel = NULL;
25  m_model = NULL;
26  m_labels = NULL;
27  m_features = NULL;
28  m_latent_features = NULL;
29  m_mean = NULL;
30 }
31 
33  CMeanFunction* m, CLabels* lab, CLikelihoodModel* mod)
34 {
35  init();
36 
37  set_kernel(kern);
38  set_features(feat);
39  set_labels(lab);
40  set_model(mod);
41  set_mean(m);
42 }
43 
45 {
52 }
53 
54 void CInferenceMethod::init()
55 {
56  SG_ADD((CSGObject**)&m_kernel, "kernel", "Kernel", MS_AVAILABLE);
57  SG_ADD(&m_scale, "scale", "Kernel Scale", MS_AVAILABLE);
58  SG_ADD((CSGObject**)&m_model, "likelihood_model", "Likelihood model",
59  MS_AVAILABLE);
60  SG_ADD((CSGObject**)&m_labels, "labels", "Labels", MS_NOT_AVAILABLE);
61  SG_ADD((CSGObject**)&m_features, "features", "Features", MS_NOT_AVAILABLE);
62  SG_ADD((CSGObject**)&m_latent_features, "latent_features", "latent Features", MS_NOT_AVAILABLE);
63  SG_ADD((CSGObject**)&m_mean, "mean_function", "Mean Function", MS_NOT_AVAILABLE);
64 
65  m_kernel = NULL;
66  m_model = NULL;
67  m_labels = NULL;
68  m_features = NULL;
69  m_latent_features = NULL;
70  m_mean = NULL;
71  m_scale = 1.0;
72 }
73 
75 {
76  SG_REF(feat);
78  m_features=feat;
79 
82  ((CDotFeatures*)m_features)->get_computed_dot_feature_matrix();
83 
85  {
86  CDotFeatures* subfeat =
88  get_first_feature_obj();
89 
92 
93  SG_UNREF(subfeat);
94  }
95 
98  update_chol();
99  update_alpha();
100 }
101 
103 {
104  SG_REF(feat);
106  m_latent_features=feat;
107 
110  ((CDotFeatures*)m_latent_features)->get_computed_dot_feature_matrix();
111 
113  {
114  CDotFeatures* subfeat =
116  get_first_feature_obj();
117 
120 
121  SG_UNREF(subfeat);
122  }
123 
126  update_chol();
127  update_alpha();
128 }
129 
131 {
132  SG_REF(kern);
134  m_kernel = kern;
136  update_chol();
137  update_alpha();
138 }
139 
141 {
142  SG_REF(m);
143  SG_UNREF(m_mean);
144  m_mean = m;
145 
147  update_chol();
148  update_alpha();
149 }
150 
152 {
153  SG_REF(lab);
155  m_labels = lab;
156 
157  if (m_labels)
158  {
160  ((CRegressionLabels*) m_labels)->get_labels().clone();
161  }
162 
164  update_alpha();
165 }
166 
168 {
169  SG_REF(mod);
170  SG_UNREF(m_model);
171  m_model = mod;
173  update_chol();
174  update_alpha();
175 }
176 
178 {
180  m_scale = s;
181  update_chol();
182  update_alpha();
183 }
184 
186 {
187  if (m_mean)
188  {
189  m_data_means =
191 
192 
194  {
195  for (index_t i = 0; i < m_label_vector.vlen; i++)
196  m_label_vector[i] -= m_data_means[i];
197  }
198  }
199 }
200 #endif /* HAVE_EIGEN3 */

SHOGUN Machine Learning Toolbox - Documentation