shark::WeightedLabeledData< InputT, LabelT > Class Template Reference

Weighted data set for supervised learning. More...

#include <shark/Data/WeightedDataset.h>

+ Inheritance diagram for shark::WeightedLabeledData< InputT, LabelT >:

Public Types

typedef base_type::DataType DataType
 
typedef base_type::WeightType WeightType
 
typedef InputT InputType
 
typedef LabelT LabelType
 

Public Member Functions

 BOOST_STATIC_CONSTANT (std::size_t, DefaultBatchSize=(LabeledData< InputT, LabelT >::DefaultBatchSize))
 
 WeightedLabeledData ()
 Empty data set. More...
 
 WeightedLabeledData (std::size_t numBatches)
 Create an empty set with just the correct number of batches. More...
 
 WeightedLabeledData (std::size_t size, element_type const &element, std::size_t batchSize=DefaultBatchSize)
 Construtor using a single element as blueprint to create a dataset with a specified number of elements. More...
 
 WeightedLabeledData (LabeledData< InputType, LabelType > const &data, Data< WeightType > const &weights)
 Construction from data. More...
 
 WeightedLabeledData (LabeledData< InputType, LabelType > const &data, double weight)
 Construction from data and a constant weight for all elements. More...
 
UnlabeledData< InputType > const & inputs () const
 Access to the inputs as a separate container. More...
 
UnlabeledData< InputType > & inputs ()
 Access to the inputs as a separate container. More...
 
Data< LabelType > const & labels () const
 Access to the labels as a separate container. More...
 
Data< LabelType > & labels ()
 Access to the labels as a separate container. More...
 
WeightedUnlabeledData< InputTypeweightedInputs () const
 Constructs an WeightedUnlabeledData object for the inputs. More...
 
self_type splice (std::size_t batch)
 Splits the container into two independent parts. The left part remains in the container, the right is stored as return type. More...
 

Friends

void swap (self_type &a, self_type &b)
 

Detailed Description

template<class InputT, class LabelT>
class shark::WeightedLabeledData< InputT, LabelT >

Weighted data set for supervised learning.

The WeightedLabeledData class extends LabeledData for the representation of data. In addition it holds and provides access to the corresponding weights.

WeightedLabeledData tries to mimic the underlying data as pairs of data tuples(input,label) and weights. this means that when accessing a batch by calling batch(i) or choosing one of the iterators one access the databatch by batch(i).data and the weights by batch(i).weight. to access the points and labels use batch(i).data.input and batch(i).data.label

this also holds true for single element access using operator(). Be aware, that direct access to element is a linear time operation. So it is not advisable to iterate over the elements, but instead iterate over the batches.

It is possible to gains everal views on the set. one can either get access to inputs, labels and weights separately or gain access to the unweighted dataset of inputs and labels. Additionally the sets support on-the-fly creation of the (inputs,weights) subset for unsupervised weighted learning

Definition at line 456 of file WeightedDataset.h.

Member Typedef Documentation

§ DataType

template<class InputT, class LabelT>
typedef base_type::DataType shark::WeightedLabeledData< InputT, LabelT >::DataType

Definition at line 462 of file WeightedDataset.h.

§ InputType

template<class InputT, class LabelT>
typedef InputT shark::WeightedLabeledData< InputT, LabelT >::InputType

Definition at line 464 of file WeightedDataset.h.

§ LabelType

template<class InputT, class LabelT>
typedef LabelT shark::WeightedLabeledData< InputT, LabelT >::LabelType

Definition at line 465 of file WeightedDataset.h.

§ WeightType

template<class InputT, class LabelT>
typedef base_type::WeightType shark::WeightedLabeledData< InputT, LabelT >::WeightType

Definition at line 463 of file WeightedDataset.h.

Constructor & Destructor Documentation

§ WeightedLabeledData() [1/5]

template<class InputT, class LabelT>
shark::WeightedLabeledData< InputT, LabelT >::WeightedLabeledData ( )
inline

Empty data set.

Definition at line 476 of file WeightedDataset.h.

§ WeightedLabeledData() [2/5]

template<class InputT, class LabelT>
shark::WeightedLabeledData< InputT, LabelT >::WeightedLabeledData ( std::size_t  numBatches)
inline

Create an empty set with just the correct number of batches.

The user must initialize the dataset after that by himself.

Definition at line 482 of file WeightedDataset.h.

§ WeightedLabeledData() [3/5]

template<class InputT, class LabelT>
shark::WeightedLabeledData< InputT, LabelT >::WeightedLabeledData ( std::size_t  size,
element_type const &  element,
std::size_t  batchSize = DefaultBatchSize 
)
inline

Construtor using a single element as blueprint to create a dataset with a specified number of elements.

Optionally the desired batch Size can be set

Parameters
sizethe new size of the container
elementthe blueprint element from which to create the Container
batchSizethe size of the batches. if this is 0, the size is unlimited

Definition at line 493 of file WeightedDataset.h.

§ WeightedLabeledData() [4/5]

template<class InputT, class LabelT>
shark::WeightedLabeledData< InputT, LabelT >::WeightedLabeledData ( LabeledData< InputType, LabelType > const &  data,
Data< WeightType > const &  weights 
)
inline

Construction from data.

Beware that when calling this constructor the organization of batches must be equal in both containers. This Constructor will not reorganize the data!

Definition at line 500 of file WeightedDataset.h.

§ WeightedLabeledData() [5/5]

template<class InputT, class LabelT>
shark::WeightedLabeledData< InputT, LabelT >::WeightedLabeledData ( LabeledData< InputType, LabelType > const &  data,
double  weight 
)
inline

Construction from data and a constant weight for all elements.

Definition at line 505 of file WeightedDataset.h.

Member Function Documentation

§ BOOST_STATIC_CONSTANT()

template<class InputT, class LabelT>
shark::WeightedLabeledData< InputT, LabelT >::BOOST_STATIC_CONSTANT ( std::size_t  ,
DefaultBatchSize  = (LabeledData< InputT, LabelT >::DefaultBatchSize) 
)

§ inputs() [1/2]

template<class InputT, class LabelT>
UnlabeledData<InputType> const& shark::WeightedLabeledData< InputT, LabelT >::inputs ( ) const
inline

Access to the inputs as a separate container.

Definition at line 510 of file WeightedDataset.h.

References shark::UnlabeledData< InputT >::inputs().

Referenced by shark::inputDimension(), and shark::CSvmTrainer< InputType, CacheType >::train().

§ inputs() [2/2]

template<class InputT, class LabelT>
UnlabeledData<InputType>& shark::WeightedLabeledData< InputT, LabelT >::inputs ( )
inline

Access to the inputs as a separate container.

Definition at line 514 of file WeightedDataset.h.

References shark::UnlabeledData< InputT >::inputs().

§ labels() [1/2]

template<class InputT, class LabelT>
Data<LabelType> const& shark::WeightedLabeledData< InputT, LabelT >::labels ( ) const
inline

Access to the labels as a separate container.

Definition at line 519 of file WeightedDataset.h.

Referenced by shark::classSizes(), shark::labelDimension(), shark::numberOfClasses(), and shark::CSvmTrainer< InputType, CacheType >::train().

§ labels() [2/2]

template<class InputT, class LabelT>
Data<LabelType>& shark::WeightedLabeledData< InputT, LabelT >::labels ( )
inline

Access to the labels as a separate container.

Definition at line 523 of file WeightedDataset.h.

§ splice()

template<class InputT, class LabelT>
self_type shark::WeightedLabeledData< InputT, LabelT >::splice ( std::size_t  batch)
inline

Splits the container into two independent parts. The left part remains in the container, the right is stored as return type.

Order of elements remain unchanged. The SharedVector is not allowed to be shared for this to work.

Definition at line 536 of file WeightedDataset.h.

§ weightedInputs()

template<class InputT, class LabelT>
WeightedUnlabeledData<InputType> shark::WeightedLabeledData< InputT, LabelT >::weightedInputs ( ) const
inline

Constructs an WeightedUnlabeledData object for the inputs.

Definition at line 528 of file WeightedDataset.h.

Friends And Related Function Documentation

§ swap

template<class InputT, class LabelT>
void swap ( self_type a,
self_type b 
)
friend

Definition at line 540 of file WeightedDataset.h.


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