Changeset 635


Ignore:
Timestamp:
Sep 6, 2006, 3:20:24 AM (15 years ago)
Author:
Peter
Message:

closes #106 make_classifier is again taking DataLookup2D and Target making SupervisedClassifer? useful also in structure without SubsetGenerator?.

Location:
trunk/c++_tools/classifier
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/c++_tools/classifier/EnsembleBuilder.cc

    r619 r635  
    3131    while(subset_.more()) {
    3232      SupervisedClassifier* classifier=
    33         mother_.make_classifier(subset_);
     33        mother_.make_classifier(subset_.training_data(),
     34                                subset_.training_target());
    3435      classifier->train();
    3536      classifier_.push_back(classifier);
  • trunk/c++_tools/classifier/NCC.cc

    r634 r635  
    77#include <c++_tools/classifier/MatrixLookup.h>
    88#include <c++_tools/classifier/MatrixLookupWeighted.h>
    9 #include <c++_tools/classifier/SubsetGenerator.h>
    109#include <c++_tools/classifier/Target.h>
    1110#include <c++_tools/utility/matrix.h>
     
    4039
    4140  SupervisedClassifier*
    42   NCC::make_classifier(const SubsetGenerator& cs) const
     41  NCC::make_classifier(const DataLookup2D& data, const Target& target) const
    4342  {     
    4443    NCC* ncc=0;
    45     if(cs.training_data().weighted()) {
    46       ncc=new NCC(dynamic_cast<const MatrixLookupWeighted&>(cs.training_data()),
    47                   cs.training_target(),this->distance_);
     44    if(data.weighted()) {
     45      ncc=new NCC(dynamic_cast<const MatrixLookupWeighted&>(data),
     46                  target,this->distance_);
    4847    }
    4948    else {
    50       ncc=new NCC(dynamic_cast<const MatrixLookup&>(cs.training_data()),
    51                   cs.training_target(),this->distance_);
     49      ncc=new NCC(dynamic_cast<const MatrixLookup&>(data),
     50                  target,this->distance_);
    5251    }
    5352    return ncc;
  • trunk/c++_tools/classifier/NCC.h

    r634 r635  
    2222namespace classifier { 
    2323
    24   class SubsetGenerator;
    2524  class DataLookup1D;
    2625  class DataLookup2D;
     
    5756    inline const utility::matrix& centroids(void) const {return centroids_;}
    5857
    59     SupervisedClassifier* make_classifier(const SubsetGenerator&) const;
     58    SupervisedClassifier* make_classifier(const DataLookup2D&,
     59                                          const Target&) const;
    6060   
    6161    ///
  • trunk/c++_tools/classifier/SVM.cc

    r628 r635  
    44
    55#include <c++_tools/classifier/DataLookup2D.h>
    6 #include <c++_tools/classifier/SubsetGenerator.h>
    76#include <c++_tools/random/random.h>
    87#include <c++_tools/statistics/Averager.h>
     
    7069
    7170
    72   SupervisedClassifier* SVM::make_classifier(const SubsetGenerator& cs) const
    73   {
    74     // Peter, should check success of dynamic_cast
    75     const KernelLookup& data =
    76       dynamic_cast<const KernelLookup&>(cs.training_data());
    77     const Target& target=cs.training_target();
     71  SupervisedClassifier* SVM::make_classifier(const DataLookup2D& data,
     72                                             const Target& target) const
     73  {
     74    const KernelLookup& kernel =
     75      dynamic_cast<const KernelLookup&>(data);
    7876
    7977    assert(data.rows()==data.columns());
    8078    assert(data.columns()==target.size());
    8179    SVM* sc;
    82     sc = new SVM(data,target);
     80    sc = new SVM(kernel,target);
    8381
    8482
  • trunk/c++_tools/classifier/SVM.h

    r628 r635  
    44// $Id$
    55
    6 #include <c++_tools/classifier/DataLookup2D.h>
    76#include <c++_tools/classifier/KernelLookup.h>
    87#include <c++_tools/classifier/SupervisedClassifier.h>
     
    1817namespace classifier { 
    1918
    20   // forward declarations
    21   class SubsetGenerator;
    22 
     19  class DataLookup2D;
    2320  // @internal Class keeping track of which samples are support vectors and
    2421  // not. The first nof_sv elements in the vector are indices of the
     
    124121
    125122    ///
    126     /// @todo doc
     123    /// If DataLookup2D is not a KernelLookup a bad_cast exception is thrown.
    127124    ///
    128125    SupervisedClassifier*
    129     make_classifier(const SubsetGenerator&) const;
     126    make_classifier(const DataLookup2D&, const Target&) const;
    130127
    131128    ///
  • trunk/c++_tools/classifier/SupervisedClassifier.h

    r626 r635  
    1515
    1616  class DataLookup2D;
    17   class SubsetGenerator;
    1817  class Target;
    1918
     
    4645    ///
    4746    virtual SupervisedClassifier*
    48     make_classifier(const SubsetGenerator&) const =0;
     47    make_classifier(const DataLookup2D&, const Target&) const =0;
    4948   
    5049
Note: See TracChangeset for help on using the changeset viewer.