BALL  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
regressionValidation.h
Go to the documentation of this file.
1 /* regressionValidation.h
2  *
3  * Copyright (C) 2009 Marcel Schumann
4  *
5  * This file is part of QuEasy -- A Toolbox for Automated QSAR Model
6  * Construction and Validation.
7  * QuEasy is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or (at
10  * your option) any later version.
11  *
12  * QuEasy is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 // -*- Mode: C++; tab-width: 2; -*-
22 // vi: set ts=2:
23 //
24 //
25 
26 #ifndef REGVALIDATION
27 #define REGVALIDATION
28 
29 #ifndef QSARDATA
30 #include <BALL/QSAR/QSARData.h>
31 #endif
32 
33 #ifndef VALIDATION
34 #include <BALL/QSAR/validation.h>
35 #endif
36 
37 #include <gsl/gsl_randist.h>
38 #include <gsl/gsl_cdf.h>
39 #include <iterator>
40 
41 
44 
45 
46 
47 namespace BALL
48 {
49  namespace QSAR
50  {
51  class RegressionModel;
54  {
55  public:
62 
65 
66 
73  void crossValidation(int k, bool restore=1);
74 
79  void crossValidation(int k, vector<BALL::Matrix<double> >* results, bool restore=1);
80 
81 
85  void bootstrap(int k, bool restore=1);
86 
91  void bootstrap(int k, vector<BALL::Matrix<double> >* results, bool restore=1);
92 
93  void bootstrap1(int k, vector<BALL::Matrix<double> >* results, bool restore=1);
94 
98  const BALL::Matrix<double>& yRandomizationTest(int runs, int k);
99 
102  double getQ2();
103 
106  double getR2();
107 
110  double getFregr();
111 
114  double getFcv();
115 
116  double getCVRes();
117 
118  double getFitRes();
119 
121  double getMaxError();
122 
123  void setCVRes(double d);
124 
126  void setQ2(double d);
127 
128  void testInputData(bool transform=0);
129 
133  void selectStat(int s);
134 
138  void calculateCoefficientStdErrors(int k, bool b=1);
139 
141  const BALL::Matrix<double>* getCoefficientStdErrors();
142 
143  void setCoefficientStdErrors(const BALL::Matrix<double>* stddev);
144 
145  void saveToFile(string filename) const;
146 
147  void saveToFile(string filename, const double& r2, const double& q2, const Matrix<double>& coefficient_stddev, const Matrix<double>& yRand_results) const;
148 
149  void readFromFile(string filename);
151 
152 
153  private:
154 
155  struct BackupData
156  {
164  };
165 
166 
171  void testAllSubstances(bool transform);
172 
173  void backupTrainingResults();
174 
175  void restoreTrainingResults();
177 
178 
182 
183  double ssR_;
184 
185  double ssE_;
186 
188  double ssY_;
189 
191  double std_err_;
192 
194  double Q2_;
195 
197  double F_cv_;
198 
200  double F_regr_;
201 
202  double R2_;
203 
204  double max_error_;
205 
207  double quality_;
208 
209  double (RegressionValidation::* predQualFetcher_)();
210 
211  double (RegressionValidation::* fitQualFetcher_)();
212 
213  void calculateQOF();
214 
217 
220 
222 
223  void (RegressionValidation::* qualCalculation)();
225 
226  };
227  }
228 }
229 
230 
231 
232 #endif // REGVALIDATION