58 if (verbosity == 1 || verbosity == 3)
68 unsigned numClusters = _xmippDS.
size();
69 unsigned numVectors = _examples.size();
103 for (k = 0; k < numVectors; k++)
107 for (j = 0; j < numClusters; j++)
112 for (j = 0; j < numClusters; j ++)
114 _xmippDS.
memb[
k][
j] = 1.0;
116 _xmippDS.
memb[
k][
j] = 0.0;
120 for (i = 0; i < numClusters; i ++)
123 for (j = 0; j < numClusters; j ++)
127 auxDist += pow(tmp, auxExp);
137 for (i = 0; i < numClusters; i++)
141 for (k = 0; k < numVectors; k++)
144 auxSum += pow((
double)(_xmippDS.
memb[k][i]),
m);
151 for (i = 0; i < numClusters; i ++)
154 stopError += auxError * auxError;
163 if (verbosity == 1 || verbosity == 3)
168 sprintf(s,
"Iteration %d of %d. Code vectors variation: %g\n", t + 1,
epochs, stopError);
174 if (verbosity == 1 || verbosity == 3)
185 const TS& _examples)
const 197 double distortion = 0;
198 for (
unsigned i = 0;
i < _examples.size();
i ++)
201 unsigned best = _xmippDS.
output(auxS);
210 return distortion / (double) _examples.size();
219 const TS& _examples)
const 231 double distortion = 0;
232 for (
unsigned i = 0;
i < _examples.size();
i ++)
242 return distortion / (double)_examples.size();
267 F += pow((
double)(_xmippDS.
memb[
k][
i]), 2);
294 if (_xmippDS.
memb[
k][
i] != 0.)
295 H += (double)(_xmippDS.
memb[
k][
i]) *
log((
double)(_xmippDS.
memb[
k][i]));
299 #ifdef UNUSED // detected as unused 29.6.2018 317 F += pow((
double)(_xmippDS.
memb[
k][
i]), 2);
338 const TS& _examples)
const 341 std::vector< std::vector< floatFeature > > ICD;
342 std::vector< std::vector< floatFeature > > D;
348 std::vector <floatFeature>
d;
358 std::vector <floatFeature> v;
373 if (auxMin > ICD[i][
j])
376 double S = auxSum / (double)(_xmippDS.
membVectors()) / (
double)(auxMin);
385 _os <<
"Class (Algorithm): " << std::endl;
389 _os <<
"Fuzzy constant m = " <<
m << std::endl;
390 _os <<
"Epsilon eps = " <<
epsilon << std::endl;
391 _os <<
"Iterations iter = " <<
epochs << std::endl << std::endl;
virtual unsigned output(const FeatureVector &_in) const
double euclideanDistance(const std::vector< T > &_v1, const std::vector< T > &_v2)
MM memb
Alias for Fuzzy vectors.
double S(const FuzzyCodeBook &_xmippDS, const TS &_examples) const
virtual void train(FuzzyCodeBook &_xmippDS, TS &_examples) const
virtual void OnReportOperation(const std::string &_rsOp)=0
virtual void OnInitOperation(unsigned long _est_it)=0
virtual const unsigned & getVerbosity() 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
void log(Image< double > &op)
virtual unsigned fuzzyOutput(unsigned _in) const
std::vector< Item > theItems
void printSelf(std::ostream &_os) const
print itself on standard output
virtual double test(const FuzzyCodeBook &_xmippDS, const TS &_examples) const
virtual void OnProgress(unsigned long _it)=0
double F(const FuzzyCodeBook &_xmippDS) const
unsigned membClusters() const
virtual void printSelf(std::ostream &_os) const
double H(const FuzzyCodeBook &_xmippDS) const
virtual double fuzzyTest(const FuzzyCodeBook &_xmippDS, const TS &_examples) const
std::vector< floatFeature > FeatureVector
ql0001_ & zero(ctemp+1),(cvec+1),(a+1),(b+1),(bl+1),(bu+1),(x+1),(w+1), &iout, ifail, &zero,(w+3), &lwar2,(iw+1), &leniw, &glob_grd.epsmac