iRoCS Toolbox  1.1.0
BasicCVAdapterTempl.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: 752 $$Name$
28 ** $Date: 2005-10-25 14:09:55 +0200 (Tue, 25 Oct 2005) $
29 ** Copyright: GPL $Author: ronneber $
30 ** Description:
31 **
32 **
33 **
34 **-------------------------------------------------------------------------
35 **
36 ** $Log$
37 ** Revision 1.4 2005/10/25 12:09:55 ronneber
38 ** - added classificationDetailsByUID() and
39 ** get/setStoreClassificationDetailsFlag()
40 **
41 ** Revision 1.3 2005/03/29 17:49:42 ronneber
42 ** - added updateKernelCache() and clearKernelCache()
43 **
44 ** Revision 1.2 2004/09/08 14:12:58 ronneber
45 ** - added saveOnlyKernelParameters()
46 **
47 ** Revision 1.1 2004/08/26 08:36:58 ronneber
48 ** initital import
49 **
50 **
51 **
52 **************************************************************************/
53 
54 #ifndef BASICCVADAPTERTEMPL_HH
55 #define BASICCVADAPTERTEMPL_HH
56 
57 #ifdef HAVE_CONFIG_H
58 #include <config.hh>
59 #endif
60 
61 #include "BasicCVAdapter.hh"
62 #include "CrossValidator.hh"
63 
64 namespace svt
65 {
66  template<typename FV,
67  typename PROBLEM,
68  typename STDATA,
69  typename SVMTYPE>
70  class BasicCVAdapterTempl : public BasicCVAdapter<FV,PROBLEM,STDATA>
71  {
72  public:
74  {
75  _cv.setProgressReporter( pr);
76  }
77 
78  virtual void loadParameters( STDATA& stData)
79  {
80  _cv.loadParameters( stData);
81  }
82 
83  virtual void loadParameters( StDataASCII& stData)
84  {
85  _cv.loadParameters( stData);
86  }
87 
88  virtual void loadParameters( StDataCmdLine& stData)
89  {
90  _cv.loadParameters( stData);
91  }
92 
93  virtual void saveParameters( STDATA& stData)
94  {
95  _cv.saveParameters( stData);
96  }
97 
98  virtual void saveParameters( StDataASCII& stData)
99  {
100  _cv.saveParameters( stData);
101  }
102 
103  virtual void saveOnlyKernelParameters( StDataASCII& stData)
104  {
105  _cv.svm()->twoClassSVM().kernel().saveParameters( stData);
106  }
107 
108  virtual void setTrainingData( const PROBLEM* problem)
109  {
110  _cv.setTrainingData( problem);
111  }
112 
113  virtual const PROBLEM* trainingData() const
114  {
115  return _cv.trainingData();
116  }
117 
118  virtual void updateKernelCache()
119  {
120  _cv.updateKernelCache();
121  }
122 
123  virtual void clearKernelCache()
124  {
125  _cv.clearKernelCache();
126  }
127 
128 
129  virtual void preprocessTrainingData()
130  {
131  _cv.preprocessTrainingData();
132  }
133 
134  virtual int doFullCV( const std::vector<int>& subsetIndexByUID,
135  std::vector<double>& predictedClassLabelByUID)
136  {
137  return _cv.doFullCV( subsetIndexByUID, predictedClassLabelByUID);
138  }
139 
140  virtual void setClassificationDelta( double d)
141  {
142  _cv.setClassificationDelta(d);
143  }
144 
145  virtual double classificationDelta() const
146  {
147  return _cv.classificationDelta();
148  }
149 
150  virtual void setStoreClassificationDetailsFlag( bool f)
151  {
152  _cv.setStoreClassificationDetailsFlag(f);
153  }
154 
156  {
157  return _cv.getStoreClassificationDetailsFlag();
158  }
159 
160  virtual void saveStatistics( STDATA& statistics,
161  int detailLevel=1)
162  {
163  _cv.saveStatistics( statistics, detailLevel);
164  }
165 
166  virtual void saveStatistics( StDataASCII& statistics,
167  int detailLevel=1)
168  {
169  _cv.saveStatistics( statistics, detailLevel);
170  }
171 
172  virtual const std::vector< StDataASCII>& classificationDetailsByUID() const
173  {
174  return _cv.classificationDetailsByUID();
175  }
176 
177 
178  private:
180  };
181 }
182 
183 #endif
184 
185 
186 
187 
188 
virtual void loadParameters(StDataASCII &stData)
virtual void saveOnlyKernelParameters(StDataASCII &stData)
save only Kernel Parameters (this is used for user information and to detect in grid search...
virtual void saveParameters(StDataASCII &stData)
virtual void updateKernelCache()
call updateKernelCache() of selected svm with given problem.
The CrossValidator class provides a highly optimized cross validation algorithm.
virtual double classificationDelta() const
virtual void loadParameters(StDataCmdLine &stData)
Same as loadParameters, but for Parameters from command line.
virtual void saveParameters(STDATA &stData)
store all parameters of the SVM to given mapstructured data
virtual void saveStatistics(StDataASCII &statistics, int detailLevel=1)
virtual void saveStatistics(STDATA &statistics, int detailLevel=1)
save cross validation statistics.
virtual const PROBLEM * trainingData() const
get pointer to training data, that was set with setTrainingData().
virtual bool getStoreClassificationDetailsFlag() const
virtual void setClassificationDelta(double d)
virtual void loadParameters(STDATA &stData)
Read all parameters (e.g.
virtual const std::vector< StDataASCII > & classificationDetailsByUID() const
get classification details for each uid from last full CV or parital CV.
virtual int doFullCV(const std::vector< int > &subsetIndexByUID, std::vector< double > &predictedClassLabelByUID)
do a full cross validation.
virtual void preprocessTrainingData()
trains all two-class SVM&#39;s with the whole data set.
virtual void clearKernelCache()
call clearKernelCache() of selected svm.
virtual void setTrainingData(const PROBLEM *problem)
set the training data.
virtual void setStoreClassificationDetailsFlag(bool f)
The StDataASCII class is a container for "structured data", that is kept completly in memory...
Definition: StDataASCII.hh:83
virtual void setProgressReporter(ProgressReporter *pr)
set progress reporter object.