Ignore:
Timestamp:
Feb 4, 2008, 4:44:44 PM (14 years ago)
Author:
Markus Ringnér
Message:

Fixes #272

File:
1 edited

Legend:

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

    r1013 r1031  
    3737#include "yat/statistics/Averager.h"
    3838#include "yat/statistics/AveragerWeighted.h"
    39 #include "yat/statistics/vector_distance.h"
     39#include "yat/statistics/distance.h"
    4040
    4141#include "yat/utility/Iterator.h"
     
    112112    // MatrixLookup and MatrixLookupWeighted
    113113    const DataLookup2D& data_;
    114 
     114    bool centroids_nan_;
    115115  };
    116116
     
    125125  template <typename Distance>
    126126  NCC<Distance>::NCC(const MatrixLookup& data, const Target& target)
    127     : SupervisedClassifier(target), centroids_(0), data_(data)
     127    : SupervisedClassifier(target), centroids_(0), data_(data), centroids_nan_(false)
    128128  {
    129129  }
     
    131131  template <typename Distance>
    132132  NCC<Distance>::NCC(const MatrixLookupWeighted& data, const Target& target)
    133     : SupervisedClassifier(target), centroids_(0), data_(data)
     133    : SupervisedClassifier(target), centroids_(0), data_(data), centroids_nan_(false)
    134134  {
    135135  }
     
    169169                              target);
    170170      }
    171       ncc->centroids_=0;
    172171    }
    173172    catch (std::bad_cast) {
     
    198197        for(size_t c=0;c<target_.nof_classes();c++) {
    199198          (*centroids_)(i,c) = class_averager[c].mean();
     199          if(class_averager[c].sum_w()==0)
     200            centroids_nan_=true;
    200201        }
    201202      }
     
    230231    prediction.clone(utility::matrix(centroids_->columns(), test.columns()));       
    231232
    232     // unweighted test data
     233    // unweighted test data and no nan's in centroids
     234    // Markus: Should test centroid_nan_ here!!!
    233235    if (const MatrixLookup* test_unweighted =
    234236        dynamic_cast<const MatrixLookup*>(&test)) {
     
    240242          utility::yat_assert<std::runtime_error>(in.size()==centroid.size());
    241243          prediction(k,j)=statistics::
    242             vector_distance(in.begin(),in.end(),centroid.begin(),
    243                             typename statistics::vector_distance_traits<Distance>::distance());
     244            distance(in.begin(),in.end(),centroid.begin(),
     245                            typename statistics::distance_traits<Distance>::distance());
    244246        }
    245247      }
     
    255257          utility::yat_assert<std::runtime_error>(in.size()==centroid.size());
    256258          prediction(k,j)=statistics::
    257             vector_distance(in.begin(),in.end(),centroid.begin(),
    258                             typename statistics::vector_distance_traits<Distance>::distance());
     259            distance(in.begin(),in.end(),centroid.begin(),
     260                            typename statistics::distance_traits<Distance>::distance());
    259261        }
    260262      }
Note: See TracChangeset for help on using the changeset viewer.