Changeset 720 for trunk/yat/classifier


Ignore:
Timestamp:
Dec 26, 2006, 7:21:36 PM (15 years ago)
Author:
Jari Häkkinen
Message:

Fixes #170. Almost all inlines removed, some classes have no cc file.

Location:
trunk/yat/classifier
Files:
31 edited

Legend:

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

    r680 r720  
    8585  }
    8686
     87  void ConsensusInputRanker::add(const InputRanker& ir)
     88  {
     89    input_rankers_.push_back(ir);
     90  }
     91
     92  size_t ConsensusInputRanker::id(size_t i) const
     93  {
     94    return id_[i];
     95  }
     96
     97  size_t ConsensusInputRanker::rank(size_t i) const
     98  {
     99    return rank_[i];
     100  }
     101
    87102  void ConsensusInputRanker::update(void)
    88103  {
  • trunk/yat/classifier/ConsensusInputRanker.h

    r680 r720  
    100100    /// the last InputRanker is added.
    101101    ///
    102     inline void add(const InputRanker& ir) { input_rankers_.push_back(ir); }
     102    void add(const InputRanker& ir);
    103103   
    104104    ///
     
    106106    /// @return index of row ranked as number \a i
    107107    ///
    108     inline size_t id(const size_t i) const { return id_[i]; }
     108    size_t id(size_t i) const;
    109109   
    110110    ///
     
    112112    /// @return rank for row \a i
    113113    ///
    114     inline size_t rank(const size_t i) const { return rank_[i]; }
     114    size_t rank(size_t i) const;
    115115   
    116116    ///
  • trunk/yat/classifier/DataLookup1D.cc

    r680 r720  
    4242  }
    4343 
     44
    4445  DataLookup1D::DataLookup1D(const size_t size, const double value)
    4546    : column_vector_(false), index_(0), owner_(true)
     
    4748    matrix_ = new MatrixLookup(1,size,value);
    4849  }
     50
    4951
    5052  DataLookup1D::DataLookup1D(const DataLookup1D& other)
     
    5456  }
    5557
     58
    5659  DataLookup1D::~DataLookup1D()
    5760  {
    5861    if (owner_)
    5962      delete matrix_;
     63  }
     64
     65
     66  size_t DataLookup1D::size(void) const
     67  {
     68    return column_vector_ ? matrix_->rows() : matrix_->columns();
     69  }
     70
     71
     72  double DataLookup1D::operator()(const size_t i) const
     73  {
     74    assert(i<size());
     75    return column_vector_ ? (*matrix_)(i,index_) : (*matrix_)(index_,i);
     76  }
     77
     78
     79  double DataLookup1D::operator[](const size_t i) const
     80  {
     81    return this->operator()(i);
    6082  }
    6183
  • trunk/yat/classifier/DataLookup1D.h

    r680 r720  
    7373    /// @return number of elements
    7474    ///
    75     inline size_t size(void) const
    76       { return column_vector_ ? matrix_->rows() : matrix_->columns(); }
     75    size_t size(void) const;
    7776
    7877    ///
    7978    /// @brief access operator
    8079    ///
    81     inline double operator()(const size_t i) const
    82     {
    83       assert(i<size());
    84       return column_vector_ ? (*matrix_)(i,index_) : (*matrix_)(index_,i);
    85     }
     80    double operator()(const size_t i) const;
    8681
    8782    ///
    8883    /// @brief access operator
    8984    ///
    90     inline double operator[](const size_t i) const
    91     {
    92       return this->operator()(i);
    93     }
    94 
     85    double operator[](const size_t i) const;
    9586
    9687    ///
  • trunk/yat/classifier/DataLookup2D.cc

    r680 r720  
    115115  }
    116116
     117
     118  size_t DataLookup2D::columns(void) const
     119  {
     120    return column_index_.size();
     121  }
     122
     123
     124  size_t DataLookup2D::rows(void) const
     125  {
     126    return row_index_.size();
     127  }
     128
     129
    117130  const DataLookup2D& DataLookup2D::operator=(const DataLookup2D& other)
    118131  {
  • trunk/yat/classifier/DataLookup2D.h

    r680 r720  
    9999    /// @return number of columns
    100100    ///
    101     inline size_t columns(void) const { return column_index_.size(); }
     101    size_t columns(void) const;
    102102
    103103    ///
    104104    /// @return number of rows
    105105    ///
    106     inline size_t rows(void) const { return row_index_.size(); }
     106    size_t rows(void) const;
    107107
    108108    ///
  • trunk/yat/classifier/DataLookupWeighted1D.cc

    r680 r720  
    5858  }
    5959
     60
    6061  DataLookupWeighted1D::~DataLookupWeighted1D()
    6162  {
     
    6566
    6667
     68  double DataLookupWeighted1D::data(const size_t i) const
     69  {
     70    return column_vector_? matrix_->data(i,index_) : matrix_->data(index_,i);
     71  }
     72
     73
     74  size_t DataLookupWeighted1D::size(void) const
     75  {
     76    return column_vector_ ? matrix_->rows() : matrix_->columns();
     77  }
     78
     79
     80  double DataLookupWeighted1D::weight(const size_t i) const
     81  {
     82    return column_vector_? matrix_->weight(i,index_) : matrix_->weight(index_,i);
     83  }
     84
     85
     86  double DataLookupWeighted1D::operator()(const size_t i) const
     87  {
     88    return column_vector_ ? (*matrix_)(i,index_) : (*matrix_)(index_,i);
     89  }
     90
     91
     92  double DataLookupWeighted1D::operator[](const size_t i) const
     93  {
     94    return this->operator()(i);
     95  }
     96
    6797}}} // of namespace classifier, yat, and theplu
  • trunk/yat/classifier/DataLookupWeighted1D.h

    r680 r720  
    7070    virtual ~DataLookupWeighted1D();
    7171
     72    /**
     73       \return data(i)
     74    */
     75    double data(const size_t i) const;
     76
    7277    ///
    7378    /// @return number of elements
    7479    ///
    75     inline size_t size(void) const
    76       { return column_vector_ ? matrix_->rows() : matrix_->columns(); }
    77 
    78     ///
    79     /// @return data(i)
    80     ///
    81     inline double data(const size_t i) const
    82     {
    83       return column_vector_? matrix_->data(i,index_) : matrix_->data(index_,i);
    84     }
     80    size_t size(void) const;
    8581
    8682    ///
    8783    /// @return weight(i)
    8884    ///
    89     inline double weight(const size_t i) const
    90     {
    91       return column_vector_? matrix_->weight(i,index_) :
    92         matrix_->weight(index_,i);
    93     }
     85    double weight(const size_t i) const;
    9486
    9587    ///
    9688    /// @return data(i) * weight(i)
    9789    ///
    98     inline double operator()(const size_t i) const
    99     {
    100       return column_vector_ ? (*matrix_)(i,index_) : (*matrix_)(index_,i);
    101     }
     90    double operator()(const size_t i) const;
    10291
    10392    ///
    10493    /// @return data(i) * weight(i)
    10594    ///
    106     inline double operator[](const size_t i) const
    107     {
    108       return this->operator()(i);
    109     }
    110 
     95    double operator[](const size_t i) const;
    11196
    11297  private:
  • trunk/yat/classifier/EnsembleBuilder.cc

    r704 r720  
    5757  }
    5858
     59
     60  const SupervisedClassifier& EnsembleBuilder::classifier(size_t i) const
     61  {
     62    return *(classifier_[i]);
     63  }
     64
     65
     66  u_long EnsembleBuilder::size(void) const
     67  {
     68    return classifier_.size();
     69  }
     70
     71
    5972  void  EnsembleBuilder::predict
    6073  (const DataLookup2D& data,
     
    90103
    91104
    92 
    93105  const std::vector<std::vector<statistics::Averager> >&
    94106  EnsembleBuilder::validate(void)
  • trunk/yat/classifier/EnsembleBuilder.h

    r680 r720  
    5555    virtual ~EnsembleBuilder(void);
    5656
    57 
    5857    ///
    5958    /// Generate ensemble. Function trains each member of the Ensemble.
     
    6463    /// @Return classifier
    6564    ///
    66     inline const SupervisedClassifier& classifier(size_t i) const
    67     {
    68       return *(classifier_[i]);
    69     }
     65    const SupervisedClassifier& classifier(size_t i) const;
    7066     
    7167    ///
    7268    /// @Return Number of classifiers in ensemble
    7369    ///
    74     inline u_long size(void) const
    75     {
    76       return classifier_.size();
    77     }
     70    u_long size(void) const;
    7871
    7972    ///
     
    9386       kernel corresponds to.
    9487    */
    95     void  predict(const DataLookup2D& data,
    96                   std::vector<std::vector<statistics::Averager> > &);
    97 
     88    void predict(const DataLookup2D& data,
     89                 std::vector<std::vector<statistics::Averager> > &);
    9890
    9991  private:
  • trunk/yat/classifier/FeatureSelector.cc

    r680 r720  
    5050
    5151
     52  const std::vector<size_t> FeatureSelector::features(void) const
     53  {
     54    return features_;
     55  }
     56
     57
    5258  const MatrixLookup& FeatureSelector::get(const MatrixLookup& matrix)
    5359  {
  • trunk/yat/classifier/FeatureSelector.h

    r680 r720  
    6666    /// @return vector of indices corresponding to selected features.
    6767    ///
    68     inline const std::vector<size_t> features(void) const { return features_; }
     68    const std::vector<size_t> features(void) const;
    6969
    7070    ///
  • trunk/yat/classifier/InputRanker.cc

    r680 r720  
    6969
    7070
    71 
    7271  InputRanker::InputRanker(const MatrixLookupWeighted& data,
    7372                           const Target& target,
     
    9796
    9897
     98  const std::vector<size_t>& InputRanker::id(void) const
     99  {
     100    return id_;
     101  }
     102
     103
     104  const std::vector<size_t>& InputRanker::rank(void) const
     105  {
     106    return rank_;
     107  }
     108
     109
     110  double InputRanker::score(size_t rank) const
     111  {
     112    return score_[rank];
     113  }
    99114
    100115}}} // of namespace classifier, yat, and theplu
  • trunk/yat/classifier/InputRanker.h

    r680 r720  
    5454    InputRanker(const MatrixLookup&, const Target&, statistics::Score&);
    5555
    56 
    5756    ///
    5857    /// Constructor taking data, target, a Score
     
    6362                statistics::Score&);
    6463
    65 
    6664    ///
    6765    /// highest ranked gene is ranked as number zero @return id
    6866    /// (index) of input ranked as number \a i
    6967    ///
    70     inline const std::vector<size_t>& id(void) const {return id_;}
     68    const std::vector<size_t>& id(void) const;
    7169
    7270    ///
     
    7472    /// id (row) \a i
    7573    ///
    76     inline const std::vector<size_t>& rank(void) const {return rank_;}
     74    const std::vector<size_t>& rank(void) const;
    7775
    7876    ///
     
    8482    /// number @a rank.
    8583    ///
    86     inline double score(size_t rank) const { return score_[rank]; }
    87 
     84    double score(size_t rank) const;
    8885
    8986  private:
  • trunk/yat/classifier/Kernel.cc

    r680 r720  
    7777  }
    7878
     79
    7980  Kernel::~Kernel()
    8081  {
     
    9091
    9192 
     93  const DataLookup2D& Kernel::data(void) const
     94  {
     95    return *data_;
     96  }
     97
     98
    9299  double Kernel::element(const DataLookup1D& vec, const size_t i) const
    93100  {
     
    107114  }
    108115
     116
     117  size_t Kernel::size(void) const
     118  {
     119    return data_->columns();
     120  }
     121
     122
     123  bool Kernel::weighted(void) const
     124  {
     125    return data_w_;
     126  }
     127
    109128}}} // of namespace classifier, yat, and theplu
  • trunk/yat/classifier/Kernel.h

    r680 r720  
    105105    /// @return const reference to the underlying data.
    106106    ///
    107     inline const DataLookup2D& data(void) const { return *data_; }
    108 
    109     ///
    110     /// @brief number of samples
    111     ///
    112     inline size_t size(void) const { return data_->columns(); }
     107    const DataLookup2D& data(void) const;
    113108
    114109    ///
     
    164159    virtual const Kernel* selected(const std::vector<size_t>& index) const=0;
    165160
     161    /**
     162       \brief number of samples
     163    */
     164    size_t size(void) const;
     165
    166166    ///
    167167    /// @return true if kernel is calculated using weights
    168168    ///
    169     inline bool weighted(void) const { return data_w_; }
     169    bool weighted(void) const;
    170170
    171171  protected:
  • trunk/yat/classifier/KernelLookup.cc

    r680 r720  
    3434namespace theplu {
    3535namespace yat {
    36 namespace classifier { 
     36namespace classifier {
    3737
    3838  KernelLookup::KernelLookup(const Kernel& kernel, const bool own)
     
    4444    row_index_=column_index_;
    4545  }
    46  
     46
     47
    4748  KernelLookup::KernelLookup(const Kernel& kernel,
    4849                             const std::vector<size_t>& row,
     
    114115  }
    115116
    116   const KernelLookup*
    117   KernelLookup::training_data(const std::vector<size_t>& train) const
    118   {
    119     return new KernelLookup(*this,train,train);
    120   }
    121 
    122 
    123   const KernelLookup*
    124   KernelLookup::validation_data(const std::vector<size_t>& train,
    125                                 const std::vector<size_t>& validation) const
    126   {
    127     return new KernelLookup(*this,train,validation);
    128   }
     117
     118  const DataLookup2D* KernelLookup::data(void) const
     119  {
     120    return kernel_->data().training_data(column_index_);
     121  }
     122
     123
     124  double KernelLookup::element(const DataLookup1D& vec, size_t i) const
     125  {
     126    return kernel_->element(vec, row_index_[i]);
     127  }
     128
     129
     130  double KernelLookup::element(const DataLookupWeighted1D& vec, size_t i) const
     131  {
     132    return kernel_->element(vec, row_index_[i]);
     133  }
     134
     135
     136  const Kernel* KernelLookup::kernel(void) const
     137  {
     138    return kernel_;
     139  }
    129140
    130141
     
    263274  }
    264275
     276
     277  const KernelLookup*
     278  KernelLookup::training_data(const std::vector<size_t>& train) const
     279  {
     280    return new KernelLookup(*this,train,train);
     281  }
     282
     283
     284  const KernelLookup*
     285  KernelLookup::validation_data(const std::vector<size_t>& train,
     286                                const std::vector<size_t>& validation) const
     287  {
     288    return new KernelLookup(*this,train,validation);
     289  }
     290
     291
     292  bool KernelLookup::weighted(void) const
     293  {
     294    return kernel_->weighted();
     295  }
     296
     297
     298  double KernelLookup::operator()(size_t row, size_t column) const
     299  {
     300    return (*kernel_)(row_index_[row],column_index_[column]);
     301  }
     302
    265303}}} // of namespace classifier, yat, and theplu
  • trunk/yat/classifier/KernelLookup.h

    r680 r720  
    6363
    6464  public:
    65    
     65
    6666    ///
    6767    /// @brief Constructor a Lookup into a Kernel
     
    101101    KernelLookup(const Kernel& kernel, const std::vector<size_t>& row,
    102102                 const std::vector<size_t>& column, const bool owner=false);
    103    
     103
    104104    ///
    105105    /// @brief Copy constructor.
     
    128128    KernelLookup(const KernelLookup& kl, const std::vector<size_t>& row,
    129129                 const std::vector<size_t>& column);
    130    
     130
    131131    ///
    132132    /// Constructor taking the column (default) or row index vector as
     
    138138    /// undefined.
    139139    ///
    140     KernelLookup(const KernelLookup& kernel, const std::vector<size_t>&,
     140    KernelLookup(const KernelLookup& kernel, const std::vector<size_t>&,
    141141                 const bool row=false);
    142142
     
    148148    virtual ~KernelLookup(void);
    149149
    150 
    151     ///
    152     /// Creates a sub-Kernel identical to the one created using
    153     /// KernelLookup(*this, train, train).
    154     ///
    155     /// @return pointer to dynamically allocated sub-Lookup of the KernelLookup
    156     ///
    157     /// @Note Returns a dynamically allocated DataLookup2D, which has
     150    ///
     151    /// Each column in returned MatrixLookup corresponds to the column
     152    /// in KernelLookup.
     153    ///
     154    /// @Note Returns a dynamically allocated MatrixLookup, which has
    158155    /// to be deleted by the caller to avoid memory leaks.
    159156    ///
    160     const KernelLookup* training_data(const std::vector<size_t>& train) const;
    161 
    162 
    163     ///
    164     /// In returned kernel each row corresponds to a training sample
    165     /// and each column corresponds to a validation sample. The
    166     /// created sub-KernelLookup is equivalent to using
    167     /// KernelLooup(*this, train, validation).
    168     ///
    169     /// @return sub-Lookup of the DataLookup2D
    170     ///
    171     /// @Note Returns a dynamically allocated DataLookup2D, which has
    172     /// to be deleted by the caller to avoid memory leaks.
    173     ///
    174     const KernelLookup*
    175     validation_data(const std::vector<size_t>& train,
    176                     const std::vector<size_t>& validation) const;
    177 
    178 
     157    const DataLookup2D* data(void) const;
     158
     159    /**
     160       Function to calculate a new Kernel element using the underlying
     161       KernelFunction. The value is calulated between @a vec and the
     162       data vector of the \f$ i \f$ th sample, in other words, the
     163       sample corresponding to the \f$ i \f$ th row or \f$ i \f$ th
     164       column. In case KernelLookup is a sub-Kernel and not symmetric,
     165       the kernel value is calculated between @a vec and the data
     166       vector corresponding to \f$ i \f$ th row.
     167    */
     168    double element(const DataLookup1D& vec, size_t i) const;
     169
     170    /**
     171       Function to calculate a new Kernel element using the underlying
     172       KernelFunction. The value is calulated between @a vec and the
     173       data vector of the \f$ i \f$ th sample, in other words, the
     174       sample corresponding to the \f$ i \f$ th row or \f$ i \f$ th
     175       column. In case KernelLookup is a sub-Kernel and not symmetric,
     176       the kernel value is calculated between @a vec and the data
     177       vector corresponding to \f$ i \f$ th row.
     178    */
     179    double element(const DataLookupWeighted1D& vec, size_t i) const;
     180
     181    const Kernel* kernel(void) const;
     182
     183    /**
     184       Each element in returned KernelLookup is calculated using only
     185       selected features (defined by @a index). Each element
     186       corresponds to the same pair of samples as in the original
     187       KernelLookup.
     188
     189       \Note Returns a dynamically allocated KernelLookup, which has
     190       to be deleted by the caller to avoid memory leaks.
     191    */
     192    const KernelLookup* selected(const std::vector<size_t>& index) const;
     193   
    179194    /**
    180195       This function is useful when predicting on a independent data
     
    192207    const KernelLookup* test_kernel(const MatrixLookup& data) const;
    193208
    194 
    195209    /**
    196210       This function is useful when predicting on a independent data
     
    208222    const KernelLookup* test_kernel(const MatrixLookupWeighted& data) const;
    209223
    210 
    211     ///
    212     /// @return element at position (\a row, \a column) in the Kernel
    213     /// matrix
    214     ///
    215     inline double operator()(const size_t row,const size_t column) const
    216     { return (*kernel_)(row_index_[row],column_index_[column]); }
    217 
    218     ///
    219     /// Each column in returned MatrixLookup corresponds to the column
    220     /// in KernelLookup.
    221     ///
    222     /// @Note Returns a dynamically allocated MatrixLookup, which has
    223     /// to be deleted by the caller to avoid memory leaks.
    224     ///
    225     inline const DataLookup2D* data(void) const
    226     { return kernel_->data().training_data(column_index_); }
    227 
    228 
    229     ///
    230     /// Function to calculate a new Kernel element using the
    231     /// underlying KernelFunction. The value is calulated between @a
    232     /// vec and the data vector of the \f$ i \f$ th sample, in other
    233     /// words, the sample corresponding to the \f$ i \f$ th row or
    234     /// \f$ i \f$ th column. In case KernelLookup is a sub-Kernel and not
    235     /// symmetric, the kernel value is calculated between @a vec and
    236     /// the data vector corresponding to \f$ i \f$ th row.
    237     ///
    238     inline double element(const DataLookup1D& vec, const size_t i) const
    239     { return kernel_->element(vec, row_index_[i]); }
    240 
    241     ///
    242     /// Function to calculate a new Kernel element using the
    243     /// underlying KernelFunction. The value is calulated between @a
    244     /// vec and the data vector of the \f$ i \f$ th sample, in other
    245     /// words, the sample corresponding to the \f$ i \f$ th row or
    246     /// \f$ i \f$ th column. In case KernelLookup is a sub-Kernel and not
    247     /// symmetric, the kernel value is calculated between @a vec and
    248     /// the data vector corresponding to \f$ i \f$ th row.
    249     ///
    250     inline double element(const DataLookupWeighted1D& vec, const size_t i) const
    251     { return kernel_->element(vec, row_index_[i]); }
    252 
    253     ///
    254     /// Each element in returned KernelLookup is calculated using only
    255     /// selected features (defined by @a index). Each element
    256     /// corresponds to the same pair of samples as in the original
    257     /// KernelLookup.
    258     ///
    259     /// @Note Returns a dynamically allocated KernelLookup, which has
    260     /// to be deleted by the caller to avoid memory leaks.
    261     ///
    262     const KernelLookup* selected(const std::vector<size_t>& index) const;
    263    
    264     ///
    265     /// @return true if underlying Kernel is weighted
    266     ///
    267     inline bool weighted(void) const { return kernel_->weighted(); }
    268 
    269     inline const Kernel* kernel(void) const { return kernel_; }
    270    
     224    /**
     225       \brief Creates a sub-Kernel identical to the one created using
     226       KernelLookup(*this, train, train).
     227   
     228       \return pointer to dynamically allocated sub-Lookup of the
     229       KernelLookup
     230   
     231       \Note Returns a dynamically allocated DataLookup2D, which has
     232       to be deleted by the caller to avoid memory leaks.
     233    */
     234    const KernelLookup* training_data(const std::vector<size_t>& train) const;
     235
     236    /**
     237       In returned kernel each row corresponds to a training sample
     238       and each column corresponds to a validation sample. The created
     239       sub-KernelLookup is equivalent to using KernelLooup(*this,
     240       train, validation).
     241   
     242       \return sub-Lookup of the DataLookup2D
     243   
     244       \Note Returns a dynamically allocated DataLookup2D, which has
     245       to be deleted by the caller to avoid memory leaks.
     246    */
     247    const KernelLookup*
     248    validation_data(const std::vector<size_t>& train,
     249                    const std::vector<size_t>& validation) const;
     250
     251    /**
     252       \return true if underlying Kernel is weighted
     253    */
     254    bool weighted(void) const;
     255
     256    /**
     257       \return element at position (\a row, \a column) in the Kernel
     258       matrix
     259    */
     260    double operator()(size_t row, size_t column) const;
     261
    271262  private:
    272263    const KernelLookup& operator=(const KernelLookup&);
     
    274265    const Kernel* kernel_;
    275266   
    276   }; // class KernelLookup
     267  }; // class KernelLookup
    277268
    278269}}} // of namespace classifier, yat, and theplu
  • trunk/yat/classifier/MatrixLookup.cc

    r680 r720  
    191191
    192192
     193  double MatrixLookup::operator()(const size_t row, const size_t column) const
     194  {
     195    assert(row<rows());
     196    assert(column<columns());
     197    return (*data_)(row_index_[row], column_index_[column]);
     198  }
     199
     200
     201
    193202  const MatrixLookup& MatrixLookup::operator=(const MatrixLookup& other)
    194203  {
  • trunk/yat/classifier/MatrixLookup.h

    r680 r720  
    231231    /// @return element
    232232    ///
    233     inline double operator()(const size_t row, const size_t column) const
    234     {
    235       assert(row<rows());
    236       assert(column<columns());
    237       return (*data_)(row_index_[row], column_index_[column]);
    238     }
     233    double operator()(const size_t row, const size_t column) const;
    239234
    240235    ///
  • trunk/yat/classifier/MatrixLookupWeighted.cc

    r680 r720  
    231231
    232232
     233
     234  double MatrixLookupWeighted::data(size_t row, size_t column) const
     235  {
     236    return (*data_)(row_index_[row], column_index_[column]);
     237  }
     238
     239
     240
    233241  const MatrixLookupWeighted*
    234242  MatrixLookupWeighted::selected(const std::vector<size_t>& i) const
     
    256264
    257265
     266  double MatrixLookupWeighted::weight(size_t row, size_t column) const
     267  {
     268    return (*weights_)(row_index_[row], column_index_[column]);
     269  }
     270
     271
     272
    258273  bool MatrixLookupWeighted::weighted(void) const
    259274  {
    260275    return true;
     276  }
     277
     278
     279
     280  double MatrixLookupWeighted::operator()(const size_t row,
     281                                          const size_t column) const
     282  {
     283    return (weight(row,column) ? data(row,column)*weight(row,column) : 0);
    261284  }
    262285
  • trunk/yat/classifier/MatrixLookupWeighted.h

    r680 r720  
    211211    /// @return data value of element (@a row, @a column)
    212212    ///
    213     inline double data(size_t row, size_t column) const
    214     { return (*data_)(row_index_[row], column_index_[column]); }
     213    double data(size_t row, size_t column) const;
    215214
    216215    ///
     
    252251    /// @return weight value of element (@a row, @a column)
    253252    ///
    254     inline double weight(size_t row, size_t column) const
    255     { return (*weights_)(row_index_[row], column_index_[column]); }
     253    double weight(size_t row, size_t column) const;
    256254
    257255    ///
     
    265263    /// @return weight * data for element \f$ i j\f$
    266264    ///
    267     inline double operator()(const size_t row, const size_t column) const
    268     {
    269       return (weight(row,column) ? data(row,column)*weight(row,column) : 0);
    270     }
     265    double operator()(const size_t row, const size_t column) const;
    271266
    272267    ///
  • trunk/yat/classifier/NCC.cc

    r685 r720  
    5656  NCC::~NCC()   
    5757  {
     58  }
     59
     60
     61  const utility::matrix& NCC::centroids(void) const
     62  {
     63    return centroids_;
    5864  }
    5965
  • trunk/yat/classifier/NCC.h

    r680 r720  
    7575    /// @return the centroids for each class as columns in a matrix.
    7676    ///
    77     inline const utility::matrix& centroids(void) const {return centroids_;}
     77    const utility::matrix& centroids(void) const;
    7878
    7979    SupervisedClassifier* make_classifier(const DataLookup2D&,
  • trunk/yat/classifier/SVM.cc

    r706 r720  
    7878  }
    7979
     80  const utility::vector& SVM::alpha(void) const
     81  {
     82    return alpha_;
     83  }
     84
     85  double SVM::C(void) const
     86  {
     87    return 1.0/C_inverse_;
     88  }
    8089
    8190  void SVM::calculate_margin(void)
     
    8998  }
    9099
     100  double SVM::kernel_mod(const size_t i, const size_t j) const
     101  {
     102    return i!=j ? (*kernel_)(i,j) : (*kernel_)(i,j) + C_inverse_;
     103  }
    91104
    92105  SupervisedClassifier* SVM::make_classifier(const DataLookup2D& data,
     
    110123  }
    111124
     125  long int SVM::max_epochs(void) const
     126  {
     127    return max_epochs_;
     128  }
     129
     130  const theplu::yat::utility::vector& SVM::output(void) const
     131  {
     132    return output_;
     133  }
     134
    112135  void SVM::predict(const DataLookup2D& input, utility::matrix& prediction) const
    113136  {
     
    153176    trained_=false;
    154177    alpha_=utility::vector(target_.size(), 0);
     178  }
     179
     180  int SVM::target(size_t i) const
     181  {
     182    return target_.binary(i) ? 1 : -1;
    155183  }
    156184
  • trunk/yat/classifier/SVM.h

    r706 r720  
    7676    /// @return \f$ \alpha \f$
    7777    ///
    78     inline const utility::vector& alpha(void) const { return alpha_; }
     78    const utility::vector& alpha(void) const;
    7979
    8080    ///
     
    9292    /// @returns mean of vector \f$ C_i \f$
    9393    ///
    94     inline double C(void) const { return 1.0/C_inverse_; }
     94    double C(void) const;
    9595
    9696    ///
     
    9999    /// @return number of maximal epochs
    100100    ///
    101     inline long int max_epochs(void) const {return max_epochs_;}
     101    long int max_epochs(void) const;
    102102   
    103103    /**
     
    107107        @return output
    108108    */
    109     inline const theplu::yat::utility::vector&
    110     output(void) const { return output_; }
     109    const theplu::yat::utility::vector& output(void) const;
    111110
    112111    /**
     
    219218    /// @return kernel modified with diagonal term (soft margin)
    220219    ///
    221     inline double kernel_mod(const size_t i, const size_t j) const
    222     { return i!=j ? (*kernel_)(i,j) : (*kernel_)(i,j) + C_inverse_; }
    223    
     220    double kernel_mod(const size_t i, const size_t j) const;
     221
     222    ///
    224223    /// @return 1 if i belong to binary target true else -1
    225     inline int target(size_t i) const { return target_.binary(i) ? 1 : -1; }
     224    ///
     225    int target(size_t i) const;
    226226
    227227    utility::vector alpha_;
  • trunk/yat/classifier/Sampler.cc

    r680 r720  
    3838  }
    3939
     40  u_long Sampler::size(void) const
     41  {
     42    return training_index_.size();
     43  }
     44
     45  const Target& Sampler::target(void) const
     46  {
     47    return target_;
     48  }
     49
     50  const std::vector<size_t>&
     51  Sampler::training_index(std::vector<size_t>::size_type i) const
     52  {
     53    return training_index_[i];
     54  }
     55
     56  const Target&
     57  Sampler::training_target(std::vector<Target>::size_type i) const
     58  {
     59    return training_target_[i];
     60  }
     61
     62  const std::vector<size_t>&
     63  Sampler::validation_index(std::vector<size_t>::size_type i) const
     64  {
     65    return validation_index_[i];
     66  }
     67
     68  const Target&
     69  Sampler::validation_target(std::vector<Target>::size_type i) const
     70  {
     71    return validation_target_[i];
     72  }
     73
    4074}}} // of namespace classifier, yat, and theplu
  • trunk/yat/classifier/Sampler.h

    r680 r720  
    5656    /// @return number of partitions
    5757    ///
    58     inline u_long size(void) const { return training_index_.size(); }
     58    u_long size(void) const;
    5959
    6060    ///
    6161    /// @return the targets for the total set
    6262    ///
    63     inline const Target& target(void) const { return target_; }
     63    const Target& target(void) const;
    6464
    6565    ///
    6666    /// @return training indices
    6767    ///
    68     inline const std::vector<size_t>&
    69     training_index(std::vector<size_t>::size_type i) const
    70     { return training_index_[i]; }
     68    const std::vector<size_t>&
     69    training_index(std::vector<size_t>::size_type i) const;
    7170
    7271    ///
     
    7574    /// @note if state is invalid the result is undefined
    7675    ///
    77     inline const Target&
    78     training_target(std::vector<Target>::size_type i) const
    79     { return training_target_[i]; }
     76    const Target&
     77    training_target(std::vector<Target>::size_type i) const;
    8078
    8179    ///
     
    8482    /// @note if state is invalid the result is undefined
    8583    ///
    86     inline const std::vector<size_t>&
    87     validation_index(std::vector<size_t>::size_type i) const
    88     { return validation_index_[i]; }
     84    const std::vector<size_t>&
     85    validation_index(std::vector<size_t>::size_type i) const;
    8986
    9087    ///
     
    9390    /// @note if state is invalid the result is undefined
    9491    ///
    95     inline const Target&
    96     validation_target(std::vector<Target>::size_type i) const
    97     { return validation_target_[i]; }
    98 
     92    const Target& validation_target(std::vector<Target>::size_type i) const;
    9993
    10094  protected:
  • trunk/yat/classifier/SubsetGenerator.cc

    r704 r720  
    205205  }
    206206
     207
     208  u_long SubsetGenerator::size(void) const
     209  {
     210    return sampler_.size();
     211  }
     212
     213
     214  const Target& SubsetGenerator::target(void) const
     215  {
     216    return sampler_.target();
     217  }
     218
     219
     220  const DataLookup2D&
     221  SubsetGenerator::training_data(std::vector<DataLookup2D*>::size_type i) const
     222  {
     223    return *(training_data_[i]);
     224  }
     225
     226
     227  const std::vector<size_t>&
     228  SubsetGenerator::training_features(std::vector<size_t>::size_type i) const
     229  {
     230    return f_selector_ ? features_[i] : features_[0];
     231  }
     232
     233
     234  const std::vector<size_t>&
     235  SubsetGenerator::training_index(std::vector<size_t>::size_type i) const
     236  {
     237    return sampler_.training_index(i);
     238  }
     239
     240
     241  const Target&
     242  SubsetGenerator::training_target(std::vector<Target>::size_type i) const
     243  {
     244    return training_target_[i];
     245  }
     246
     247
     248  const DataLookup2D&
     249  SubsetGenerator::validation_data(std::vector<DataLookup2D*>::size_type i) const
     250  {
     251    return *(validation_data_[i]);
     252  }
     253
     254
     255  const std::vector<size_t>&
     256  SubsetGenerator::validation_index(std::vector<size_t>::size_type i) const
     257  {
     258    return sampler_.validation_index(i);
     259  }
     260
     261
     262  const Target&
     263  SubsetGenerator::validation_target(std::vector<Target>::size_type i) const
     264  {
     265    return validation_target_[i];
     266  }
     267
    207268}}} // of namespace classifier, yat, and theplu
  • trunk/yat/classifier/SubsetGenerator.h

    r704 r720  
    7272    /// @return number of subsets
    7373    ///
    74     inline u_long size(void) const { return sampler_.size(); }
     74    u_long size(void) const;
    7575
    7676    ///
    7777    /// @return the target for the total set
    7878    ///
    79     inline const Target& target(void) const { return sampler_.target(); }
    80 
     79    const Target& target(void) const;
    8180
    8281    ///
    8382    /// @return the sampler for the total set
    8483    ///
    85     //    inline const Sampler& sampler(void) const { return sampler_; }
    86 
     84    //    const Sampler& sampler(void) const;
    8785
    8886    ///
    8987    /// @return training data
    9088    ///
    91     inline const DataLookup2D& training_data(std::vector<DataLookup2D*>::
    92                                              size_type i) const
    93     { return *(training_data_[i]); }
     89    const DataLookup2D&
     90    training_data(std::vector<DataLookup2D*>::size_type i) const;
    9491
    9592    ///
    9693    /// @return training features
    9794    ///
    98     inline const std::vector<size_t>& training_features(std::vector<size_t>::
    99                                                         size_type i) const
    100     { return f_selector_ ? features_[i] : features_[0]; }
    101 
     95    const std::vector<size_t>&
     96    training_features(std::vector<size_t>::size_type i) const;
    10297
    10398    ///
    10499    /// @return training index
    105100    ///
    106     inline const std::vector<size_t>& training_index(std::vector<size_t>::
    107                                                      size_type i) const
    108     { return sampler_.training_index(i); }
     101    const std::vector<size_t>&
     102    training_index(std::vector<size_t>::size_type i) const;
    109103
    110104    ///
    111105    /// @return training target
    112106    ///
    113     inline const Target& training_target(std::vector<Target>::
    114                                          size_type i) const
    115     { return training_target_[i]; }
     107    const Target& training_target(std::vector<Target>::size_type i) const;
    116108
    117109    ///
    118110    /// @return validation data
    119111    ///
    120     inline const DataLookup2D& validation_data(std::vector<DataLookup2D*>::
    121                                                size_type i) const
    122     { return *(validation_data_[i]); }
     112    const DataLookup2D&
     113    validation_data(std::vector<DataLookup2D*>::size_type i) const;
    123114
    124115    ///
    125116    /// @return validation index
    126117    ///
    127     inline const std::vector<size_t>& validation_index(std::vector<size_t>::
    128                                                        size_type i) const
    129     { return sampler_.validation_index(i); }
     118    const std::vector<size_t>&
     119    validation_index(std::vector<size_t>::size_type i) const;
    130120
    131121    ///
    132122    /// @return validation target
    133123    ///
    134     inline const Target& validation_target(std::vector<Target>::
    135                                            size_type i) const
    136     { return validation_target_[i]; }
     124    const Target& validation_target(std::vector<Target>::size_type i) const;
    137125
    138126    ///
    139127    /// @return true if weighted
    140128    /// @todo remove this function
    141     //inline bool weighted(void) const { return weighted_; }
     129    //bool weighted(void) const;
    142130
    143131  private:
  • trunk/yat/classifier/Target.h

    r714 r720  
    5959    /// @brief Copy Constructor
    6060    ///
    61     //inline Target(const Target& other)
     61    //Target(const Target& other)
    6262    //  : classes_(other.classes_), class_map_(other.class_map_),
    6363    //    labels_(other.labels_) {}
Note: See TracChangeset for help on using the changeset viewer.