SHOGUN  v3.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  CStructuredLabels* labs)
25 : CStructuredOutputMachine(model, labs)
26 {
27  register_parameters();
28 }
29 
31 {
32 }
33 
35 {
36  m_w = w;
37 }
38 
40 {
41  return m_w;
42 }
43 
45 {
46  if (data)
47  {
48  set_features(data);
49  }
50 
51  CStructuredLabels* out;
52  CFeatures* model_features = this->get_features();
53  if (!model_features)
54  {
55  out = new CStructuredLabels();
56  }
57  else
58  {
59  out = new CStructuredLabels(model_features->get_num_vectors());
60  for ( int32_t i = 0 ; i < model_features->get_num_vectors() ; ++i )
61  {
62  CResultSet* result = m_model->argmax(m_w, i, false);
63  out->add_label(result->argmax);
64 
65  SG_UNREF(result);
66  }
67  }
68  SG_UNREF(model_features);
69  return out;
70 }
71 
72 void CLinearStructuredOutputMachine::register_parameters()
73 {
74  SG_ADD(&m_w, "m_w", "Weight vector", MS_NOT_AVAILABLE);
75 }
76 
78 {
79 }

SHOGUN Machine Learning Toolbox - Documentation