Xmipp
v3.23.11-Nereus
|
#include <fuzzy_code_book.h>
Public Types | |
typedef std::vector< std::vector< floatFeature > > | MM |
typedef ClassicTrainingVectors | TS |
Alias for Membership Matrix. More... | |
typedef ClassificationTrainingSet< std::vector< floatFeature >, floatFeature > | FV |
Alias for a Training set. More... | |
Public Types inherited from ClassificationDataSet< FeatureVector, Label > | |
typedef FeatureVector | In |
Class of input vectors. Usually a FeatureVector (vector of Feature) More... | |
typedef Label | Out |
Class of the target. Can be a double, string, unsigned, even a vector ... More... | |
typedef ClassificationTrainingSet< In, Out > | TS |
Training set. Set of vectors (training vectors), probably classified. More... | |
Public Types inherited from ClassificationTrainingSet< FeatureVector, Label > | |
enum | splitMode |
Ways the training set can be used. More... | |
enum | useMode |
use of samples More... | |
typedef std::multimap< unsigned, unsigned, std::less< unsigned > > | splitTS |
Training sets mode. More... | |
typedef splitTS::iterator | splitIt |
iterator More... | |
Public Member Functions | |
FuzzyCodeBook (const bool &_calib=false) | |
FuzzyCodeBook (unsigned _n, unsigned _size, unsigned _data, bool _cal=false) | |
FuzzyCodeBook (unsigned _n, unsigned _size, unsigned _data, double _lower=0, double _upper=1, bool _cal=false) | |
FuzzyCodeBook (unsigned _n, const ClassicTrainingVectors &_ts, const bool _use_rand_cvs=false) | |
FuzzyCodeBook (std::istream &_is, const unsigned _size=0) | |
virtual | ~FuzzyCodeBook () |
floatFeature & | membAt (unsigned _di, unsigned _ci) |
unsigned | membClusters () const |
unsigned | membVectors () const |
virtual FeatureVector & | fuzzyTest (unsigned _in) const |
virtual unsigned | fuzzyTestIndex (unsigned _in) const |
virtual unsigned | fuzzyWinner (unsigned _in) const |
virtual unsigned | fuzzyOutput (unsigned _in) const |
virtual void | classify (const ClassicTrainingVectors *_ts) |
virtual TS | alphaCore (TS _ts, double _alpha, unsigned _cluster) const |
virtual void | writeMembership (std::ostream &_os) const |
virtual void | readMembership (std::istream &_is) |
virtual void | saveObject (std::ostream &_os) const |
virtual void | loadObject (std::istream &_is) |
virtual void | readSelf (std::istream &_is, const unsigned _size=0) |
Public Member Functions inherited from CodeBook | |
CodeBook (const bool &_calib=false) | |
CodeBook (unsigned _n, unsigned _size, bool _cal=false) | |
CodeBook (unsigned _n, unsigned _size, floatFeature _lower=0, floatFeature _upper=1, bool _cal=false) | |
CodeBook (unsigned _n, const ClassicTrainingVectors &_ts, const bool _use_rand_cvs) | |
CodeBook (std::istream &_is) | |
virtual | ~CodeBook () |
virtual FeatureVector & | test (const FeatureVector &_in) const |
virtual unsigned | testIndex (const FeatureVector &_in) const |
virtual const std::vector< unsigned > & | classifAt (const unsigned &_index) const |
virtual unsigned | classifSizeAt (const unsigned &_index) const |
virtual Label | apply (const FeatureVector &_in) const |
virtual void | calibrate (ClassicTrainingVectors &_ts, Label _def="") |
virtual unsigned | output (const FeatureVector &_in) const |
virtual void | printSelf (std::ostream &_os) const |
virtual void | readSelf (std::istream &_is, long _dim=-1, long _size=-1) |
virtual void | Normalize (const std::vector< ClassicTrainingVectors::statsStruct > &_varStats) |
virtual void | unNormalize (const std::vector< ClassicTrainingVectors::statsStruct > &_varStats) |
virtual void | printHistogram (std::ostream &_os) const |
virtual void | printQuantError (std::ostream &_os) const |
Public Member Functions inherited from ClassificationDataSet< FeatureVector, Label > | |
ClassificationDataSet () | |
virtual | ~ClassificationDataSet () |
Public Member Functions inherited from ClassificationTrainingSet< FeatureVector, Label > | |
ClassificationTrainingSet (const bool &_calib=true, unsigned _n=0) | |
ClassificationTrainingSet (std::istream &_is) | |
virtual | ~ClassificationTrainingSet () |
void | setSplit (float _tp, float _vp) |
splitIt | beginSubset (unsigned _um) |
splitIt | endSubset (unsigned _um) |
Returns an iterator to the end of the subset. More... | |
virtual void | add (const FeatureVector &_i, const Label &_tg) |
virtual void | add (const FeatureVector &_i) |
virtual bool | remove (unsigned int _idx) |
size_t | size () const |
const Label & | targetAt (unsigned _i) const |
Label & | targetAt (unsigned _i) |
const FeatureVector & | itemAt (unsigned _i) const |
FeatureVector & | itemAt (unsigned _i) |
bool | calibrated () const |
void | calibrated (const bool &_calib) |
void | clear () |
virtual void | readSelf (std::istream &_is) |
unsigned | numTargets () const |
virtual bool | swapItems (unsigned _i, unsigned _j) |
Public Attributes | |
MM | memb |
Alias for Fuzzy vectors. More... | |
Public Attributes inherited from CodeBook | |
std::vector< std::vector< unsigned > > | classifVectors |
std::vector< double > | aveDistances |
Public Attributes inherited from ClassificationTrainingSet< FeatureVector, Label > | |
std::vector< FeatureVector > | theItems |
std::vector< Label > | theTargets |
Additional Inherited Members | |
Protected Member Functions inherited from CodeBook | |
void | readClassifVectors (std::istream &_is) |
void | writeClassifVectors (std::ostream &_os) const |
Protected Member Functions inherited from ClassificationTrainingSet< FeatureVector, Label > | |
void | computeNumTargets () |
void | checkCalibrated (std::istream &_is) |
void | readItems (std::istream &_is) |
void | writeCalibrated (std::ostream &_os) const |
void | writeItems (std::ostream &_os, bool _delim=false) const |
void | skipComments (std::istream &_is) const |
std::vector< FeatureVector >::const_iterator | itemsBegin () const |
std::vector< FeatureVector >::const_iterator | itemsEnd () const |
std::vector< Label >::const_iterator | targetsBegin () const |
std::vector< Label >::const_iterator | targetsEnd () const |
Protected Attributes inherited from ClassificationTrainingSet< FeatureVector, Label > | |
bool | isCalibrated |
splitTS | splitTrainingSet |
unsigned | nTargets |
This class implements an specific Data Structure for Fuzzy algorithms. It inherits fron CodeBook, so this Data Structure is basically a codebook with a Fuzzy-membership Matrix. Some of the methods from CodeBook are redefined.
Definition at line 44 of file fuzzy_code_book.h.
typedef ClassificationTrainingSet<std::vector<floatFeature>, floatFeature > FuzzyCodeBook::FV |
Alias for a Training set.
Definition at line 53 of file fuzzy_code_book.h.
typedef std::vector< std::vector< floatFeature > > FuzzyCodeBook::MM |
Definition at line 48 of file fuzzy_code_book.h.
Alias for Membership Matrix.
Definition at line 51 of file fuzzy_code_book.h.
|
inline |
Default constructor Parameter: _calib Calibrated or not, that is, a CB with class labels or not
Definition at line 63 of file fuzzy_code_book.h.
FuzzyCodeBook::FuzzyCodeBook | ( | unsigned | _n, |
unsigned | _size, | ||
unsigned | _data, | ||
bool | _cal = false |
||
) |
Constructor. Constructs a fuzzy codebook with initial code vectors filled with zero. Parameter: _n Number of code vectors Parameter: _size Size of code vectors Parameter: _data Size of the training set Parameter: _cal Calibrated or not, that is, a CB with class labels or not It calls Base Class constructor (CodeBook)
Constructor. Constructs a codebook with initial code vectors filled with zero. Parameter: _n Number of vectors (clusters) Parameter: _size Size of code vectors Parameter: _cal Calibrated or not, that is, a CB with class labels or not It calls Base Class constructor (CodeBook)
Definition at line 41 of file fuzzy_code_book.cpp.
FuzzyCodeBook::FuzzyCodeBook | ( | unsigned | _n, |
unsigned | _size, | ||
unsigned | _data, | ||
double | _lower = 0 , |
||
double | _upper = 1 , |
||
bool | _cal = false |
||
) |
Constructor. Constructs a fuzzy codebook with random initial code vectors. Parameter: _n Number of code vectors Parameter: _size Size of code vectors Parameter: _data Size of the training set Parameter: _lower Lower value for random elements Parameter: _upper Upper value for random elements Parameter: _cal Calibrated or not, that is, a CB with class labels or not It calls Base Class constructor (CodeBook)
Constructor. Constructs a codebook with random initial code vectors. Parameter: _n Number of vectors Parameter: _size Size of code vectors Parameter: _lower Lower value for random elements Parameter: _upper Upper value for random elements Parameter: _cal Calibrated or not, that is, a CB with class labels or not It calls Base Class constructor (CodeBook)
Definition at line 72 of file fuzzy_code_book.cpp.
FuzzyCodeBook::FuzzyCodeBook | ( | unsigned | _n, |
const ClassicTrainingVectors & | _ts, | ||
const bool | _use_rand_cvs = false |
||
) |
Constructor. Constructs a fuzzy codebook with initial code vectors taken randomly from the training file. Parameter: _n Number of vectors Parameter: _ts Training set; will be used to get initial values Parameter: _use_rand_cvs Use random code vectors (inherited from base class) It calls Base Class constructor (CodeBook)
Constructor. Constructs a codebook with initial code vectors taken randomly from the training file. Parameter: _n Number of vectors Parameter: _ts Training set; will be used to get initial values Parameter: _use_rand_cvs Use random code vectors (inherited from base class) It calls Base Class constructor (CodeBook)
Definition at line 105 of file fuzzy_code_book.cpp.
FuzzyCodeBook::FuzzyCodeBook | ( | std::istream & | _is, |
const unsigned | _size = 0 |
||
) |
Constructs a fuzzy code book given a stream Parameter: _is The input stream Parameter: _size Size of code vectors (number of data points)
runtime_error | If there are problems with the stream |
Definition at line 127 of file fuzzy_code_book.cpp.
|
inlinevirtual |
|
virtual |
Returns the alpha-core set (also called alpha-level set or simply "core") Parameter: _ts The training set Parameter: _alpha A threshold to identify the core. Parameter: _cluster The cluster or partition Returns a training vector "contained" in the cluster
Returns the alpha-core set (also called alpha-level set or simply "core") Parameter: _ts The training set Parameter: _alpha A threshold to identify the core. Parameter: _cluster The cluster or partition
Definition at line 369 of file fuzzy_code_book.cpp.
|
virtual |
Fills the classifVectors with the list of the best input vectors associated to it. In this case, it uses the Fuzzy Memberships to make the assignments Parameter: _ts Sample list to classify
Reimplemented from CodeBook.
Definition at line 310 of file fuzzy_code_book.cpp.
|
virtual |
Returns the index of the codevector closest to an input. This is the method used to classify inputs Parameter: _in Index to the Sample to be classified
Definition at line 299 of file fuzzy_code_book.cpp.
|
virtual |
Returns the code vector that represents the input in the codebook Parameter: _in Sample to classify Note: The difference between Fuzzy codevector and non-Fuzzy codevector is that the best (winner) is estimated using the fuzzy membership matrix.
Definition at line 209 of file fuzzy_code_book.cpp.
|
virtual |
Returns the index to the code vector that represents the input in the codebook Parameter: _in Sample to classify Note: The difference between Fuzzy codevector and non-Fuzzy codevector is that the best (winner) is estimated using the fuzzy membership matrix.
Definition at line 233 of file fuzzy_code_book.cpp.
|
virtual |
Returns the index of the codevector closest to an input. This is the method used to classify inputs Parameter: _in Index to the Sample to be classified
Definition at line 289 of file fuzzy_code_book.cpp.
|
virtual |
Loads the xmippFuzzyCodeBook class from a stream. this method can be used to load the status of the class. Parameter: _is The output stream
Loads the FuzzyCodeBook class from a stream. this method can be used to load the status of the class. Parameter: _is The output stream
Reimplemented from CodeBook.
Reimplemented in FuzzyMap.
Definition at line 483 of file fuzzy_code_book.cpp.
floatFeature & FuzzyCodeBook::membAt | ( | unsigned | _di, |
unsigned | _ci | ||
) |
Fuctions to access the Fuzzy Membership Matrix Returns a reference to the specified item Parameter: _ci cluster index Parameter: _di data index
out_of_range | If _i is out of range |
Definition at line 174 of file fuzzy_code_book.cpp.
unsigned FuzzyCodeBook::membClusters | ( | ) | const |
Returns dimensions of the Membership matrix
Definition at line 191 of file fuzzy_code_book.cpp.
unsigned FuzzyCodeBook::membVectors | ( | ) | const |
Definition at line 195 of file fuzzy_code_book.cpp.
|
virtual |
Reads the membership values Parameter: _is The input stream
Definition at line 432 of file fuzzy_code_book.cpp.
|
virtual |
Constructs a fuzzy code book given a stream Parameter: _is The input stream Parameter: _size Size of code vectors (number of data points)
runtime_error | If there are problems with the stream |
Reimplemented in FuzzyMap.
Definition at line 460 of file fuzzy_code_book.cpp.
|
virtual |
Saves the xmippFuzzyCodeBook class into a stream. this method can be used to save the status of the class. Parameter: _os The output stream
Saves the FuzzyCodeBook class into a stream. this method can be used to save the status of the class. Parameter: _os The output stream
Reimplemented from CodeBook.
Reimplemented in FuzzyMap.
Definition at line 447 of file fuzzy_code_book.cpp.
|
virtual |
Writes the membership values Parameter: _os The output stream
Definition at line 420 of file fuzzy_code_book.cpp.
MM FuzzyCodeBook::memb |
Alias for Fuzzy vectors.
Definition at line 57 of file fuzzy_code_book.h.