Changeset 856 for trunk/yat


Ignore:
Timestamp:
Sep 5, 2007, 2:50:49 PM (14 years ago)
Author:
Markus Ringnér
Message:

The SNR score is now ok again and renamed SNRScore. Fixes #235"

Location:
trunk/yat/statistics
Files:
1 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/yat/statistics/Makefile.am

    r833 r856  
    3131  Euclidean.cc Fisher.cc FoldChange.cc Histogram.cc Pearson.cc      \
    3232  PearsonCorrelation.cc PearsonDistance.cc ROC.cc \
    33   SAMScore.cc Score.cc SNR.cc tScore.cc tTest.cc \
     33  SAMScore.cc Score.cc SNRScore.cc tScore.cc  tTest.cc \
    3434  utility.cc VectorFunction.cc WilcoxonFoldChange.cc
    3535
     
    4141  FoldChange.h Histogram.h Pearson.h PearsonCorrelation.h \
    4242  PearsonDistance.h ROC.h \
    43   SAMScore.h Score.h SNR.h tScore.h tTest.h \
     43  SAMScore.h Score.h SNRScore.h tScore.h tTest.h \
    4444  utility.h VectorFunction.h WilcoxonFoldChange.h
  • trunk/yat/statistics/SNRScore.cc

    r855 r856  
    2323*/
    2424
    25 #include "SNR.h"
     25#include "SNRScore.h"
    2626#include "Averager.h"
    2727#include "AveragerWeighted.h"
     
    3636namespace statistics { 
    3737
    38   SNR::SNR(bool b)
    39     : Score(b), score_(0)
     38  SNRScore::SNRScore(bool b)
     39    : Score(b)
    4040  {
    4141  }
    4242
    43   double SNR::score(const classifier::Target& target,
    44                     const utility::vector& value)
     43  SNRScore::~SNRScore(void)
     44  {
     45  }
     46
     47  double SNRScore::score(const classifier::Target& target,
     48                         const utility::vector& value) const
    4549  {
    4650    statistics::Averager positive;
     
    5458    double diff = positive.mean() - negative.mean();
    5559    double denom=positive.std()+negative.std();
    56     score_=diff/denom;
     60    double snr=diff/denom;
    5761    if(positive.n()==0 || negative.n()==0)
    58       score_=0;
    59     if (score_<0 && absolute_)
    60       score_=-score_;   
    61     return score_;
     62      snr=0;
     63    if (snr<0 && absolute_)
     64      snr=-snr;   
     65    return snr;
    6266  }
    6367
    64   double SNR::score(const classifier::Target& target,
    65                     const classifier::DataLookupWeighted1D& value)
     68  double SNRScore::score(const classifier::Target& target,
     69                         const classifier::DataLookupWeighted1D& value) const
    6670  {
    6771    statistics::AveragerWeighted positive;
     
    7680    double denom=positive.std()+negative.std();
    7781    assert(denom);
    78     score_=diff/denom;
     82    double snr=diff/denom;
    7983    if(positive.sum_w()==0 || negative.sum_w()==0)
    80       score_=0;
    81     if (score_<0 && absolute_)
    82       score_=-score_;   
    83     return score_;
     84      snr=0;
     85    if (snr<0 && absolute_)
     86      snr=-snr;   
     87    return snr;
    8488  }
    8589
    8690
    8791
    88   double SNR::score(const classifier::Target& target,
     92  double SNRScore::score(const classifier::Target& target,
    8993                    const utility::vector& value,
    90                     const utility::vector& weight)
     94                    const utility::vector& weight) const
    9195  {
    9296    statistics::AveragerWeighted positive;
     
    101105    double denom=positive.std()+negative.std();
    102106    assert(denom);
    103     score_=diff/denom;
     107    double snr=diff/denom;
    104108    if(positive.sum_w()==0 || negative.sum_w()==0)
    105       score_=0;
    106     if (score_<0 && absolute_)
    107       score_=-score_;   
    108     return score_;
     109      snr=0;
     110    if (snr<0 && absolute_)
     111      snr=-snr;   
     112    return snr;
    109113  }
    110114
  • trunk/yat/statistics/SNRScore.h

    r855 r856  
    3131
    3232namespace theplu {
    33 namespace yat {
    34   namespace utility {
    35     class vector;
    36   }
    37   namespace classifier {
    38     class DataLookWeighted1D;
    39   }
    40 namespace statistics { 
     33  namespace yat {
     34    namespace utility {
     35      class vector;
     36    }
     37    namespace classifier {
     38      class DataLookWeighted1D;
     39    }
     40    namespace statistics { 
    4141
    42   /**
    43      @brief Class for score based on signal-to-noise ratio (SNR). 
    44      
    45      Also
    46      sometimes referred to as Golub score. The score is the ratio
    47      between difference in mean and the sum of standard deviations
    48      for two groups:  \f$ \frac{ m_x-m_y}{ s_x + s_y} \f$ where \f$
    49      s \f$ is standard deviation.
    50   */
    51   class SNR : public Score
    52   {
    53  
    54   public:
    55     ///
    56     /// @brief Default Constructor.
    57     ///
    58     SNR(bool absolute=true);
    59 
    60     /**
    61        SNR is defined as \f$ \frac{m_x-m_y}{s_x+s_y} \f$ where \f$ m
    62        \f$ and \f$ s \f$ are mean and standard deviation,
    63        respectively. @see Averager
    64 
    65        @return SNR score. If absolute=true absolute value of SNR is
    66        returned
    67     */
    68     double score(const classifier::Target& target,
    69                  const utility::vector& value);
    70 
    71     /**
    72        SNR is defined as \f$ \frac{m_x-m_y}{s_x+s_y} \f$ where \f$ m
    73        \f$ and \f$ s \f$ are weighted versions of mean and standard
    74        deviation, respectively. @see AveragerWeighted
    75 
    76        @return SNR score. If absolute=true absolute value of SNR is
    77        returned
    78     */
    79     double score(const classifier::Target& target,
    80                  const classifier::DataLookupWeighted1D& value);         
    81 
    82     /**
    83        SNR is defined as \f$ \frac{m_x-m_y}{s_x+s_y} \f$ where \f$ m
    84        \f$ and \f$ s \f$ are weighted versions of mean and standard
    85        deviation, respectively. @see AveragerWeighted
    86 
    87        @return SNR score. If absolute=true absolute value of SNR is
    88        returned
    89     */
    90     double score(const classifier::Target& target,
    91                  const utility::vector& value,
    92                  const utility::vector& weight);         
    93   private:
    94     double score_;
    95   };
    96 
    97 }}} // of namespace statistics, yat, and theplu
     42      /**
     43         @brief Class for score based on signal-to-noise ratio (SNRScore). 
     44         
     45         Also
     46         sometimes referred to as Golub score. The score is the ratio
     47         between difference in mean and the sum of standard deviations
     48         for two groups:  \f$ \frac{ m_x-m_y}{ s_x + s_y} \f$ where \f$
     49         s \f$ is standard deviation.
     50      */
     51      class SNRScore : public Score
     52      {
     53       
     54      public:
     55        ///
     56        /// @brief Default Constructor.
     57        ///
     58        SNRScore(bool absolute=true);
     59       
     60        ///
     61        /// @brief The destructor.
     62        ///
     63        virtual ~SNRScore(void);
     64       
     65        /**
     66           SNRScore is defined as \f$ \frac{m_x-m_y}{s_x+s_y} \f$ where \f$ m
     67           \f$ and \f$ s \f$ are mean and standard deviation,
     68           respectively. @see Averager
     69           
     70           @return SNRScore score. If absolute=true absolute value of SNRScore is
     71           returned
     72        */
     73        double score(const classifier::Target& target,
     74                     const utility::vector& value) const;
     75       
     76        /**
     77           SNRScore is defined as \f$ \frac{m_x-m_y}{s_x+s_y} \f$ where \f$ m
     78           \f$ and \f$ s \f$ are weighted versions of mean and standard
     79           deviation, respectively. @see AveragerWeighted
     80           
     81           @return SNRScore score. If absolute=true absolute value of SNRScore is
     82           returned
     83        */
     84        double score(const classifier::Target& target,
     85                     const classifier::DataLookupWeighted1D& value) const;         
     86       
     87        /**
     88           SNRScore is defined as \f$ \frac{m_x-m_y}{s_x+s_y} \f$ where \f$ m
     89           \f$ and \f$ s \f$ are weighted versions of mean and standard
     90           deviation, respectively. @see AveragerWeighted
     91           
     92           @return SNRScore score. If absolute=true absolute value of SNRScore is
     93           returned
     94        */
     95        double score(const classifier::Target& target,
     96                     const utility::vector& value,
     97                     const utility::vector& weight) const;         
     98       
     99      };
     100     
     101     
     102    }}} // of namespace statistics, yat, and theplu
    98103
    99104#endif
Note: See TracChangeset for help on using the changeset viewer.