Changeset 3320
 Timestamp:
 Sep 19, 2014, 8:15:58 AM (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/classifier/IGP.h
r3319 r3320 28 28 #include "Target.h" 29 29 #include "yat/utility/concept_check.h" 30 #include "yat/utility/Matrix.h" 30 31 #include "yat/utility/Vector.h" 31 32 #include "yat/utility/yat_assert.h" … … 53 54 http://biostatistics.oxfordjournals.org/cgi/content/abstract/kxj029v1"> 54 55 Kapp and Tibshirani, Biostatistics (2006)</a>. 56 57 \note Distance must be symmetric, i.e., Distance(x,y) == Distance(y,x). 55 58 */ 56 59 template <typename Distance> … … 126 129 127 130 // Calculate IGP for each class 128 igp_ = utility::Vector(target_.nof_classes());131 igp_.resize(target_.nof_classes(), 0.0); 129 132 133 // calculate distances 134 utility::Matrix dist(matrix_.columns(), matrix_.columns()); 135 for (size_t i=0; i<dist.rows(); ++i) 136 for (size_t j=i+1; j<dist.rows(); ++j) { 137 dist(i,j) = dist(j,i) = distance_(matrix_.begin_column(i), 138 matrix_.end_column(i), 139 matrix_.begin_column(j)); 140 } 141 142 // find nearest neigbour for each sample 130 143 for(size_t i=0; i<target_.size(); i++) { 131 144 size_t neighbor=i; … … 134 147 if (i==j) // avoid selfself comparison 135 148 continue; 136 double dist = distance_(matrix_.begin_column(i), matrix_.end_column(i), 137 matrix_.begin_column(j)); 138 if(dist<mindist) { 139 mindist=dist; 149 if(dist(i,j)<mindist) { 150 mindist=dist(i,j); 140 151 neighbor=j; 141 152 }
Note: See TracChangeset
for help on using the changeset viewer.