Changeset 542


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

added predict function in SVM supporting weight

Location:
trunk/lib/classifier
Files:
10 edited

Legend:

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

    r539 r542  
    6868   
    6969    virtual double element(const DataLookup1D& vec, const size_t i) const=0;
     70    virtual double element(const DataLookup1D& vec, const DataLookup1D& w,
     71                           const size_t i) const=0;
    7072
    7173  protected:
  • trunk/lib/classifier/KernelLookup.h

    r539 r542  
    105105    { return kernel_->element(vec, row_index_[i]); }
    106106
     107    inline double element(const DataLookup1D& vec, const DataLookup1D& w,
     108                          const size_t i) const
     109    { return kernel_->element(vec, w, row_index_[i]); }
     110
    107111  private:
    108112    ///
  • trunk/lib/classifier/KernelWeighted_MEV.h

    r539 r542  
    5959    }
    6060
     61    inline double element(const DataLookup1D& vec, const DataLookup1D& w,
     62                          const size_t i) const
     63    {
     64      return (*kf_)(vec, DataLookup1D(data_,i),w,DataLookup1D(weights_,i));
     65    }
     66
    6167  private:
    6268    ///
  • trunk/lib/classifier/KernelWeighted_SEV.h

    r539 r542  
    6161    }
    6262
     63    inline double element(const DataLookup1D& vec, const DataLookup1D& w,
     64                          const size_t i) const
     65    {
     66      return (*kf_)(vec, DataLookup1D(data_,i),w,DataLookup1D(weights_,i));
     67    }
    6368
    6469  private:
  • trunk/lib/classifier/Kernel_MEV.cc

    r528 r542  
    1414  }
    1515
    16 
    1716}} // of namespace classifier and namespace theplu
  • trunk/lib/classifier/Kernel_MEV.h

    r539 r542  
    5454    { return kf_->operator()(vec, DataLookup1D(data_,i)); }
    5555     
     56    inline double element(const DataLookup1D& vec, const DataLookup1D& w,
     57                          const size_t i) const
     58    {return (*kf_)(vec, DataLookup1D(data_,i), w, DataLookup1D(w.size(),1.0));}
    5659
    5760  private:
  • trunk/lib/classifier/Kernel_SEV.cc

    r539 r542  
    3030  }
    3131
     32  double Kernel_SEV::element(const DataLookup1D& vec, const DataLookup1D& w,
     33                             const size_t i) const
     34  {
     35    return (*kf_)(vec, DataLookup1D(data_,i), w, DataLookup1D(w.size(),1.0));
     36  }
     37
    3238
    3339}} // of namespace classifier and namespace theplu
  • trunk/lib/classifier/Kernel_SEV.h

    r527 r542  
    6262    ///
    6363    double element(const DataLookup1D& vec, const size_t i) const;
     64    double element(const DataLookup1D& vec, const DataLookup1D& w,
     65                   const size_t i) const;
    6466
    6567
  • trunk/lib/classifier/SVM.cc

    r539 r542  
    6464    for (size_t i=0; i<alpha_.size(); i++)
    6565      y += alpha_(i)*target_(i)*kernel_->element(x,i);
     66
     67    return y+bias_;
     68  }
     69
     70  double SVM::predict(const DataLookup1D& x, const DataLookup1D& w) const
     71  {
     72    double y=0;
     73    for (size_t i=0; i<alpha_.size(); i++)
     74      y += alpha_(i)*target_(i)*kernel_->element(x,w,i);
    6675
    6776    return y+bias_;
  • trunk/lib/classifier/SVM.h

    r539 r542  
    171171    ///
    172172    double predict(const DataLookup1D& input) const;
     173
     174    ///
     175    /// @return output from data @a input with corresponding @a weight
     176    ///
     177    double predict(const DataLookup1D& input, const DataLookup1D& weight) const;
    173178
    174179    ///
Note: See TracChangeset for help on using the changeset viewer.