Xmipp
v3.23.11-Nereus
|
#include <training_set.h>
Public Types | |
enum | splitMode { CROSSVAL, SPLITSAMPLE, JACKKNIFE, BOOTSTRAP } |
Ways the training set can be used. More... | |
enum | useMode { TRAIN = 0, VALIDATION = 1, TEST = 2 } |
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 | |
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 Item &_i, const Target &_tg) |
virtual void | add (const Item &_i) |
virtual bool | remove (unsigned int _idx) |
size_t | size () const |
const Target & | targetAt (unsigned _i) const |
Target & | targetAt (unsigned _i) |
const Item & | itemAt (unsigned _i) const |
Item & | itemAt (unsigned _i) |
bool | calibrated () const |
void | calibrated (const bool &_calib) |
void | clear () |
virtual void | printSelf (std::ostream &_os) const |
virtual void | readSelf (std::istream &_is) |
virtual void | saveObject (std::ostream &_os) const |
virtual void | loadObject (std::istream &_is) |
unsigned | numTargets () const |
virtual bool | swapItems (unsigned _i, unsigned _j) |
Public Attributes | |
std::vector< Item > | theItems |
std::vector< Target > | theTargets |
Protected Member Functions | |
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< Item >::const_iterator | itemsBegin () const |
std::vector< Item >::const_iterator | itemsEnd () const |
std::vector< Target >::const_iterator | targetsBegin () const |
std::vector< Target >::const_iterator | targetsEnd () const |
Protected Attributes | |
bool | isCalibrated |
splitTS | splitTrainingSet |
unsigned | nTargets |
Friends | |
std::ostream & | operator<< (std::ostream &_os, const ClassificationTrainingSet &_ts) |
std::istream & | operator>> (std::istream &_is, ClassificationTrainingSet &_ts) |
Generic training sets. This is the parent class for all possible training sets that can be used by the classification algorithms. It provides the library with the basic functionality of training vectors. This a template class that takes as input the type of the training vectors and the type of the target variable (for supervised analysis) \The following example shows the declaration of a training set formed by a vector of doubles and a target variable of type string. \ \ClassificationTrainingSet<double, string> myTS;
Definition at line 61 of file training_set.h.
typedef splitTS::iterator ClassificationTrainingSet< Item, Target >::splitIt |
iterator
Definition at line 69 of file training_set.h.
typedef std::multimap<unsigned, unsigned, std::less<unsigned> > ClassificationTrainingSet< Item, Target >::splitTS |
Training sets mode.
Definition at line 66 of file training_set.h.
enum ClassificationTrainingSet::splitMode |
Ways the training set can be used.
Enumerator | |
---|---|
CROSSVAL | |
SPLITSAMPLE | |
JACKKNIFE | |
BOOTSTRAP |
Definition at line 72 of file training_set.h.
enum ClassificationTrainingSet::useMode |
use of samples
Enumerator | |
---|---|
TRAIN | |
VALIDATION | |
TEST |
Definition at line 75 of file training_set.h.
|
inline |
Default constructor Parameter: _calib: True if the trainign set is calibrated (labeled) Parameter: _n: Number of items that the trained set should contain
Definition at line 92 of file training_set.h.
|
inline |
Constructs a training set given a stream Parameter: _is The input stream
Definition at line 101 of file training_set.h.
|
inlinevirtual |
|
inlinevirtual |
Adds an item to the training set Parameter: _i The item Parameter: _tg The target (Used only if the TS is calibrated).
Reimplemented in FuzzyMap, and ClassificationMap.
Definition at line 171 of file training_set.h.
|
inlinevirtual |
Adds an item to a non calibrated training set Parameter: _i The item
Definition at line 183 of file training_set.h.
|
inline |
Returns an iterator to the beginning of the subset Parameter: _um is the mode: training, testing or validation
Definition at line 154 of file training_set.h.
|
inline |
Returns true if the training set is calibreted or not
Definition at line 301 of file training_set.h.
|
inline |
|
inlineprotected |
Checks if the training set is calibrated or not Parameter: _is The input stream
runtime_error | If there are problems with the stream |
Definition at line 442 of file training_set.h.
|
inline |
Clears the training set: all items and targets are suppresed; all other variables remain the same
Definition at line 318 of file training_set.h.
|
inlineprotected |
Compute the number of different targets in the training set
Definition at line 420 of file training_set.h.
|
inline |
|
inline |
Returns a const reference to the specified item Parameter: _i The index
out_of_range | If _i is out of range |
Definition at line 264 of file training_set.h.
|
inline |
Returns a recerence to an item. Parameter: _i The index Parameter: _item The item
out_of_range | If _i is out of range |
Definition at line 284 of file training_set.h.
|
inlineprotected |
Protected interface to the items
Definition at line 624 of file training_set.h.
|
inlineprotected |
Protected interface to the items
Definition at line 633 of file training_set.h.
|
inlinevirtual |
Loads the class from a stream. this method can be used to load the status of the class. Parameter: _is The output stream
Reimplemented in FuzzyMap, ClassificationMap, FuzzyCodeBook, CodeBook, and ClassicTrainingVectors.
Definition at line 360 of file training_set.h.
|
inline |
Returns the number of different classes in the (calibrated) training set
runtime_error | If the training set is not calibrated |
Definition at line 373 of file training_set.h.
|
inlinevirtual |
Standard output for a training set Parameter: _os The output stream
Reimplemented in FuzzyMap, ClassificationMap, CodeBook, and ClassicTrainingVectors.
Definition at line 330 of file training_set.h.
|
inlineprotected |
Read the items Parameter: _is The input stream
runtime_error | If there are problems with the stream |
Definition at line 481 of file training_set.h.
|
inlinevirtual |
Standard input for a training set Parameter: _is The input stream
runtime_error | If there are problems with the stream NOTE: This method is empty, it should be defined. |
Reimplemented in ClassificationMap, and ClassicTrainingVectors.
Definition at line 341 of file training_set.h.
|
inlinevirtual |
Deletes an item from the training set Parameter: _idx The index
Definition at line 193 of file training_set.h.
|
inlinevirtual |
Saves the class into a stream. this method can be used to save the status of the class. Parameter: _os The output stream
Reimplemented in FuzzyMap, ClassificationMap, FuzzyCodeBook, CodeBook, and ClassicTrainingVectors.
Definition at line 349 of file training_set.h.
|
inline |
Sets the proportion of training, validation and testing and creates the map. Used for split-sample training and validation. Parameters must be between 0 and 1 and must add to less than 1; the rest will be used for testing Parameter: _tp proportion over 1 of samples devoted to training Parameter: _vp proportion over 1 of samples devoted to validation
Definition at line 120 of file training_set.h.
|
inline |
|
inlineprotected |
Skip the comments if the stream Parameter: _is The input stream
Definition at line 598 of file training_set.h.
|
inlinevirtual |
|
inline |
Returns a const reference to the specified target Parameter: _i The index
out_of_range | If _i is out of range |
Definition at line 221 of file training_set.h.
|
inline |
Returns a reference to a target. Parameter: _i The index
out_of_range | If _i is out of range |
Definition at line 245 of file training_set.h.
|
inlineprotected |
Protected interface to the targets
Definition at line 643 of file training_set.h.
|
inlineprotected |
Protected interface to the targets
Definition at line 651 of file training_set.h.
|
inlineprotected |
Writes if the training set is calibrated or not Parameter: _os The output stream
Definition at line 549 of file training_set.h.
|
inlineprotected |
Writes the items Parameter: _os The output stream Parameter: _delim Flag to use "<" delimiters (false by default)
Definition at line 561 of file training_set.h.
|
friend |
Standard output for a training set Parameter: _os The output stream Parameter: _ts The training set to be printed
Definition at line 397 of file training_set.h.
|
friend |
Standard input for a training set Parameter: _is The input stream Parameter: _ts The training set to be read
runtime_error | If there are problems with the stream |
Definition at line 409 of file training_set.h.
|
protected |
Definition at line 78 of file training_set.h.
|
protected |
Definition at line 82 of file training_set.h.
|
protected |
Definition at line 79 of file training_set.h.
std::vector<Item> ClassificationTrainingSet< Item, Target >::theItems |
Definition at line 84 of file training_set.h.
std::vector<Target> ClassificationTrainingSet< Item, Target >::theTargets |
Definition at line 85 of file training_set.h.