BlendStopping.h

00001 #ifndef __BLEND_STOPPING_
00002 #define __BLEND_STOPPING_
00003 
00004 #include "AutomaticParameterTuner.h"
00005 #include "NumericalTools.h"
00006 #include "Algorithm.h"
00007 #include "Framework.h"
00008 #include "ipps.h"
00009 #include "AUC.h"
00010 
00011 #include <stdio.h>
00012 #include <stdlib.h>
00013 #include <math.h>
00014 //#include <iostream>
00015 #include <fstream>
00016 #include <vector>
00017 #include <algorithm>
00018 #include <string>
00019 
00020 using namespace std;
00021 
00041 class BlendStopping : public Framework, public AutomaticParameterTuner, public AUC
00042 {
00043 public:
00044     BlendStopping();
00045     BlendStopping ( Algorithm *data );
00046     BlendStopping ( Algorithm *data, string algorithmFullPrediction );
00047     ~BlendStopping();
00048 
00049     // virtual overrider in AutomaticParameterTuner (for tuning lambda)
00050     double calcRMSEonProbe();
00051     double calcRMSEonBlend();
00052     void saveBestPrediction();
00053 
00054     // fill this with the new predictions per output class
00055     REAL** m_newPrediction;
00056 
00057     // calc rmse over all classes with pseudo-inverse
00058     double calcBlending ( char* fname = 0 );
00059     double getClassificationError();
00060     void setRegularization ( REAL reg );
00061     void clear();
00062 
00063     // for final prediction
00064     void saveTmpBestWeights();
00065     void saveBlendingWeights ( string path, bool saveBest = false );
00066     void loadBlendingWeights ( string path, int nPredictors );
00067     void predictEnsembleOutput ( REAL** predictions, REAL* output );
00068     void printWeights ( bool printBest = false );
00069 
00070 protected:
00071     int m_nPredictors;
00072     int m_nClass;
00073     int m_nDomain;
00074     int m_nTrain;
00075     double m_blendingRegularization;
00076     REAL m_classificationError;
00077     REAL* m_singlePrediction;
00078     REAL* m_prediction;
00079 
00080     // pseudo inverse per class
00081     REAL** m_A;
00082     REAL** m_b;
00083     REAL** m_x;
00084     REAL** m_xBest;
00085 
00086     vector<string> m_usedFiles;
00087     Algorithm* m_data;
00088     NumericalTools m_numTools;
00089     string m_algorithmFullPrediction;
00090     bool m_globalWeights;
00091 
00092     // area under curve tuning parameters
00093     double* m_paramsAUC;
00094     bool m_optimizeRMSE;
00095 };
00096 
00097 #endif

Generated on Tue Jan 26 09:20:58 2010 for ELF by  doxygen 1.5.8