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>
24 
25 namespace shogun
26 {
27 
28 #define IGNORE_IN_CLASSLIST
29 
40  TMultipleCPinfo(uint32_t from, uint32_t N) : m_from(from), m_N(N) { }
42  uint32_t m_from;
44  uint32_t m_N;
45 };
46 
47 class CStructuredModel;
48 
50 struct CResultSet : public CSGObject
51 {
53  CResultSet();
54 
56  virtual ~CResultSet();
57 
59  virtual const char* get_name() const;
60 
63 
66 
69 
73 
76 };
77 
89 {
90  public:
93 
99  CStructuredModel(CFeatures* features, CStructuredLabels* labels);
100 
102  virtual ~CStructuredModel();
103 
115  virtual void init_primal_opt(
116  float64_t regularization,
121 
126  virtual int32_t get_dim() const = 0;
127 
132  void set_labels(CStructuredLabels* labs);
133 
139 
141  virtual CStructuredLabels* structured_labels_factory(int32_t num_labels=0);
142 
147  void set_features(CFeatures* feats);
148 
154 
167  SGVector< float64_t > get_joint_feature_vector(int32_t feat_idx, int32_t lab_idx);
168 
181  virtual SGVector< float64_t > get_joint_feature_vector(int32_t feat_idx, CStructuredData* y);
182 
196  virtual CResultSet* argmax(SGVector< float64_t > w, int32_t feat_idx, bool const training = true) = 0;
197 
205  float64_t delta_loss(int32_t ytrue_idx, CStructuredData* ypred);
206 
215 
217  virtual const char* get_name() const { return "StructuredModel"; }
218 
223  virtual void init_training();
224 
232  virtual bool check_training_setup() const;
233 
243  virtual int32_t get_num_aux() const;
244 
254  virtual int32_t get_num_aux_con() const;
255 
256  private:
258  void init();
259 
260  protected:
263 
266 
267 }; /* class CStructuredModel */
268 
269 } /* namespace shogun */
270 
271 #endif /* _STRUCTURED_MODEL__H__ */

SHOGUN Machine Learning Toolbox - Documentation