SHOGUN  v3.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GUIPluginEstimate.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) 1999-2008 Soeren Sonnenburg
8  * Written (W) 1999-2008 Gunnar Raetsch
9  * Copyright (C) 1999-2008 Fraunhofer Institute FIRST and Max-Planck-Society
10  */
11 
12 #include <shogun/ui/SGInterface.h>
14 
15 #include <shogun/lib/config.h>
16 #include <shogun/io/SGIO.h>
18 
19 using namespace shogun;
20 
22 {
23  init();
24 }
25 
27 : CSGObject()
28 {
29  init();
30 
31  ui=ui_;
32 }
33 
35 {
37 }
38 
39 void CGUIPluginEstimate::init()
40 {
41  ui=NULL;
42  estimator=NULL;
43  pos_pseudo=1e-10;
44  neg_pseudo=1e-10;
45 }
46 
48 {
50  estimator=new CPluginEstimate(pos, neg);
52 
53  if (!estimator)
54  SG_ERROR("Could not create new plugin estimator, pos_pseudo %f, neg_pseudo %f\n", pos_pseudo, neg_pseudo)
55  else
56  SG_INFO("Created new plugin estimator (%p), pos_pseudo %f, neg_pseudo %f\n", estimator, pos_pseudo, neg_pseudo)
57 
58  return true;
59 }
60 
62 {
63  CLabels* trainlabels=ui->ui_labels->get_train_labels();
65  ui_features->get_train_features();
66  bool result=false;
67 
68  if (!trainlabels)
69  SG_ERROR("No labels available.\n")
70 
71  if (!trainfeatures)
72  SG_ERROR("No features available.\n")
73 
74  ASSERT(trainfeatures->get_feature_type()==F_WORD)
75 
76  estimator->set_features(trainfeatures);
77  estimator->set_labels(trainlabels);
78  if (estimator)
79  result=estimator->train();
80  else
81  SG_ERROR("No estimator available.\n")
82 
83  return result;
84 }
85 
86 bool CGUIPluginEstimate::load(char* param)
87 {
88  bool result=false;
89  return result;
90 }
91 
92 bool CGUIPluginEstimate::save(char* param)
93 {
94  bool result=false;
95  return result;
96 }
97 
99 {
100  CFeatures* testfeatures=ui->ui_features->get_test_features();
101 
102  if (!estimator)
103  {
104  SG_ERROR("no estimator available")
105  return 0;
106  }
107 
108  if (!testfeatures)
109  {
110  SG_ERROR("no test features available")
111  return 0;
112  }
113 
115 
116  return estimator->apply();
117 }
118 
120 {
121  CFeatures* testfeatures=ui->ui_features->get_test_features();
122 
123  if (!estimator)
124  {
125  SG_ERROR("no estimator available")
126  return 0;
127  }
128 
129  if (!testfeatures)
130  {
131  SG_ERROR("no test features available")
132  return 0;
133  }
134 
136 
137  return estimator->apply_one(idx);
138 }

SHOGUN Machine Learning Toolbox - Documentation