SHOGUN  v2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LinearStructuredOutputMachine.cpp
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 
13 
14 using namespace shogun;
15 
18 {
19  register_parameters();
20 }
21 
23  CStructuredModel* model,
24  CLossFunction* loss,
25  CStructuredLabels* labs)
26 : CStructuredOutputMachine(model, loss, labs)
27 {
28  register_parameters();
29 }
30 
32 {
33 }
34 
36 {
38 }
39 
41 {
42  return m_model->get_features();
43 }
44 
46 {
47  return m_w;
48 }
49 
51 {
52  if (data)
53  {
54  set_features(data);
55  }
56 
57  CStructuredLabels* out;
58  CFeatures* model_features = this->get_features();
59  if (!model_features)
60  {
61  out = new CStructuredLabels();
62  }
63  else
64  {
65  out = new CStructuredLabels(model_features->get_num_vectors());
66  for ( int32_t i = 0 ; i < model_features->get_num_vectors() ; ++i )
67  {
68  CResultSet* result = m_model->argmax(m_w, i, false);
69  out->add_label(result->argmax);
70 
71  SG_UNREF(result);
72  }
73  }
74  SG_UNREF(model_features);
75  return out;
76 }
77 
78 void CLinearStructuredOutputMachine::register_parameters()
79 {
80  SG_ADD(&m_w, "m_w", "Weight vector", MS_NOT_AVAILABLE);
81 }

SHOGUN Machine Learning Toolbox - Documentation