Changeset 1050 for trunk/yat/classifier


Ignore:
Timestamp:
Feb 7, 2008, 7:47:34 PM (13 years ago)
Author:
Peter
Message:

Simplifying distance structure

Location:
trunk/yat/classifier
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/classifier/IGP.h

    r1031 r1050  
    3030#include "yat/utility/vector.h"
    3131#include "yat/utility/yat_assert.h"
    32 #include "yat/statistics/distance.h"
    3332
    3433#include <cmath>
     
    7170  private:
    7271    utility::vector igp_;
     72    Distance distance_;
    7373
    7474    const MatrixLookup& matrix_;
     
    9494      for(u_int j=0; j<target_.size(); j++) {           
    9595        DataLookup1D b(matrix_,j,false);
    96         double dist=statistics::
    97           distance(a.begin,a.end(),b.begin(),
    98                           statistics::distance_traits<Distance>::distace());
     96        double dist=distance_(a.begin, a.end(), b.begin());
    9997        if(j!=i && dist<mindist) {
    10098          mindist=dist;
  • trunk/yat/classifier/KNN.h

    r1042 r1050  
    2525*/
    2626
     27#include "DataLookup1D.h"
    2728#include "DataLookupWeighted1D.h"
    2829#include "MatrixLookup.h"
     
    3031#include "SupervisedClassifier.h"
    3132#include "Target.h"
    32 #include "yat/statistics/distance.h"
    3333#include "yat/utility/matrix.h"
    3434#include "yat/utility/yat_assert.h"
     
    113113    u_int k_;
    114114
     115    Distance distance_;
    115116    ///
    116117    /// Calculates the distances between a data set and the training
     
    156157        for(size_t j=0; j<test.columns(); j++) {
    157158          classifier::DataLookup1D test(*test_unweighted,j,false);
    158           (*distances)(i,j) =
    159             statistics::distance(classifier::DataLookup1D(data_,
    160                                                           i,false).begin(),
    161                                  classifier::DataLookup1D(data_,
    162                                                           i,false).end(),
    163                                  test.begin(),
    164                                  typename statistics::
    165                                  distance_traits<Distance>::distance());
     159          classifier::DataLookup1D tmp(data_,i,false);
     160          (*distances)(i,j) = distance_(tmp.begin(), tmp.end(), test.begin());
    166161          utility::yat_assert<std::runtime_error>(!std::isnan((*distances)(i,j)));
    167162        }
     
    180175            classifier::DataLookupWeighted1D test(*test_weighted,j,false);
    181176            utility::yat_assert<std::runtime_error>(training.size()==test.size());
    182             (*distances)(i,j) =
    183               statistics::distance(training.begin(),training.end(),
    184                                    test.begin(), typename statistics::distance_traits<Distance>::distance());
     177            (*distances)(i,j) = distance_(training.begin(), training.end(),
     178                                          test.begin());
    185179            utility::yat_assert<std::runtime_error>(!std::isnan((*distances)(i,j)));
    186180          }
  • trunk/yat/classifier/NCC.h

    r1042 r1050  
    3737#include "yat/statistics/Averager.h"
    3838#include "yat/statistics/AveragerWeighted.h"
    39 #include "yat/statistics/distance.h"
    40 
    4139#include "yat/utility/Iterator.h"
    4240#include "yat/utility/IteratorWeighted.h"
     
    112110    utility::matrix* centroids_;
    113111    bool centroids_nan_;
     112    Distance distance_;
    114113
    115114    // data_ has to be of type DataLookup2D to accomodate both
     
    270269        DataLookup1D centroid(unweighted_centroids,k,false);           
    271270        utility::yat_assert<std::runtime_error>(in.size()==centroid.size());
    272         prediction(k,j)=statistics::
    273           distance(in.begin(),in.end(),centroid.begin(),
    274                    typename statistics::distance_traits<Distance>::distance());
     271        prediction(k,j) = distance_(in.begin(), in.end(), centroid.begin());
    275272      }
    276273    }
     
    287284        DataLookupWeighted1D centroid(weighted_centroids,k,false);
    288285        utility::yat_assert<std::runtime_error>(in.size()==centroid.size());
    289         prediction(k,j)=statistics::
    290           distance(in.begin(),in.end(),centroid.begin(),
    291                    typename statistics::distance_traits<Distance>::distance());
     286        prediction(k,j) = distance_(in.begin(), in.end(), centroid.begin());
    292287      }
    293288    }
Note: See TracChangeset for help on using the changeset viewer.