BALL  1.4.79
 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 BALL_QSAR_REGRESSIONVALIDATION_H
27 #define BALL_QSAR_REGRESSIONVALIDATION_H
28 
29 #include <BALL/QSAR/common.h>
30 
31 #include <BALL/QSAR/QSARData.h>
32 
33 #include <BALL/QSAR/validation.h>
34 
35 #include <iterator>
36 
37 namespace BALL
38 {
39  namespace QSAR
40  {
41  class RegressionModel;
44  {
45  public:
52 
54 
55  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
57 
58 
65  void crossValidation(int k, bool restore=true);
66 
71  void crossValidation(int k, MatrixVector* results, bool restore=true);
72 
73 
77  void bootstrap(int k, bool restore=1);
78 
83  void bootstrap(int k, MatrixVector* results, bool restore=true);
84 
85  void bootstrap1(int k, MatrixVector* results, bool restore=true);
86 
90  const Eigen::MatrixXd& yRandomizationTest(int runs, int k);
91 
94  double getQ2();
95 
98  double getR2();
99 
102  double getFregr();
103 
106  double getFcv();
107 
108  double getCVRes();
109 
110  double getFitRes();
111 
113  double getMaxError();
114 
115  void setCVRes(double d);
116 
118  void setQ2(double d);
119 
120  void testInputData(bool transform=0);
121 
125  void selectStat(int s);
126 
130  void calculateCoefficientStdErrors(int k, bool b=1);
131 
133  const Eigen::MatrixXd* getCoefficientStdErrors();
134 
135  void setCoefficientStdErrors(const Eigen::MatrixXd* stddev);
136 
137  void saveToFile(string filename) const;
138 
139  void saveToFile(string filename, const double& r2, const double& q2, const Eigen::MatrixXd& coefficient_stddev, const Eigen::MatrixXd& yRand_results) const;
140 
141  void readFromFile(string filename);
143 
144 
145  private:
146 
147  struct BackupData
148  {
149  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
150 
151  Eigen::MatrixXd descriptor_matrix;
152  Eigen::MatrixXd training_result;
153  Eigen::MatrixXd Y;
154  Eigen::MatrixXd K;
155  Eigen::MatrixXd latent_variables;
156  Eigen::MatrixXd loadings;
157  Eigen::MatrixXd weights;
158  };
159 
160 
165  void testAllSubstances(bool transform);
166 
167  void backupTrainingResults();
168 
169  void restoreTrainingResults();
171 
172 
176 
177  double ssR_;
178 
179  double ssE_;
180 
182  double ssY_;
183 
185  double std_err_;
186 
188  double Q2_;
189 
191  double F_cv_;
192 
194  double F_regr_;
195 
196  double R2_;
197 
198  double max_error_;
199 
201  double quality_;
202 
203  double (RegressionValidation::* predQualFetcher_)();
204 
205  double (RegressionValidation::* fitQualFetcher_)();
206 
207  void calculateQOF();
208 
210  Eigen::MatrixXd coefficient_stderr_;
211 
213  RegressionModel* regr_model_;
214 
215  BackupData backup_data_;
216 
217  void (RegressionValidation::* qualCalculation)();
219 
220  };
221  }
222 }
223 
224 
225 
226 #endif // BALL_QSAR_REGRESSIONVALIDATION_H
std::vector< Eigen::MatrixXd, Eigen::aligned_allocator< Eigen::MatrixXd > > MatrixVector
Definition: QSAR/common.h:10
BALL_EXTERN_VARIABLE const double k
Definition: constants.h:93
#define BALL_EXPORT
Definition: COMMON/global.h:50