SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StructuredModel.h
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) 2012 Fernando José Iglesias García
8  * Copyright (C) 2012 Fernando José Iglesias García
9  */
10 
11 #ifndef _STRUCTURED_MODEL__H__
12 #define _STRUCTURED_MODEL__H__
13 
14 #include <shogun/lib/config.h>
15 
16 #include <shogun/base/SGObject.h>
19 
20 #include <shogun/lib/common.h>
21 #include <shogun/lib/SGVector.h>
22 #include <shogun/lib/SGMatrix.h>
25 
26 namespace shogun
27 {
28 
29 #define IGNORE_IN_CLASSLIST
30 
41  TMultipleCPinfo(uint32_t from, uint32_t N) : m_from(from), m_N(N) { }
43  uint32_t m_from;
45  uint32_t m_N;
46 };
47 
48 class CStructuredModel;
49 
51 struct CResultSet : public CSGObject
52 {
54  CResultSet();
55 
57  virtual ~CResultSet();
58 
60  virtual const char* get_name() const;
61 
64 
67 
70 
73 
76 
79 
82 
86 
89 };
90 
102 {
103  public:
106 
112  CStructuredModel(CFeatures* features, CStructuredLabels* labels);
113 
115  virtual ~CStructuredModel();
116 
128  virtual void init_primal_opt(
129  float64_t regularization,
134 
139  virtual int32_t get_dim() const = 0;
140 
145  void set_labels(CStructuredLabels* labs);
146 
152 
154  virtual CStructuredLabels* structured_labels_factory(int32_t num_labels=0);
155 
160  void set_features(CFeatures* feats);
161 
167 
180  SGVector< float64_t > get_joint_feature_vector(int32_t feat_idx, int32_t lab_idx);
181 
194  virtual SGVector< float64_t > get_joint_feature_vector(int32_t feat_idx, CStructuredData* y);
195 
209  int32_t lab_idx);
210 
224  CStructuredData* y);
225 
239  virtual CResultSet* argmax(SGVector< float64_t > w, int32_t feat_idx, bool const training = true) = 0;
240 
248  float64_t delta_loss(int32_t ytrue_idx, CStructuredData* ypred);
249 
258 
260  virtual const char* get_name() const { return "StructuredModel"; }
261 
266  virtual void init_training();
267 
275  virtual bool check_training_setup() const;
276 
286  virtual int32_t get_num_aux() const;
287 
297  virtual int32_t get_num_aux_con() const;
298 
299  private:
301  void init();
302 
303  protected:
306 
309 
310 }; /* class CStructuredModel */
311 
312 } /* namespace shogun */
313 
314 #endif /* _STRUCTURED_MODEL__H__ */

SHOGUN Machine Learning Toolbox - Documentation