experiment.h

Go to the documentation of this file.
00001 // Copyright 2007, Massachusetts Institute of Technology.
00002 // The use of this code is permitted for research only. There is
00003 // absolutely no warranty for this software.
00004 //
00005 // Author: John Lee (jjl@mit.edu)
00006 //
00007 
00008 #ifndef EXPERIMENT_EXPERIMENT_H
00009 #define EXPERIMENT_EXPERIMENT_H
00010 
00011 #include <vector>
00012 #include "kernel/matrix.h"
00013 #include "kernel/kernel-matrix.h"
00014 #include "util/labeled-index.h"
00015 
00016 using namespace std;
00017 
00018 using namespace libpmk;
00019 namespace libpmk_util {
00020 
00022 
00028 class Experiment {
00029  public:
00035    Experiment(vector<LabeledIndex> training,
00036               vector<LabeledIndex> testing,
00037               const KernelMatrix& kernel);
00038 
00047    Experiment(vector<LabeledIndex> training,
00048               const KernelMatrix& training_matrix,
00049               vector<LabeledIndex> testing, const Matrix& testing_matrix);
00050 
00051    virtual ~Experiment() { }
00052 
00054    virtual void Train() = 0;
00055 
00057 
00062    virtual int Test() = 0;
00063 
00064 
00066 
00069    int GetPrediction(int test_index) const;
00070 
00073    int GetNumCorrect() const;
00074 
00077    int GetNumCorrect(int label) const;
00078 
00080    int GetNumTestExamples() const;
00081 
00083    int GetNumTestExamples(int label) const;
00084 
00086    double GetAccuracy() const;
00087 
00089    double GetAccuracy(int label) const;
00090 
00091  protected:
00092    vector<LabeledIndex> training_;
00093    vector<LabeledIndex> testing_;
00094 
00096    double GetKernelValue(int row, int col) const;
00097 
00099    double GetKernelValue(const LabeledIndex& row,
00100                          const LabeledIndex& col) const;
00101 
00106    void SetPrediction(int test_index, int prediction);
00107 
00108  private:
00109    KernelMatrix kernel_;
00110    vector<int> predictions_;
00111 };
00112 }  // namespace libpmk_util
00113 #endif  // EXPERIMENT_EXPERIMENT_H

Generated on Wed May 2 11:17:12 2007 for libpmk by  doxygen 1.5.1