Changeset 539


Ignore:
Timestamp:
Mar 5, 2006, 2:33:47 PM (16 years ago)
Author:
Peter
Message:

re-introduced prediction in SVM

Location:
trunk/lib/classifier
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/classifier/Kernel.h

    r536 r539  
    6767
    6868   
    69     //virtual double element(const gslapi::vector& vec, const size_t i) const=0;
     69    virtual double element(const DataLookup1D& vec, const size_t i) const=0;
    7070
    7171  protected:
  • trunk/lib/classifier/KernelLookup.h

    r537 r539  
    102102    { return (*kernel_)(row_index_[row],column_index_[column]); }
    103103
    104     //inline double element(const gslapi::vector& vec, const size_t i) const
    105     //{ return kernel_->element(vec, row_index_[i]); }
     104    inline double element(const DataLookup1D& vec, const size_t i) const
     105    { return kernel_->element(vec, row_index_[i]); }
    106106
    107107  private:
  • trunk/lib/classifier/KernelWeighted_MEV.h

    r527 r539  
    5252    /// @return kernel element between data @a ve and training sample @a i
    5353    ///
    54     //inline double element(const gslapi::vector& vec, const size_t i) const
    55     //{
    56     //  return (*kf_)(vec, gslapi::vector(data_,i),
    57     //                       gslapi::vector(vec.size(),1.0),
    58     //                       gslapi::vector(weights_,i));
    59     //}
     54    inline double element(const DataLookup1D& vec, const size_t i) const
     55    {
     56      return (*kf_)(vec, DataLookup1D(data_,i),
     57                    DataLookup1D(vec.size(),1.0),
     58                    DataLookup1D(weights_,i));
     59    }
    6060
    6161  private:
  • trunk/lib/classifier/KernelWeighted_SEV.h

    r527 r539  
    5454    /// @return kernel element between data @a ve and training sample @a i
    5555    ///
    56     //inline double element(const DataLookup1D& vec, const size_t i) const
    57     //{
    58     //  return (*kf_)(vec, DataLookup1D(data_,i),
    59     //                DataLookup1D(vec.size(),1.0),
    60     //                DataLookup1D(weights_,i));
    61     //}
     56    inline double element(const DataLookup1D& vec, const size_t i) const
     57    {
     58      return (*kf_)(vec, DataLookup1D(data_,i),
     59                    DataLookup1D(vec.size(),1.0),
     60                    DataLookup1D(weights_,i));
     61    }
    6262
    6363
  • trunk/lib/classifier/Kernel_MEV.h

    r527 r539  
    5151    /// @return kernel element between data @a ve and training sample @a i
    5252    ///
    53     //inline double element(const gslapi::vector& vec, const size_t i) const
    54     //{ return kf_->operator()(vec, gslapi::vector(data_,i)); }
     53    inline double element(const DataLookup1D& vec, const size_t i) const
     54    { return kf_->operator()(vec, DataLookup1D(data_,i)); }
    5555     
    5656
  • trunk/lib/classifier/Kernel_SEV.cc

    r527 r539  
    2323          (*kf_)(DataLookup1D(data_,i,false),DataLookup1D(data_,j,false));
    2424  }
     25
     26
    2527  double Kernel_SEV::element(const DataLookup1D& vec, const size_t i) const
    2628  {
  • trunk/lib/classifier/SVM.cc

    r537 r539  
    5959  }
    6060
    61   double SVM::predict(const gslapi::vector& x) const
    62   {
    63     // predict won't work until kernel::element is working
    64     assert(0);
     61  double SVM::predict(const DataLookup1D& x) const
     62  {
    6563    double y=0;
    66     //for (size_t i=0; i<alpha_.size(); i++)
    67       //y += alpha_(i)*target_(i)*kernel_->element(x,i);
     64    for (size_t i=0; i<alpha_.size(); i++)
     65      y += alpha_(i)*target_(i)*kernel_->element(x,i);
    6866
    6967    return y+bias_;
  • trunk/lib/classifier/SVM.h

    r527 r539  
    170170    /// @return output from data @a input
    171171    ///
    172     double predict(const gslapi::vector& input) const;
     172    double predict(const DataLookup1D& input) const;
    173173
    174174    ///
Note: See TracChangeset for help on using the changeset viewer.