67 for (
unsigned i = 0 ;
i < _n ;
i++)
96 for (
unsigned i = 0 ;
i < _n ;
i++)
98 std::vector<floatFeature> v;
131 std::vector<floatFeature> v;
132 for (
unsigned i = 0 ;
i < _n ;
i++)
141 std::vector<floatFeature>::const_iterator viter = v.begin();
142 minval = maxval = *viter;
143 for (viter++; viter != v.end(); viter++)
147 else if (*viter > maxval)
175 std::vector<FeatureVector>::const_iterator
i =
itemsBegin();
176 std::vector<FeatureVector>::const_iterator best =
i;
200 std::vector<FeatureVector>::const_iterator
i =
itemsBegin();
201 std::vector<FeatureVector>::const_iterator best =
i;
205 unsigned bestIndex = 0;
221 #ifdef UNUSED // detected as unused 29.6.2018 244 for (
unsigned j = 0 ;
j < _ts->
size() ;
j++)
247 for (
unsigned i = 0 ;
i <
size() ;
i++)
266 _os <<
"1 " <<
size() << std::endl;
267 for (
size_t j = 0;
j <
size();
j++)
278 _os <<
"1 " <<
size() << std::endl;
279 for (
size_t j = 0;
j <
size();
j++)
290 std::ostringstream msg;
291 msg <<
"index out of range";
292 throw std::runtime_error(msg.str());
304 std::ostringstream msg;
305 msg <<
"index out of range";
306 throw std::runtime_error(msg.str());
332 for (std::vector<FeatureVector>::const_iterator
i =
itemsBegin() ;
337 for (
unsigned j = 0 ;
j < _ts.
size() ;
j++)
373 #ifndef _NO_EXCEPTION 393 if (!sscanf(line.c_str(),
"%ld", &
size))
410 std::vector<floatFeature> v;
412 for (
int j = 0;
j < dim;
j++)
422 #ifndef _NO_EXCEPTION 425 catch (std::exception& e)
427 std::ostringstream msg;
428 msg << e.what() << std::endl <<
"Error reading the code book";
429 throw std::runtime_error(msg.str());
494 if (_varStats.size() !=
theItems[0].size())
496 std::ostringstream msg;
497 msg <<
"Normalization information does not coincide with codebook structure";
498 throw std::runtime_error(msg.str());
500 for (
unsigned it = 0; it <
size(); it++)
519 if (_varStats.size() !=
theItems[0].size())
521 std::ostringstream msg;
522 msg <<
"Normalization information does not coincide with codebook structure";
523 throw std::runtime_error(msg.str());
525 for (
unsigned it = 0; it <
size(); it++)
531 if (_varStats[i].sd != 0)
virtual unsigned output(const FeatureVector &_in) const
std::vector< FeatureVector >::const_iterator itemsBegin() const
virtual void Normalize(const std::vector< ClassicTrainingVectors::statsStruct > &_varStats)
double euclideanDistance(const std::vector< T > &_v1, const std::vector< T > &_v2)
virtual void classify(const ClassicTrainingVectors *_ts)
void writeClassifVectors(std::ostream &_os) const
virtual unsigned testIndex(const FeatureVector &_in) const
virtual void unNormalize(const std::vector< ClassicTrainingVectors::statsStruct > &_varStats)
CodeBook(const bool &_calib=false)
virtual FeatureVector & test(const FeatureVector &_in) const
virtual void printSelf(std::ostream &_os) const
virtual const std::vector< unsigned > & classifAt(const unsigned &_index) const
std::vector< FeatureVector > theItems
std::vector< double > aveDistances
virtual void printHistogram(std::ostream &_os) const
virtual void saveObject(std::ostream &_os) const
basic_istream< char, std::char_traits< char > > istream
std::vector< Label > theTargets
std::vector< FeatureVector >::const_iterator itemsEnd() const
virtual unsigned classifSizeAt(const unsigned &_index) const
virtual void printQuantError(std::ostream &_os) const
std::vector< std::vector< unsigned > > classifVectors
void readClassifVectors(std::istream &_is)
unsigned int randomize_random_generator()
virtual void printSelf(std::ostream &_os) const
virtual void loadObject(std::istream &_is)
std::vector< floatFeature > FeatureVector
virtual void loadObject(std::istream &_is)
virtual void calibrate(ClassicTrainingVectors &_ts, Label _def="")
std::vector< T > randomVector(const unsigned &_size, const T &_lower, const T &_upper)
virtual Label apply(const FeatureVector &_in) const
virtual void readSelf(std::istream &_is, long _dim=-1, long _size=-1)
virtual void saveObject(std::ostream &_os) const