Changeset 1120 for trunk/yat/classifier


Ignore:
Timestamp:
Feb 22, 2008, 12:18:41 AM (13 years ago)
Author:
Peter
Message:

vector is now Vector

Location:
trunk/yat/classifier
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/classifier/DataLookup1D.cc

    r1080 r1120  
    2929
    3030#include "yat/utility/matrix.h"
    31 #include "yat/utility/vector.h"
     31#include "yat/utility/Vector.h"
    3232
    3333#include <cassert>
  • trunk/yat/classifier/IGP.h

    r1050 r1120  
    2828#include "MatrixLookup.h"
    2929#include "Target.h"
    30 #include "yat/utility/vector.h"
     30#include "yat/utility/Vector.h"
    3131#include "yat/utility/yat_assert.h"
    3232
     
    6565    /// @return the IGP score for each class as elements in a vector.
    6666    ///
    67     const utility::vector& score(void) const;
     67    const utility::Vector& score(void) const;
    6868
    6969
    7070  private:
    71     utility::vector igp_;
     71    utility::Vector igp_;
    7272    Distance distance_;
    7373
     
    8686   
    8787    // Calculate IGP for each class
    88     igp_ = utility::vector(target_.nof_classes());
     88    igp_ = utility::Vector(target_.nof_classes());
    8989   
    9090    for(u_int i=0; i<target_.size(); i++) {
     
    116116 
    117117  template <typename Distance>
    118   const utility::vector& IGP<Distance>::score(void) const
     118  const utility::Vector& IGP<Distance>::score(void) const
    119119  {
    120120    return igp_;
  • trunk/yat/classifier/NBC.cc

    r1042 r1120  
    101101          assert(i<centroids_.rows());
    102102          assert(j<centroids_.columns());
    103           centroids_(i,j) = aver[j].mean();
    104103          assert(i<sigma2_.rows());
    105104          assert(j<sigma2_.columns());
    106           if (aver[j].n()>1)
     105          if (aver[j].n()>1){
    107106            sigma2_(i,j) = aver[j].variance();
    108           else
     107            centroids_(i,j) = aver[j].mean();
     108          }
     109          else {
    109110            sigma2_(i,j) = std::numeric_limits<double>::quiet_NaN();
     111            centroids_(i,j) = std::numeric_limits<double>::quiet_NaN();
     112          }
    110113        }
    111114      }
     
    125128          assert(i<sigma2_.rows());
    126129          assert(j<sigma2_.columns());
    127           if (aver[j].n()>1)
     130          if (aver[j].n()>1){
    128131            sigma2_(i,j) = aver[j].variance();
    129           else
     132            centroids_(i,j) = aver[j].mean();
     133          }
     134          else {
    130135            sigma2_(i,j) = std::numeric_limits<double>::quiet_NaN();
     136            centroids_(i,j) = std::numeric_limits<double>::quiet_NaN();
     137          }
    131138        }
    132139      }
     
    142149    assert(x.rows()==sigma2_.rows());
    143150    assert(x.rows()==centroids_.rows());
    144 
    145151   
    146152   
     
    192198    // problems when calculating P = exp(- -lnP), we centralize matrix
    193199    // by adding a constant.
    194     double m=0;
    195     for (size_t i=0; i<prediction.rows(); ++i)
    196       for (size_t j=0; j<prediction.columns(); ++j)
    197         m+=prediction(i,j);
    198     prediction -= m/prediction.rows()/prediction.columns();
     200    statistics::Averager a;
     201    add(a, prediction.begin(), prediction.end());
     202    prediction -= a.mean();
    199203
    200204    // exponentiate
  • trunk/yat/classifier/NCC.h

    r1115 r1120  
    3838#include "yat/statistics/AveragerWeighted.h"
    3939#include "yat/utility/matrix.h"
    40 #include "yat/utility/vector.h"
     40#include "yat/utility/Vector.h"
    4141#include "yat/utility/stl_utility.h"
    4242#include "yat/utility/yat_assert.h"
  • trunk/yat/classifier/SVM.cc

    r1108 r1120  
    3030#include "yat/statistics/Averager.h"
    3131#include "yat/utility/matrix.h"
    32 #include "yat/utility/vector.h"
     32#include "yat/utility/Vector.h"
    3333
    3434#include <algorithm>
     
    7676
    7777
    78   const utility::vector& SVM::alpha(void) const
     78  const utility::Vector& SVM::alpha(void) const
    7979  {
    8080    return alpha_;
     
    134134
    135135
    136   const theplu::yat::utility::vector& SVM::output(void) const
     136  const utility::Vector& SVM::output(void) const
    137137  {
    138138    return output_;
     
    186186    target_ = targ;
    187187   
    188     alpha_ = utility::vector(targ.size(), 0.0);
    189     output_ = utility::vector(targ.size(), 0.0);
     188    alpha_ = utility::Vector(targ.size(), 0.0);
     189    output_ = utility::Vector(targ.size(), 0.0);
    190190    // initializing variables for optimization
    191191    assert(target_.size()==kernel_->rows());
     
    193193
    194194    sample_.init(alpha_,tolerance_);
    195     utility::vector   E(target_.size(),0);
     195    utility::Vector   E(target_.size(),0);
    196196    for (size_t i=0; i<E.size(); i++) {
    197197      for (size_t j=0; j<E.size(); j++)
     
    273273
    274274
    275   bool SVM::choose(const theplu::yat::utility::vector& E)
     275  bool SVM::choose(const theplu::yat::utility::Vector& E)
    276276  {
    277277    // First check for violation among SVs
  • trunk/yat/classifier/SVM.h

    r1108 r1120  
    2929#include "SVindex.h"
    3030#include "Target.h"
    31 #include "yat/utility/vector.h"
     31#include "yat/utility/Vector.h"
    3232
    3333#include <utility>
     
    8181    /// @return \f$ \alpha \f$
    8282    ///
    83     const utility::vector& alpha(void) const;
     83    const utility::Vector& alpha(void) const;
    8484
    8585    ///
     
    117117        @return output
    118118    */
    119     const theplu::yat::utility::vector& output(void) const;
     119    const theplu::yat::utility::Vector& output(void) const;
    120120
    121121    /**
     
    215215    ///  can be found
    216216    ///
    217     bool choose(const theplu::yat::utility::vector&);
     217    bool choose(const theplu::yat::utility::Vector&);
    218218
    219219    ///
     
    227227    int target(size_t i) const;
    228228
    229     utility::vector alpha_;
     229    utility::Vector alpha_;
    230230    double bias_;
    231231    double C_inverse_;
     
    233233    double margin_;
    234234    unsigned long int max_epochs_;
    235     utility::vector output_;
     235    utility::Vector output_;
    236236    SVindex sample_;
    237237    Target target_;
  • trunk/yat/classifier/SVindex.cc

    r1100 r1120  
    2727#include "yat/statistics/Averager.h"
    2828#include "yat/utility/matrix.h"
    29 #include "yat/utility/vector.h"
     29#include "yat/utility/Vector.h"
    3030
    3131#include <algorithm>
     
    6565  }
    6666
    67   void SVindex::init(const utility::vector& alpha, const double tol)
     67  void SVindex::init(const utility::Vector& alpha, const double tol)
    6868  {
    6969    nof_sv_=0;
  • trunk/yat/classifier/SVindex.h

    r1000 r1120  
    3232
    3333namespace utility {
    34   class vector;
     34  class Vector;
    3535}
    3636
     
    5959
    6060    /// synch the object against alpha
    61     void init(const utility::vector& alpha, const double);
     61    void init(const utility::Vector& alpha, const double);
    6262
    6363    /// @return nof support vectors
  • trunk/yat/classifier/utility.cc

    r1009 r1120  
    2626#include "DataLookup1D.h"
    2727#include "DataLookupWeighted1D.h"
    28 #include "yat/utility/vector.h"
     28#include "yat/utility/Vector.h"
    2929
    3030
     
    3333namespace classifier {
    3434
    35   void convert(const DataLookup1D& lookup, utility::vector& vector)
     35  void convert(const DataLookup1D& lookup, utility::Vector& vector)
    3636  {
    37     vector = utility::vector(lookup.size());
     37    vector = utility::Vector(lookup.size());
    3838    for(u_int i=0; i<lookup.size(); i++)
    3939      vector(i)=lookup(i);
    4040  }
    4141
    42   void convert(const DataLookupWeighted1D& lookup, utility::vector& value,
    43                utility::vector& weight)
     42  void convert(const DataLookupWeighted1D& lookup, utility::Vector& value,
     43               utility::Vector& weight)
    4444  {
    4545   
    46     value = utility::vector(lookup.size());
    47     weight = utility::vector(lookup.size());
     46    value = utility::Vector(lookup.size());
     47    weight = utility::Vector(lookup.size());
    4848    for(u_int i=0; i<lookup.size(); i++){
    4949      value(i)=lookup.data(i);
  • trunk/yat/classifier/utility.h

    r1000 r1120  
    3030
    3131  namespace utility {
    32     class vector;
     32    class Vector;
    3333  }
    3434
     
    4141  /// Converts a DataLookup1D to a utility::vector
    4242  ///
    43   void convert(const DataLookup1D&, utility::vector&);
     43  void convert(const DataLookup1D&, utility::Vector&);
    4444
    4545  ///
    4646  /// Converts a DataLookupWeighted1D to two utility::vector
    4747  ///
    48   void convert(const DataLookupWeighted1D&, utility::vector& value,
    49                utility::vector& weight);
     48  void convert(const DataLookupWeighted1D&, utility::Vector& value,
     49               utility::Vector& weight);
    5050
    5151}}} // of namespace classifier, yat, and theplu
Note: See TracChangeset for help on using the changeset viewer.