SHOGUN  v3.0.0
 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/base/SGObject.h>
17 
18 #include <shogun/lib/common.h>
19 #include <shogun/lib/SGVector.h>
21 
22 namespace shogun
23 {
24 
25 #define IGNORE_IN_CLASSLIST
26 
37  TMultipleCPinfo(uint32_t from, uint32_t N) : m_from(from), m_N(N) { }
39  uint32_t m_from;
41  uint32_t m_N;
42 };
43 
44 class CStructuredModel;
45 
47 struct CResultSet : public CSGObject
48 {
50  CResultSet();
51 
53  virtual ~CResultSet();
54 
56  virtual const char* get_name() const;
57 
60 
63 
66 
70 
73 };
74 
86 {
87  public:
90 
96  CStructuredModel(CFeatures* features, CStructuredLabels* labels);
97 
99  virtual ~CStructuredModel();
100 
112  virtual void init_primal_opt(
113  float64_t regularization,
118 
123  virtual int32_t get_dim() const = 0;
124 
129  void set_labels(CStructuredLabels* labs);
130 
136 
141  void set_features(CFeatures* feats);
142 
148 
161  SGVector< float64_t > get_joint_feature_vector(int32_t feat_idx, int32_t lab_idx);
162 
175  virtual SGVector< float64_t > get_joint_feature_vector(int32_t feat_idx, CStructuredData* y);
176 
190  virtual CResultSet* argmax(SGVector< float64_t > w, int32_t feat_idx, bool const training = true) = 0;
191 
199  float64_t delta_loss(int32_t ytrue_idx, CStructuredData* ypred);
200 
209 
211  virtual const char* get_name() const { return "StructuredModel"; }
212 
217  virtual void init_training();
218 
226  virtual bool check_training_setup() const;
227 
237  virtual int32_t get_num_aux() const;
238 
248  virtual int32_t get_num_aux_con() const;
249 
250  private:
252  void init();
253 
254  protected:
257 
260 
261 }; /* class CStructuredModel */
262 
263 } /* namespace shogun */
264 
265 #endif /* _STRUCTURED_MODEL__H__ */

SHOGUN Machine Learning Toolbox - Documentation