42 bool _cal):
CodeBook(_n, _size, _cal)
49 memb.resize(numVectors);
50 for (
unsigned k = 0;
k < numVectors;
k++)
52 std::vector <floatFeature> v;
53 v.resize(numClusters, 0);
73 bool _cal):
CodeBook(_n, _size, _lower, _upper, _cal)
80 memb.resize(numVectors);
81 for (
unsigned k = 0;
k < numVectors;
k++)
83 std::vector <floatFeature> v;
84 v.resize(numClusters, 0);
106 const bool _use_rand_cvs) :
CodeBook(_n, _ts, _use_rand_cvs)
111 numVectors = _ts.
size();
112 memb.resize(numVectors);
113 std::vector <floatFeature> v;
114 v.resize(numClusters, 0);
115 for (
unsigned k = 0;
k < numVectors;
k++)
135 memb.resize(numVectors);
136 for (
unsigned k = 0;
k < numVectors;
k++)
138 std::vector <floatFeature> v;
139 v.resize(numClusters, 0);
148 #ifdef UNUSED // detected as unused 29.6.2018 157 std::ostringstream msg;
160 msg <<
"Out of range. No item at position " << _di <<
"," << _ci << std::endl;
161 throw std::out_of_range(msg.str());
164 return memb[_di][_ci];
176 std::ostringstream msg;
179 msg <<
"Out of range. No item at position " << _di <<
"," << _ci << std::endl;
180 throw std::out_of_range(msg.str());
183 return memb[_di][_ci];
216 if (maxMemb <
memb[_in][
c])
218 maxMemb = (double)
memb[_in][c];
240 if (maxMemb <
memb[_in][
c])
242 maxMemb = (double)
memb[_in][c];
250 #ifdef UNUSED // detected as unused 29.6.2018 255 Label FuzzyCodeBook::fuzzyApply(
unsigned _in)
const 269 for (std::vector<FeatureVector>::const_iterator
i =
itemsBegin();
275 for (
unsigned j = 0 ;
j < _ts.
size() ;
j++)
317 for (
unsigned j = 0 ;
j < _ts->
size() ;
j++)
320 for (
unsigned i = 0 ;
i <
size() ;
i++)
332 #ifdef UNUSED // detected as unused 29.6.2018 338 void FuzzyCodeBook::hardPartition()
350 memb[
k][maxIndex] = 0.0;
377 if ((_alpha < 0) || (_alpha > 1))
379 std::ostringstream msg;
380 msg <<
"threshold must be in [0,1]";
381 throw std::runtime_error(msg.str());
386 std::ostringstream msg;
387 msg <<
"Invalid cluster number";
388 throw std::runtime_error(msg.str());
393 double maxMemb =
memb[
k][_cluster];
394 unsigned maxIndex = _cluster;
405 if (maxIndex == _cluster && maxMemb >= _alpha)
423 for (
unsigned k = 0;
k < numVectors;
k++)
424 _os <<
memb[
k] << std::endl;
435 memb.resize(numVectors);
436 for (
unsigned k = 0;
k < numVectors;
k++)
438 numClusters =
memb[0].size();
467 memb.resize(numVectors);
468 for (
size_t k = 0;
k < numVectors;
k++)
470 std::vector <floatFeature> v;
471 v.resize(numClusters, 0);
490 #ifdef UNUSED // detected as unused 29.6.2018 495 void FuzzyCodeBook::printDensity(std::ostream& _os)
const 497 _os <<
"1" << std::endl;
498 for (
size_t j = 0;
j < numClusters;
j++)
501 for (
size_t i = 0;
i < numVectors;
i++)
502 sumDens += (
double)
memb[
i][
j];
503 _os <<
j <<
" " << sumDens << std::endl;
virtual void loadObject(std::istream &_is)
floatFeature & membAt(unsigned _di, unsigned _ci)
std::vector< FeatureVector >::const_iterator itemsBegin() const
double euclideanDistance(const std::vector< T > &_v1, const std::vector< T > &_v2)
virtual unsigned fuzzyTestIndex(unsigned _in) const
MM memb
Alias for Fuzzy vectors.
virtual void saveObject(std::ostream &_os) const
unsigned membVectors() const
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
virtual void classify(const ClassicTrainingVectors *_ts)
virtual unsigned fuzzyWinner(unsigned _in) const
virtual unsigned fuzzyOutput(unsigned _in) const
std::vector< FeatureVector > theItems
std::vector< double > aveDistances
virtual void readMembership(std::istream &_is)
virtual void readSelf(std::istream &_is, const unsigned _size=0)
virtual void writeMembership(std::ostream &_os) const
basic_istream< char, std::char_traits< char > > istream
std::vector< Label > theTargets
unsigned membClusters() const
std::vector< FeatureVector >::const_iterator itemsEnd() const
virtual FeatureVector & fuzzyTest(unsigned _in) const
FuzzyCodeBook(const bool &_calib=false)
std::vector< std::vector< unsigned > > classifVectors
std::vector< floatFeature > FeatureVector
virtual void loadObject(std::istream &_is)
virtual TS alphaCore(TS _ts, double _alpha, unsigned _cluster) const
virtual void readSelf(std::istream &_is, long _dim=-1, long _size=-1)
virtual void saveObject(std::ostream &_os) const