SHOGUN  v2.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 #include <shogun/lib/SGVector.h>
19 
20 namespace shogun
21 {
22 
23 #define IGNORE_IN_CLASSLIST
24 
31  uint32_t _from;
33  uint32_t N;
34 };
35 
36 class CStructuredModel;
37 
39 struct CResultSet : public CSGObject
40 {
42  CResultSet() : CSGObject(), argmax(NULL) { };
43 
45  virtual ~CResultSet() { SG_UNREF(argmax) }
46 
49 
52 
55 
59 
62 
64  virtual const char* get_name() const { return "ResultSet"; }
65 };
66 
78 {
79  public:
82 
88  CStructuredModel(CFeatures* features, CStructuredLabels* labels);
89 
91  virtual ~CStructuredModel();
92 
103  virtual void init_opt(
108 
113  virtual int32_t get_dim() const = 0;
114 
119  void set_labels(CStructuredLabels* labs);
120 
126 
131  void set_features(CFeatures* feats);
132 
138 
151  SGVector< float64_t > get_joint_feature_vector(int32_t feat_idx, int32_t lab_idx);
152 
165  virtual SGVector< float64_t > get_joint_feature_vector(int32_t feat_idx, CStructuredData* y);
166 
180  virtual CResultSet* argmax(SGVector< float64_t > w, int32_t feat_idx, bool const training = true) = 0;
181 
189  float64_t delta_loss(int32_t ytrue_idx, CStructuredData* ypred);
190 
199 
201  virtual const char* get_name() const { return "StructuredModel"; }
202 
210  virtual bool check_training_setup() const;
211 
221  virtual int32_t get_num_aux() const;
222 
232  virtual int32_t get_num_aux_con() const;
233 
241  virtual float64_t risk(float64_t* subgrad, float64_t* W, TMultipleCPinfo* info=0);
242 
243  private:
245  void init();
246 
247  protected:
250 
253 
254 }; /* class CStructuredModel */
255 
256 } /* namespace shogun */
257 
258 #endif /* _STRUCTURED_MODEL__H__ */

SHOGUN Machine Learning Toolbox - Documentation