SHOGUN  4.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
HierarchicalMultilabelModel.h
Go to the documentation of this file.
1 /*
2  * This software is distributed under BSD 3-clause license (see LICENSE file).
3  *
4  * Copyright(C) 2014 Abinash Panda
5  * Copyright(C) 2014 Thoralf Klein
6  * Written(W) 2014 Abinash Panda
7  */
8 
9 #ifndef _HIERARCHICAL_MULTILABEL_MODEL__H__
10 #define _HIERARCHICAL_MULTILABEL_MODEL__H__
11 
12 #include <shogun/lib/config.h>
14 
15 namespace shogun
16 {
17 
30 {
31 public:
34 
48  SGVector<int32_t> taxonomy, bool leaf_nodes_mandatory = false);
49 
52 
54  virtual CStructuredLabels * structured_labels_factory(int32_t num_labels = 0);
55 
59  virtual int32_t get_dim() const;
60 
72  virtual SGVector<float64_t> get_joint_feature_vector(int32_t feat_idx,
73  CStructuredData * y);
74 
85  virtual CResultSet * argmax(SGVector<float64_t> w, int32_t feat_idx,
86  bool const training = true);
87 
96 
108  virtual void init_primal_opt(
109  float64_t regularization,
117 
119  virtual const char * get_name() const
120  {
121  return "HierarchicalMultilabelModel";
122  }
123 
124 private:
125  int32_t m_num_classes;
126  SGVector<int32_t> m_taxonomy;
127  bool m_leaf_nodes_mandatory;
128  int32_t m_root;
129  // array for vectors storing the node-ids of the children
130  // m_children[node_id] = vector of node_ids of the children
131  // = empty vector, if node is a terminal node
132  SGVector<int32_t> * m_children;
133 
134 private:
135  void init(SGVector<int32_t> taxonomy, bool leaf_nodes_mandatory);
136 
139  float64_t delta_loss(int32_t y1, int32_t y2);
140 
147  SGVector<int32_t> get_label_vector(SGVector<int32_t> sparse_label);
148 
149 }; /* class CHierarchicalMultilabelModel */
150 
151 } /* namespace shogun */
152 
153 #endif /* _HIERARCHICAL_MULTILABEL_MODEL__H__ */
154 
155 
Base class of the labels used in Structured Output (SO) problems.
virtual CStructuredLabels * structured_labels_factory(int32_t num_labels=0)
virtual SGVector< float64_t > get_joint_feature_vector(int32_t feat_idx, CStructuredData *y)
virtual void init_primal_opt(float64_t regularization, SGMatrix< float64_t > &A, SGVector< float64_t > a, SGMatrix< float64_t > B, SGVector< float64_t > &b, SGVector< float64_t > &lb, SGVector< float64_t > &ub, SGMatrix< float64_t > &C)
double float64_t
Definition: common.h:50
Class CStructuredModel that represents the application specific model and contains most of the applic...
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual CResultSet * argmax(SGVector< float64_t > w, int32_t feat_idx, bool const training=true)
virtual float64_t delta_loss(CStructuredData *y1, CStructuredData *y2)
The class Features is the base class of all feature objects.
Definition: Features.h:68
Class CHierarchicalMultilabelModel represents application specific model and contains application dep...
Base class of the components of StructuredLabels.

SHOGUN Machine Learning Toolbox - Documentation