Changeset 520


Ignore:
Timestamp:
Feb 22, 2006, 4:01:10 PM (16 years ago)
Author:
Peter
Message:

changed internal representation in Target

Location:
trunk/lib/classifier
Files:
5 edited

Legend:

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

    r505 r520  
    3535
    3636    ///
    37     /// Generate ensemble
     37    /// Generate ensemble. Function trains each member of the Ensemble.
    3838    ///
    3939    void build(void);
  • trunk/lib/classifier/SVM.cc

    r514 r520  
    239239           
    240240      epochs++; 
    241       if (epochs>max_epochs_)
     241      if (epochs>max_epochs_){
     242        std::cerr << "WARNING: SVM: maximal number of epochs reached.\n";
    242243        return false;
     244      }
    243245    }
    244246   
  • trunk/lib/classifier/SVM.h

    r514 r520  
    117117
    118118    ///
     119    /// @return \f$\alpha\f$
     120    ///
     121    inline const gslapi::vector& alpha(void) const { return alpha_; }
     122
     123    ///
    119124    /// The C-parameter is the balance term (see train()). A very
    120125    /// large C means the training will be focused on getting samples
     
    131136    ///
    132137    inline double C(void) const { return 1/C_inverse_; }
    133 
    134     ///
    135     /// @return \f$\alpha\f$
    136     ///
    137     inline const gslapi::vector& alpha(void) const { return alpha_; }
    138138
    139139    ///
  • trunk/lib/classifier/Target.cc

    r514 r520  
    2525    : class_map_(t.class_map_)
    2626  {
    27     binary_.resize(index.size());
     27    binary_=t.binary_;
    2828    classes_.resize(index.size());
    2929    for (size_t i=0; i<index.size(); i++) {
    3030      assert(index[i]<t.size());
    3131      classes_[i]=t.classes_[index[i]];
    32       binary_[i]=t.binary_[index[i]];
    3332    }
    3433    labels_ = t.labels_;
     
    9089    }
    9190    // setting binary to false for every class
    92     binary_=std::vector<short>(label.size(),0);
     91    binary_=std::vector<char>(nof_classes(),false);
    9392   
    9493    set_binary(0,true);
    9594
    9695  }
    97 
    98   //  const Target& Target::operator=(const Target& other)
    99   //{
    100   //  classes_=other.classes_;   
    101   //  class_map_=other.class_map_;   
    102   //  labels_=other.labels_;
    103   //  return *this;
    104   //}
    105 
    106   void Target::set_binary(const size_t target, const bool b)
    107   {
    108     for (size_t i=0; i<classes_.size(); i++)
    109       if (classes_[i]==target)
    110         binary_[i]=b;
    111   }
    112 
    11396
    11497  std::ostream& operator<<(std::ostream& s, const Target& a)
  • trunk/lib/classifier/Target.h

    r514 r520  
    6969
    7070    ///
    71     /// Default binary is set to false for all classes except class 0
     71    /// Default binary is set to false for all classes except class 0.
    7272    ///
    73     /// @return true if class of sample @a i is set to true
     73    /// @return binary target for sample @a i
    7474    ///
    7575    /// @see set_binary
    7676    ///
    7777    inline bool binary(const size_t i) const
    78     { assert(i<size()); return binary_[i]; }
     78    { assert(i<size()); return binary_[operator()(i)]; }
    7979   
    8080    ///
    81     /// Class @a target is set to @a b. Default is binary set to false
    82     /// for each class.
     81    /// Binary target for each sample with class @a i is set to @a
     82    /// b. Default is binary set to false for each class except class
     83    /// 0 which is set to true.
    8384    ///
    84     void set_binary(const size_t target, const bool b);
     85    inline void set_binary(const size_t i, const bool b)
     86    { assert(i<nof_classes()); binary_[i]=b; }
    8587
    8688    ///
     
    102104
    103105  private:
    104     std::vector<short> binary_; // avoid using vector<bool>
     106    // binary target for class i
     107    std::vector<char> binary_; // avoid using vector<bool>
    105108    std::vector<size_t> classes_; // class of sample i
    106109    std::map<std::string,size_t> class_map_; 
Note: See TracChangeset for help on using the changeset viewer.