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...
 
Shape const & inputShape () const
 Returns the Shape of the inputs. More...
 
ShapeinputShape ()
 Returns the Shape of the inputs. More...
 
Shape const & labelShape () const
 Returns the Shape of the labels. More...
 
ShapelabelShape ()
 Returns the Shape of the labels. More...
 
WeightedUnlabeledData< InputTypeweightedInputs () const
 Constructs an WeightedUnlabeledData object for the inputs. More...
 
WeightedLabeledData 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 (WeightedLabeledData &a, WeightedLabeledData &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 578 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 583 of file WeightedDataset.h.

◆ InputType

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

Definition at line 585 of file WeightedDataset.h.

◆ LabelType

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

Definition at line 586 of file WeightedDataset.h.

◆ WeightType

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

Definition at line 584 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 597 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 603 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 614 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 621 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 626 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

◆ 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 635 of file WeightedDataset.h.

References shark::WeightedDataPair< DataType, WeightType >::data.

◆ inputShape() [1/2]

template<class InputT, class LabelT>
Shape const& shark::WeightedLabeledData< InputT, LabelT >::inputShape ( ) const
inline

Returns the Shape of the inputs.

Definition at line 649 of file WeightedDataset.h.

Referenced by shark::bootstrap().

◆ inputShape() [2/2]

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

Returns the Shape of the inputs.

Definition at line 654 of file WeightedDataset.h.

◆ labels() [1/2]

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

◆ 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 644 of file WeightedDataset.h.

References shark::WeightedDataPair< DataType, WeightType >::data.

◆ labelShape() [1/2]

template<class InputT, class LabelT>
Shape const& shark::WeightedLabeledData< InputT, LabelT >::labelShape ( ) const
inline

Returns the Shape of the labels.

Definition at line 659 of file WeightedDataset.h.

Referenced by shark::bootstrap().

◆ labelShape() [2/2]

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

Returns the Shape of the labels.

Definition at line 664 of file WeightedDataset.h.

◆ splice()

template<class InputT, class LabelT>
WeightedLabeledData 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 677 of file WeightedDataset.h.

References shark::WeightedDataPair< DataType, WeightType >::data.

◆ 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 669 of file WeightedDataset.h.

References shark::WeightedDataPair< DataType, WeightType >::data.

Friends And Related Function Documentation

◆ swap

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

Definition at line 681 of file WeightedDataset.h.


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