Changeset 768 for trunk/yat/classifier/NBC.cc
 Timestamp:
 Feb 22, 2007, 6:18:15 PM (16 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/classifier/NBC.cc
r767 r768 74 74 bool NBC::train() 75 75 { 76 sigma _=centroids_=utility::matrix(data_.rows(), target_.nof_classes());76 sigma2_=centroids_=utility::matrix(data_.rows(), target_.nof_classes()); 77 77 utility::matrix nof_in_class(data_.rows(), target_.nof_classes()); 78 78 … … 106 106 assert(data_.rows()==input.rows()); 107 107 108 std::log(sigma_(i,c)) +109 110 108 prediction = utility::matrix(centroids_.columns(),input.columns()); 111 for (size_t c=0; c<centroid _.columns(); ++c) {109 for (size_t c=0; c<centroids_.columns(); ++c) { 112 110 double sum_ln_sigma=0; 113 111 for (size_t i=0; i<sigma2_.rows(); ++i) … … 119 117 prediction(c,s) = sum_ln_sigma; 120 118 for (size_t i=0; i<input.columns(); ++i) { 121 prediction(c,s) += std::pow(input(i,s) mean_(i,c),2)/sigma2_(i,c);119 prediction(c,s) += std::pow(input(i,s)centroids_(i,c),2)/sigma2_(i,c); 122 120 } 123 121 }
Note: See TracChangeset
for help on using the changeset viewer.