iRoCS Toolbox  1.1.0
SVMApplication.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * Copyright (C) 2004-2015 Olaf Ronneberger, Florian Pigorsch, Jörg Mechnich,
4  * Thorsten Falk
5  *
6  * Image Analysis Lab, University of Freiburg, Germany
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  **************************************************************************/
23 
24 /**************************************************************************
25 ** Title:
26 ** $RCSfile$
27 ** $Revision: 589 $$Name$
28 ** $Date: 2005-01-28 15:03:30 +0100 (Fri, 28 Jan 2005) $
29 ** Copyright: GPL $Author: fehr $
30 ** Description:
31 **
32 **
33 **
34 **-------------------------------------------------------------------------
35 **
36 ** $Log$
37 ** Revision 1.5 2005/01/28 14:03:30 fehr
38 ** some include bugfixing for external library use
39 **
40 ** Revision 1.4 2004/09/13 10:04:04 ronneber
41 ** - documentation update
42 **
43 ** Revision 1.3 2004/09/08 14:35:50 ronneber
44 ** - adapted to new ParamInfo class
45 **
46 ** Revision 1.2 2004/09/03 07:15:11 ronneber
47 ** - adapted to new updateCache() interface of Kernels
48 **
49 ** Revision 1.1 2004/08/26 08:36:59 ronneber
50 ** initital import
51 **
52 ** Revision 1.1 2003/05/19 11:09:45 ronneber
53 ** - initial revision
54 **
55 **
56 **
57 **************************************************************************/
58 
59 
60 #ifndef SVMAPPLICATION_HH
61 #define SVMAPPLICATION_HH
62 
63 #ifdef HAVE_CONFIG_H
64 #include <config.hh>
65 #endif
66 
67 #include <string>
68 #include <map>
69 #include <iostream>
70 #include <fstream>
71 #include <vector>
72 
73 #include <cerrno> // errno
74 #include <cstring> // strerror()
75 
76 #include "BasicSVMAdapter.hh"
77 #include "BasicSVMFactory.hh"
78 #include "BasicCVAdapter.hh"
79 #include "BasicCVFactory.hh"
80 #include "GridAxis.hh"
81 #include "GridSearch.hh"
82 #include "HelpExtractor.hh"
84 #include "PrettyOptionPrinter.hh"
85 #include "DirectAccessor.hh"
86 
87 namespace svt
88 {
89 
90  /*======================================================================*/
104  /*======================================================================*/
105  template< typename FV,
106  typename ALGORITHMS,
107  typename LOAD_SAVE_POLICY>
108  class SVMApplication : public LOAD_SAVE_POLICY
109  {
110  public:
111  typedef typename LOAD_SAVE_POLICY::STDATA STDATA;
112 
114  :_prettyPrintColumn(30)
115  {}
116 
117 
118  virtual ~SVMApplication()
119  {}
120 
121  /*======================================================================*/
133  /*======================================================================*/
134  virtual int main( int argc, const char** argv,
135  std::ostream& os = std::cout);
136 
137 
138 
139  /*======================================================================*/
150  /*======================================================================*/
151  virtual int main( StDataCmdLine& cmdLine,
152  std::ostream& os = std::cout);
153 
154 
155  /*======================================================================*/
163  /*======================================================================*/
164  virtual const std::string& programName() const
165  {
166  return _programName;
167  }
168 
169  /*======================================================================*/
176  /*======================================================================*/
177  virtual void setProgramName( const std::string& name)
178  {
179  _programName = name;
180  }
181 
182 
183 
184 
185 
186 
187  /*======================================================================*/
195  /*======================================================================*/
196  virtual void checkWrongParameters( StDataCmdLine& cmdline);
197 
198 
199  /*======================================================================*/
210  /*======================================================================*/
211  virtual int doTraining( StDataCmdLine& cmdline,
212  std::ostream& os = std::cout);
213 
214 
215  /*======================================================================*/
226  /*======================================================================*/
227  virtual int doClassification( StDataCmdLine& cmdline,
228  std::ostream& os = std::cout);
229 
230 
231  /*======================================================================*/
242  /*======================================================================*/
243  virtual int doCrossValidation( StDataCmdLine& cmdline,
244  std::ostream& os = std::cout);
245 
246 
247  /*======================================================================*/
258  /*======================================================================*/
259  virtual int doGridSearch( StDataCmdLine& cmdline,
260  std::ostream& os = std::cout);
261 
262 
263 
264  void setPrettyPrintColumn( int column)
265  {
266  _prettyPrintColumn = column;
267  }
268 
269 
270  private:
271  std::string _programName;
272  int _prettyPrintColumn;
273 
274 
275  };
276 
277 }
278 
279 #include "SVMApplication.icc"
280 
281 
282 #endif
LOAD_SAVE_POLICY::STDATA STDATA
virtual int main(int argc, const char **argv, std::ostream &os=std::cout)
main function for an SVM-Application.
virtual int doClassification(StDataCmdLine &cmdline, std::ostream &os=std::cout)
do Classification with given command line parameters
virtual int doCrossValidation(StDataCmdLine &cmdline, std::ostream &os=std::cout)
do cross validation with given command line parameters
virtual int doTraining(StDataCmdLine &cmdline, std::ostream &os=std::cout)
do Training with given command line parameters
The SVMApplication class specifies a complete command line application.
virtual const std::string & programName() const
return the name of the shell program.
virtual int doGridSearch(StDataCmdLine &cmdline, std::ostream &os=std::cout)
do cross validation with given command line parameters
void setPrettyPrintColumn(int column)
virtual void checkWrongParameters(StDataCmdLine &cmdline)
check for wrong ( = unused) parameters in cmdline
virtual void setProgramName(const std::string &name)
Overwrite program name that was extracted from argv[0].