yat  0.14.5pre
Public Member Functions | Related Functions | List of all members
theplu::yat::classifier::Target Class Reference

Class for containing sample labels. More...

#include <yat/classifier/Target.h>

Public Member Functions

 Target (void)
 default constructor
 
 Target (const std::vector< std::string > &labels)
 Constructor creating target with labels.
 
 Target (const std::vector< std::string > &labels, const Target &)
 Constructor.
 
 throw (utility::IO_error, std::exception)
 istream constructor.
 
 Target (const Target &org, const utility::Index &vec)
 
 ~Target ()
 Destructor.
 
const std::map< std::string,
size_t > & 
classes (void) const
 
size_t nof_classes (void) const
 
bool binary (size_t i) const
 Default binary is set to false for all classes except class 0. More...
 
const std::vector< std::string > & labels (void)
 
void set_binary (size_t i, bool b)
 
void random_shuffle (void)
 randomize labels More...
 
size_t size (void) const
 
size_t size (const std::string &label) const
 
size_t size (size_t cl) const
 
size_t operator() (size_t sample) const
 
size_t operator[] (size_t sample) const
 
const Targetoperator= (const Target &)
 assignment operator
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &, const Target &)
 

Detailed Description

Class for containing sample labels.

Constructor & Destructor Documentation

theplu::yat::classifier::Target::Target ( const Target org,
const utility::Index vec 
)

Constructor creating a sub-Target from Target org. vec defines which indices to use.

Note
class is preserved, i.e., operator() returns the same for the Target as the original Target.

Member Function Documentation

bool theplu::yat::classifier::Target::binary ( size_t  i) const

Default binary is set to false for all classes except class 0.

Returns
binary target for sample i
See Also
set_binary
const std::map<std::string,size_t>& theplu::yat::classifier::Target::classes ( void  ) const
Returns
a map with label as key and class as value.
const std::vector<std::string>& theplu::yat::classifier::Target::labels ( void  )

The size of returned vector is equal to number of classes. To get label of sample i you need to call target.labels()[target(i)]

Returns
vector of labels for classes
size_t theplu::yat::classifier::Target::nof_classes ( void  ) const

This function is equivalent to Target::classes().size()

Returns
number of classes
Note
there might be empty classes, i.e., classes with zero samples. This may happen when using Target(const std::vector<std::string>& labels, const Target&) or Target(const Target& org, const std::vector<size_t>& vec).
size_t theplu::yat::classifier::Target::operator() ( size_t  sample) const
Returns
the class of sample
size_t theplu::yat::classifier::Target::operator[] ( size_t  sample) const
Returns
the class of sample
Deprecated:
Provided for backward compatibility with the 0.4 API. Use operator().
void theplu::yat::classifier::Target::random_shuffle ( void  )

randomize labels

Randomizes classes. Number of samples with a specific label is not modified, neither mapping from label to class.

void theplu::yat::classifier::Target::set_binary ( size_t  i,
bool  b 
)

Binary target for each sample with class i is set to b. Default is binary set to false for each class except class 0 which is set to true.

size_t theplu::yat::classifier::Target::size ( void  ) const
Returns
number of samples
size_t theplu::yat::classifier::Target::size ( const std::string &  label) const
Returns
number of samples with label label
size_t theplu::yat::classifier::Target::size ( size_t  cl) const
Returns
number of samples with class cl

Friends And Related Function Documentation

std::ostream & operator<< ( std::ostream &  ,
const Target  
)
related

The output operator for the Target class.


The documentation for this class was generated from the following file:

Generated on Tue Sep 26 2017 02:33:29 for yat by  doxygen 1.8.5