BALL  1.4.1
kernel.h
Go to the documentation of this file.
00001 /* kernel.h
00002  * 
00003  * Copyright (C) 2009 Marcel Schumann
00004  * 
00005  * This file is part of QuEasy -- A Toolbox for Automated QSAR Model
00006  * Construction and Validation.
00007  * QuEasy is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3 of the License, or (at
00010  * your option) any later version.
00011  * 
00012  * QuEasy is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00021   // -*- Mode: C++; tab-width: 2; -*-
00022 // vi: set ts=2:
00023 //
00024 //
00025 
00026 #ifndef KERNEL
00027 #define KERNEL
00028 
00029 #ifndef LMODEL
00030 #include <BALL/QSAR/linearModel.h>
00031 #endif
00032 
00033 #ifndef MODEL
00034 #include <BALL/QSAR/Model.h>
00035 #endif
00036 
00037 #ifndef QSAR_EXCEPTION
00038 #include <BALL/QSAR/exception.h>
00039 #endif
00040 
00041 #ifndef REGRESSION
00042 #include <BALL/QSAR/regressionModel.h>
00043 #endif
00044 
00045 #include <cmath>
00046 #include <sstream>
00047 
00048 
00049 namespace BALL
00050 {
00051   namespace QSAR
00052   {
00053     class BALL_EXPORT Kernel
00054     { 
00055       
00056     
00057       public:
00061         Kernel(Model* m, int k_type, double p1, double p2=-1);
00062         
00063         Kernel(Model* m, String f, String g);
00064             
00065         Kernel(Model* m, Vector<double>& w);
00066         
00069         Kernel(Model* m, const LinearModel& lm, int column);
00070 
00071         ~Kernel();
00073         
00074         
00082         void calculateKernelMatrix(Matrix<double>& input, Matrix<double>& output);
00083         
00088         void calculateKernelMatrix(Matrix<double>& K, Matrix<double>& m1, Matrix<double>& m2, Matrix<double>& output);
00089         
00090         
00092         void calculateKernelVector(Matrix<double>& K,Vector<double>& m1, Matrix<double>& m2, Vector<double>& output);
00093         
00100         void gridSearch(double step_width, int steps, int recursions, int k, bool opt=0);
00102         
00103         
00113         int type;
00114         
00116         double par1, par2;
00117         
00121         String equation1;
00122         
00126         String equation2;
00128         
00129         
00130       protected:
00134 
00135         void gridSearch(double step_width, int steps, bool first_rec, int k, double par1_start, double par2_start, bool opt);
00136 
00139         void calculateWeightedKernelMatrix(Matrix<double>& input, Matrix<double>& output);
00140         
00141         
00144         void calculateWeightedKernelMatrix(Matrix<double>& m1, Matrix<double>& m2, Matrix<double>& output);
00145         
00146         
00147         void calculateKernelMatrix1(Matrix<double>& input, Matrix<double>& output);
00148         
00149         void calculateKernelMatrix2(Matrix<double>& input, Matrix<double>& output);
00150         
00151         void calculateKernelMatrix3(Matrix<double>& input, Matrix<double>& output);
00152         
00153         void calculateKernelMatrix4(Matrix<double>& input, Matrix<double>& output);
00154         
00155         
00156         void calculateKernelMatrix1(Matrix<double>& m1, Matrix<double>& m2, Matrix<double>& output);
00157         
00158         void calculateKernelMatrix2(Matrix<double>& m1, Matrix<double>& m2, Matrix<double>& output);
00159         
00160         void calculateKernelMatrix3(Matrix<double>& m1, Matrix<double>& m2, Matrix<double>& output);
00161         
00162         void calculateKernelMatrix4(Matrix<double>& m1, Matrix<double>& m2, Matrix<double>& output);
00164         
00165         
00170         Model* model_;
00171         
00172         Vector<double> weights_;
00174         
00175         
00176         friend class FeatureSelection;
00177       
00178     };
00179   }
00180 }
00181 
00182 #endif // KERNEL
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines