SHOGUN  v2.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 : CSGObject(), ui(ui_), estimator(NULL),
23  pos_pseudo(1e-10), neg_pseudo(1e-10)
24 {
25 }
26 
28 {
30 }
31 
33 {
35  estimator=new CPluginEstimate(pos, neg);
37 
38  if (!estimator)
39  SG_ERROR("Could not create new plugin estimator, pos_pseudo %f, neg_pseudo %f\n", pos_pseudo, neg_pseudo);
40  else
41  SG_INFO("Created new plugin estimator (%p), pos_pseudo %f, neg_pseudo %f\n", estimator, pos_pseudo, neg_pseudo);
42 
43  return true;
44 }
45 
47 {
48  CLabels* trainlabels=ui->ui_labels->get_train_labels();
50  ui_features->get_train_features();
51  bool result=false;
52 
53  if (!trainlabels)
54  SG_ERROR("No labels available.\n");
55 
56  if (!trainfeatures)
57  SG_ERROR("No features available.\n");
58 
59  ASSERT(trainfeatures->get_feature_type()==F_WORD);
60 
61  estimator->set_features(trainfeatures);
62  estimator->set_labels(trainlabels);
63  if (estimator)
64  result=estimator->train();
65  else
66  SG_ERROR("No estimator available.\n");
67 
68  return result;
69 }
70 
71 bool CGUIPluginEstimate::load(char* param)
72 {
73  bool result=false;
74  return result;
75 }
76 
77 bool CGUIPluginEstimate::save(char* param)
78 {
79  bool result=false;
80  return result;
81 }
82 
84 {
85  CFeatures* testfeatures=ui->ui_features->get_test_features();
86 
87  if (!estimator)
88  {
89  SG_ERROR( "no estimator available") ;
90  return 0;
91  }
92 
93  if (!testfeatures)
94  {
95  SG_ERROR( "no test features available") ;
96  return 0;
97  }
98 
100 
101  return estimator->apply();
102 }
103 
105 {
106  CFeatures* testfeatures=ui->ui_features->get_test_features();
107 
108  if (!estimator)
109  {
110  SG_ERROR( "no estimator available") ;
111  return 0;
112  }
113 
114  if (!testfeatures)
115  {
116  SG_ERROR( "no test features available") ;
117  return 0;
118  }
119 
121 
122  return estimator->apply_one(idx);
123 }

SHOGUN Machine Learning Toolbox - Documentation