Scorer.H
Go to the documentation of this file.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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef TIGS_SCORER_H_DEFINED
00039 #define TIGS_SCORER_H_DEFINED
00040
00041 #include "Image/Image.H"
00042 #include "Util/log.H"
00043 #include "rutz/rand.h"
00044
00045 #include <iosfwd>
00046 #include <string>
00047
00048
00049 class Scorer
00050 {
00051 public:
00052 virtual ~Scorer();
00053
00054 virtual void accum(const Image<float>& eyeposmap, int pos) = 0;
00055
00056 virtual std::string getScoreString(const std::string& name) = 0;
00057 };
00058
00059 struct KLScorer : public Scorer
00060 {
00061 KLScorer(int nbins, int nrand);
00062
00063 virtual ~KLScorer();
00064
00065 virtual void accum(const Image<float>& eyeposmap, int pos);
00066
00067 virtual std::string getScoreString(const std::string& name);
00068
00069 private:
00070 static rutz::urand theirGenerator;
00071
00072 int itsNbins;
00073 int itsNrand;
00074 Image<int> itsObservedBins;
00075 Image<int> itsRandomBins;
00076 int itsNtrials;
00077 };
00078
00079 class NssScorer : public Scorer
00080 {
00081 public:
00082 NssScorer();
00083
00084 virtual void accum(const Image<float>& eyeposmap, int pos);
00085
00086 virtual std::string getScoreString(const std::string& name);
00087
00088 double getCurrentZscore() const
00089 {
00090 if (observedCount <= 0)
00091 LFATAL("no zscore observations");
00092
00093 return currentZscore;
00094 }
00095
00096 double getOverallZscore() const
00097 {
00098 if (observedCount <= 0)
00099 LFATAL("no zscore observations");
00100
00101 return observedZscore / observedCount;
00102 }
00103
00104 private:
00105 double currentZscore;
00106 double observedZscore;
00107 double maxZscore;
00108 int observedCount;
00109 };
00110
00111 class PercentileScorer : public Scorer
00112 {
00113 public:
00114 PercentileScorer();
00115
00116 virtual void accum(const Image<float>& eyeposmap, int pos);
00117
00118 virtual std::string getScoreString(const std::string& name);
00119
00120 double getCurrentPrctile() const
00121 {
00122 if (observedCount <= 0)
00123 LFATAL("no prctile observations");
00124
00125 return currentPrctile;
00126 }
00127
00128 double getOverallPrctile() const
00129 {
00130 if (observedCount <= 0)
00131 LFATAL("no prctile observations");
00132
00133 return observedPrctile / observedCount;
00134 }
00135
00136 private:
00137 double currentPrctile;
00138 double observedPrctile;
00139 int observedCount;
00140 };
00141
00142
00143 class SwpeScorer : public Scorer
00144 {
00145 public:
00146 SwpeScorer();
00147
00148 virtual void accum(const Image<float>& eyeposmap, int pos);
00149
00150 virtual std::string getScoreString(const std::string& name);
00151
00152 private:
00153 Dims itsDims;
00154 double itsEyeScore;
00155 double itsRandEyeScore;
00156 double itsRandMapScore;
00157 double itsFlatMapScore;
00158 int itsObservedCount;
00159
00160 rutz::urand itsGenerator;
00161 };
00162
00163 struct MulticastScorer
00164 {
00165 MulticastScorer();
00166
00167 void score(const std::string& name,
00168 const Image<float>& eyeposmap, int pos);
00169
00170 void showScore(const std::string& name);
00171
00172 void writeScore(const std::string& name, std::ostream& os);
00173
00174 int observedCount;
00175 PercentileScorer itsPrctileScorer;
00176 NssScorer itsNssScorer;
00177 KLScorer itsKLScorer;
00178 SwpeScorer itsSwpeScorer;
00179 };
00180
00181
00182
00183
00184
00185
00186
00187
00188 #endif // TIGS_SCORER_H_DEFINED