00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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