Changeset 414


Ignore:
Timestamp:
Dec 1, 2005, 4:17:49 PM (16 years ago)
Author:
Peter
Message:

adding FoldChange? class and fixing bugs in Score classes

Location:
trunk
Files:
2 added
9 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/doc/svnplot.pl

    r316 r414  
    1111  my @line2 = split(/\D/,$line[0]);
    1212  $dates[$line2[1]]=$line[4];
     13  print "$line2[1] -> $line[4]\n";
    1314    }
    1415}
  • trunk/doc/svnplot.sh

    r340 r414  
    11#!/bin/sh
    22
    3 cd ../lib/
     3cd ..
    44touch svnstat.tmp1
    55rm svnstat.tmp1
    66
    7 echo "Extracting date information."
     7echo "Extracting log information."
     8svn log -q | sort -u > lib/date.tmp
     9cd lib
     10echo "Extracting files information."
    811(file `svn list -R` | grep -v directory | awk 'BEGIN {FS=":"} {printf("%s",$1); printf("\n");}')>files.tmp
    9 svn log `grep . files.tmp` -q | sort -u > date.tmp
    1012echo "Extracting file information."
    11 svn blame `grep . files.tmp` >> svnstat.tmp1
     13svn blame `grep . files.tmp` > svnstat.tmp1
    1214sort svnstat.tmp1 -g > svnstat.tmp2
    1315echo "Plotting."
     
    1820mv svnplot.png ../doc/html/.
    1921
    20 rm svnstat.tmp1
    21 rm svnstat.tmp2
    22 rm svnstat.tmp3
    23 rm files.tmp
    24 rm date.tmp
    25 rm svnplot.ps
     22#rm svnstat.tmp1
     23#rm svnstat.tmp2
     24#rm svnstat.tmp3
     25#rm files.tmp
     26#rm date.tmp
     27#rm svnplot.ps
  • trunk/lib/statistics/AveragerWeighted.h

    r411 r414  
    9393    { return sum_ww() / (sum_w()*sum_w()-sum_ww()) * sum_xx_centered(); }
    9494
     95    ///
     96    /// @return \f$ \sum_i (x_i-m)^2\f$
     97    ///
     98    /// @note this function is likely to be changed, when this class
     99    /// will be revised.
     100    ///
     101    inline double sum_xsqr_centered(void) const { return sum_xx_centered(); }
     102
    95103
    96104  private:
  • trunk/lib/statistics/Makefile.am

    r386 r414  
    88noinst_LTLIBRARIES = libstatistics.la
    99libstatistics_la_SOURCES = \
    10   Averager.cc AveragerPair.cc AveragerWeighted.cc Fisher.cc Histogram.cc \
    11   Kernel.cc KernelBox.cc KernelTriCube.cc Linear.cc Local.cc \
     10  Averager.cc AveragerPair.cc AveragerWeighted.cc Fisher.cc FoldChange.cc \
     11  Histogram.cc Kernel.cc KernelBox.cc KernelTriCube.cc Linear.cc Local.cc \
    1212  MultiDimensional.cc Naive.cc \
    13   Pearson.cc Polynomial.cc ROC.cc Score.cc utility.cc
     13  Pearson.cc Polynomial.cc ROC.cc Score.cc tScore.cc utility.cc
    1414
    1515include_statisticsdir = $(includedir)/c++_tools/statistics
    1616
    1717include_statistics_HEADERS = \
    18   Averager.h AveragerPair.h AveragerWeighted.h Fisher.h Histogram.h \
    19   Kernel.h KernelBox.h KernelTriCube.h Linear.h Local.h \
     18  Averager.h AveragerPair.h AveragerWeighted.h Fisher.h FoldChange.h \
     19  Histogram.h Kernel.h KernelBox.h KernelTriCube.h Linear.h Local.h \
    2020  MultiDimensional.h Naive.h \
    2121  OneDimensional.h Pearson.h Polynomial.h ROC.h Score.h tScore.h utility.h
  • trunk/lib/statistics/Pearson.h

    r295 r414  
    66#include <c++_tools/statistics/Score.h>
    77
    8 //Peter, should add a function to get the sign of the correlation
    98namespace theplu {
    109  class gslapi::vector;
  • trunk/lib/statistics/ROC.h

    r334 r414  
    1212namespace theplu {
    1313namespace statistics { 
     14
    1415  ///
    1516  /// Class for ROC (Reciever Operating Characteristic).
    1617  ///   
    17  
    1818  class ROC : public Score
    1919  {
  • trunk/lib/statistics/tScore.cc

    r303 r414  
    55
    66// Thep C++ Tools
    7 #include "tScore.h"
    8 #include "Averager.h"
    9 #include "vector.h"
    10 #include "WeightedAverager.h"
     7#include <c++_tools/statistics/tScore.h>
     8#include <c++_tools/statistics/Averager.h>
     9#include <c++_tools/gslapi/vector.h>
     10#include <c++_tools/statistics/AveragerWeighted.h>
    1111
    1212namespace theplu {
     
    4141    double diff = positive.mean() - negative.mean();
    4242    double s=sqrt((positive.sum_xsqr()+negative.sum_xsqr())
    43                   /(positive.n()-1+negative.n()-1));
    44     t_=diff/s;
     43                  /(positive.n()+negative.n()-2));
     44    t_=diff/s/(1.0/positive.n()+1.0/negative.n());
    4545    if (t_<0 && absolute_)
    4646      t_=-t_;
     
    6262    target_ = target;
    6363    weight_ = weight;
    64     statistics::WeightedAverager positive;
    65     statistics::WeightedAverager negative;
     64    statistics::AveragerWeighted positive;
     65    statistics::AveragerWeighted negative;
    6666    for(size_t i=0; i<train_set_.size(); i++){
    6767      if (target_[train_set_[i]]==1)
     
    7171    }
    7272    double diff = positive.mean() - negative.mean();
    73     double s=sqrt((positive.squared_sum()+negative.squared_sum())/
    74                   (positive.sum_w()+negative.sum_w()));
    75     t_=diff/s;
     73    double s=sqrt((positive.sum_xsqr_centered()+negative.sum_xsqr_centered())/
     74                  (positive.sum_w()+negative.sum_w()-2));
     75    t_=diff/s/(1.0/positive.sum_w()+1.0/negative.sum_w());
    7676    if (t_<0 && absolute_)
    7777      t_=-t_;
  • trunk/lib/statistics/tScore.h

    r295 r414  
    1414namespace theplu {
    1515namespace statistics { 
     16
    1617  ///
    1718  /// Class for Fisher's t-test.
    1819  ///   
    19  
    2020  class tScore : public Score
    2121  {
     
    2828
    2929    ///
    30     /// Destructor
    31     ///
    32     virtual ~tScore(void) {};
    33          
    34    
    35     ///
    3630    /// Calculates the value of t-score, i.e. the ratio between
    3731    /// difference in mean and standard deviation of this
    3832    /// difference. \f$ \frac{ \vert \frac{1}{n_x}\sum x_i -
    3933    /// \frac{1}{n_y}\sum y_i \vert } {\frac{\sum x_i^2 + \sum
    40     /// y_i^2}{n_x-1+n_y-1}} \f$ @return t-score if absolute=true
     34    /// y_i^2}{n_x-1+n_y-1}} \f$
     35    ///
     36    /// @return t-score if absolute=true
    4137    /// absolute value of t-score is returned
    4238    ///
  • trunk/test/Makefile.am

    r399 r414  
    55TESTS = alignment_test averager_test consensus_inputranker_test \
    66  crossvalidation_test inputranker_test kernel_test matrix_test \
    7   nni_test pca_test regression_test rnd_test roc_test \
     7  nni_test pca_test regression_test rnd_test score_test \
    88  statistics_test stl_utility_test svd_test svm_test vector_test
    99
     
    2727regression_test_SOURCES = regression_test.cc
    2828rnd_test_SOURCES = rnd_test.cc
    29 roc_test_SOURCES = roc_test.cc
     29score_test_SOURCES = score_test.cc
    3030statistics_test_SOURCES = statistics_test.cc
    3131stl_utility_test_SOURCES = stl_utility_test.cc
  • trunk/test/score_test.cc

    r397 r414  
    33#include <c++_tools/gslapi/matrix.h>
    44#include <c++_tools/statistics/ROC.h>
     5#include <c++_tools/statistics/tScore.h>
     6#include <c++_tools/statistics/Pearson.h>
     7#include <c++_tools/statistics/FoldChange.h>
    58#include <c++_tools/gslapi/vector.h>
    69
     
    1518int main(const int argc,const char* argv[])
    1619
    17   bool print = (argc>1 && argv[1]==std::string("-p"));
     20  std::ostream* error;
     21  if (argc>1 && argv[1]==std::string("-v"))
     22    error = &std::cerr;
     23  else {
     24    error = new std::ofstream("/dev/null");
     25    if (argc>1)
     26      std::cout << "score_test -v : for printing extra information\n";
     27  }
     28  *error << "testing score classes" << std::endl;
    1829  bool ok = true;
     30
     31  *error << "testing ROC" << std::endl;
    1932  gslapi::vector value(31);
    2033  gslapi::vector target(31,-1);
     
    2639  double area = roc.score(target, value);
    2740  if (area!=1.0){
    28     if (print)
    29       std::cerr << "test_roc a: area is " << area << " should be 1.0"
    30                 << std::endl;
     41    *error << "test_roc a: area is " << area << " should be 1.0"
     42           << std::endl;
    3143    ok = false;
    3244  }
     
    3446  area = roc.score(target, value);
    3547  if (area!=1.0){
    36     if (print)
    37       std::cerr << "test_roc: area is " << area << " should be 1.0"
    38                 << std::endl;
     48    *error << "test_roc: area is " << area << " should be 1.0"
     49           << std::endl;
    3950    ok = false;
    4051  }
     
    4354  double p_matlab = 0.00000115;
    4455  if (p/p_matlab > 1.01 | p/p_matlab < 0.99){
    45     if (print)
    46       std::cerr << "get_p_approx: p-value not correct" << std::endl;
     56    *error << "get_p_approx: p-value not correct" << std::endl;
    4757    ok = false;
    4858  }
     
    5060  p = roc.p_value();
    5161  if (p > pow(10, -8.0) | p < pow(10, -9.0)){
    52     if (print)
    53       std::cerr << "get_p_exact: p-value not correct" << std::endl;
     62    *error << "get_p_exact: p-value not correct" << std::endl;
    5463    ok = false;
    5564  }
     
    7382    area = roc.score(target2,vec);
    7483    if (area<correct_area(i)-tol || area>correct_area(i)+tol){
    75       if (print){
    76         std::cerr << "test_roc: area is " << area << " should be "
     84      *error << "test_roc: area is " << area << " should be "
    7785             << correct_area(i) << std::endl;
    78       }
    7986      ok=false;
    8087    }
     
    8693    area = roc.score(target2, vec, weight);
    8794    if (area<correct_area(i)-tol || area>correct_area(i)+tol){
    88       if (print){
    89         std::cerr << "test_roc: weighted area is " << area << " should be "
     95      *error << "test_roc: weighted area is " << area << " should be "
    9096             << correct_area(i) << std::endl;
    91       }
    9297      ok=false;
    9398    }
    9499  }
     100
     101  *error << "testing FoldChange" << std::endl;
     102  statistics::FoldChange fold_change(true);
     103
     104  *error << "testing tScore" << std::endl;
     105  statistics::tScore t_score(true);
     106
     107  *error << "testing Pearson" << std::endl;
     108  statistics::Pearson pearson(true);
    95109
    96110
Note: See TracChangeset for help on using the changeset viewer.