shark::LabelOrder Class Reference

This will normalize the labels of a given dataset to 0..N-1. More...

#include <shark/Data/LabelOrder.h>

+ Inheritance diagram for shark::LabelOrder:

Public Member Functions

 LabelOrder ()
 
virtual ~LabelOrder ()
 
std::string name () const
 From INameable: return the class name. More...
 
void normalizeLabels (LabeledData< RealVector, unsigned int > &dataset)
 This will normalize the labels and store the ordering in the member variables. The dataset will afterwards have labels ranging from 0 to N-1, with N the number of classes. This will overwrite any previously stored label ordering in the object. More...
 
void restoreOriginalLabels (LabeledData< RealVector, unsigned int > &dataset)
 This will restore the original labels of the dataset. This must be called with data compatible the original dataset, so that the labels will fit. The label ordering will not be destroyed after calling this function, so it can be called multiple times, e.g. to testsets or similar data. More...
 
void getLabelOrder (std::vector< int > &labelOrder)
 Get label ordering directly. More...
 
void getLabelOrder (std::vector< unsigned int > &labelOrder)
 Get label ordering directly. More...
 
void setLabelOrder (std::vector< int > &labelOrder)
 Set label ordering directly. More...
 
void setLabelOrder (std::vector< unsigned int > &labelOrder)
 Set label ordering directly. More...
 
- Public Member Functions inherited from shark::INameable
virtual ~INameable ()
 

Protected Attributes

std::vector< int > m_labelOrder
 

Detailed Description

This will normalize the labels of a given dataset to 0..N-1.

This will normalize the labels of a given dataset to 0..N-1
and store the ordering in a member variable. After processing, the dataset will afterwards have labels ranging from 0 to N-1, with N the number of classes, so usual Shark trainers can work with it. One can then revert the original labeling just by calling restoreOriginalLabels

Definition at line 59 of file LabelOrder.h.

Constructor & Destructor Documentation

§ LabelOrder()

shark::LabelOrder::LabelOrder ( )
inline

Definition at line 66 of file LabelOrder.h.

§ ~LabelOrder()

virtual shark::LabelOrder::~LabelOrder ( )
inlinevirtual

Definition at line 69 of file LabelOrder.h.

Member Function Documentation

§ getLabelOrder() [1/2]

void shark::LabelOrder::getLabelOrder ( std::vector< int > &  labelOrder)
inline

Get label ordering directly.

Parameters
[out]labelOrdervector to store the current label order.

Definition at line 163 of file LabelOrder.h.

References m_labelOrder.

§ getLabelOrder() [2/2]

void shark::LabelOrder::getLabelOrder ( std::vector< unsigned int > &  labelOrder)
inline

Get label ordering directly.

Parameters
[out]labelOrdervector to store the current label order.

Definition at line 174 of file LabelOrder.h.

References m_labelOrder.

§ name()

std::string shark::LabelOrder::name ( ) const
inlinevirtual

From INameable: return the class name.

Reimplemented from shark::INameable.

Definition at line 73 of file LabelOrder.h.

§ normalizeLabels()

void shark::LabelOrder::normalizeLabels ( LabeledData< RealVector, unsigned int > &  dataset)
inline

This will normalize the labels and store the ordering in the member variables. The dataset will afterwards have labels ranging from 0 to N-1, with N the number of classes. This will overwrite any previously stored label ordering in the object.

Parameters
[in,out]datasetdataset that will be relabeled

Definition at line 84 of file LabelOrder.h.

References shark::LabeledData< InputT, LabelT >::labels(), m_labelOrder, shark::blas::max(), shark::LabeledData< InputT, LabelT >::numberOfElements(), and SHARKEXCEPTION.

§ restoreOriginalLabels()

void shark::LabelOrder::restoreOriginalLabels ( LabeledData< RealVector, unsigned int > &  dataset)
inline

This will restore the original labels of the dataset. This must be called with data compatible the original dataset, so that the labels will fit. The label ordering will not be destroyed after calling this function, so it can be called multiple times, e.g. to testsets or similar data.

Parameters
[in,out]datasetdataset to relabel (restore labels)

Definition at line 140 of file LabelOrder.h.

References shark::LabeledData< InputT, LabelT >::labels(), m_labelOrder, shark::LabeledData< InputT, LabelT >::numberOfElements(), and SHARKEXCEPTION.

§ setLabelOrder() [1/2]

void shark::LabelOrder::setLabelOrder ( std::vector< int > &  labelOrder)
inline

Set label ordering directly.

Parameters
[in]labelOrdervector with the new label order

Definition at line 184 of file LabelOrder.h.

References m_labelOrder.

§ setLabelOrder() [2/2]

void shark::LabelOrder::setLabelOrder ( std::vector< unsigned int > &  labelOrder)
inline

Set label ordering directly.

Parameters
[in]labelOrdervector with the new label order

Definition at line 193 of file LabelOrder.h.

References m_labelOrder.

Member Data Documentation

§ m_labelOrder

std::vector<int> shark::LabelOrder::m_labelOrder
protected

Definition at line 201 of file LabelOrder.h.

Referenced by getLabelOrder(), normalizeLabels(), restoreOriginalLabels(), and setLabelOrder().


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