 Timestamp:
 Feb 22, 2007, 6:18:15 PM (15 years ago)
 Location:
 trunk/yat/classifier
 Files:

 2 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 } 
trunk/yat/classifier/NBC.h
r767 r768 93 93 94 94 utility::matrix centroids_; 95 utility::matrix sigma _;95 utility::matrix sigma2_; 96 96 const DataLookup2D& data_; 97 97
Note: See TracChangeset
for help on using the changeset viewer.