shark::DataView< DatasetType > Class Template Reference

Constant time Element-Lookup for Datasets. More...

#include <shark/Data/DataView.h>

Public Types

typedef dataset_type::const_element_reference const_reference
 
typedef boost::mpl::if_< std::is_const< DatasetType >, typename dataset_type::const_element_reference, typename dataset_type::element_reference >::type reference
 
typedef IteratorBase< reference, DataView< DatasetType > > iterator
 
typedef IteratorBase< const_reference, DataView< DatasetType > const > const_iterator
 

Public Member Functions

 DataView ()
 
 DataView (DatasetType &dataset)
 
template<class IndexRange >
 DataView (DataView< DatasetType > const &view, IndexRange const &indices)
 create a subset of the dataset type using only the elemnt indexed by indices More...
 
reference operator[] (std::size_t position)
 
const_reference operator[] (std::size_t position) const
 
reference front ()
 
const_reference front () const
 
reference back ()
 
const_reference back () const
 
std::size_t index (std::size_t position) const
 Position of the element in the dataset. More...
 
std::size_t batch (std::size_t position) const
 Index of the batch holding the element. More...
 
std::size_t positionInBatch (std::size_t position) const
 Index inside the batch holding the element. More...
 
std::size_t size () const
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
dataset_type const & dataset () const
 

Detailed Description

template<class DatasetType>
class shark::DataView< DatasetType >

Constant time Element-Lookup for Datasets.

Datasets are fast for random lookup of batches. Since batch sizes can be arbitrary structured and changed by the user, there is no way for the Data and LabeledData classes to provide fast random access to single elements. Still, this property is needed quite often, for example for creating subsets, randomize data or tree structures. A View stores the position of every element in a dataset. So it has constant time access to the elements but it also requires linear memory in the number of elements in the set. This is typically small compared to the size of the set itself, but construction imposes an considerable overhead.

In contrast to (Un)LabeledData, which is centered around batches, the View is centered around single elements, so its iterators iterate over the elements. For a better support for bagging an index method is added which returns the position of the element in the underlying data container. Also the iterators are indexed and return this index.

Definition at line 60 of file DataView.h.

Member Typedef Documentation

◆ const_iterator

template<class DatasetType>
typedef IteratorBase<const_reference, DataView<DatasetType> const > shark::DataView< DatasetType >::const_iterator

Definition at line 138 of file DataView.h.

◆ const_reference

template<class DatasetType>
typedef dataset_type::const_element_reference shark::DataView< DatasetType >::const_reference

Definition at line 65 of file DataView.h.

◆ iterator

template<class DatasetType>
typedef IteratorBase<reference,DataView<DatasetType> > shark::DataView< DatasetType >::iterator

Definition at line 137 of file DataView.h.

◆ reference

template<class DatasetType>
typedef boost::mpl::if_< std::is_const<DatasetType>, typename dataset_type::const_element_reference, typename dataset_type::element_reference >::type shark::DataView< DatasetType >::reference

Definition at line 73 of file DataView.h.

Constructor & Destructor Documentation

◆ DataView() [1/3]

template<class DatasetType>
shark::DataView< DatasetType >::DataView ( )
inline

Definition at line 140 of file DataView.h.

◆ DataView() [2/3]

template<class DatasetType>
shark::DataView< DatasetType >::DataView ( DatasetType &  dataset)
inline

Definition at line 141 of file DataView.h.

◆ DataView() [3/3]

template<class DatasetType>
template<class IndexRange >
shark::DataView< DatasetType >::DataView ( DataView< DatasetType > const &  view,
IndexRange const &  indices 
)
inline

create a subset of the dataset type using only the elemnt indexed by indices

Definition at line 157 of file DataView.h.

Member Function Documentation

◆ back() [1/2]

template<class DatasetType>
reference shark::DataView< DatasetType >::back ( )
inline

Definition at line 183 of file DataView.h.

◆ back() [2/2]

template<class DatasetType>
const_reference shark::DataView< DatasetType >::back ( ) const
inline

Definition at line 187 of file DataView.h.

◆ batch()

template<class DatasetType>
std::size_t shark::DataView< DatasetType >::batch ( std::size_t  position) const
inline

◆ begin() [1/2]

template<class DatasetType>
iterator shark::DataView< DatasetType >::begin ( )
inline

Definition at line 214 of file DataView.h.

Referenced by shark::toDataset().

◆ begin() [2/2]

template<class DatasetType>
const_iterator shark::DataView< DatasetType >::begin ( ) const
inline

Definition at line 217 of file DataView.h.

◆ dataset()

template<class DatasetType>
dataset_type const& shark::DataView< DatasetType >::dataset ( ) const
inline

◆ end() [1/2]

template<class DatasetType>
iterator shark::DataView< DatasetType >::end ( )
inline

Definition at line 220 of file DataView.h.

Referenced by shark::toDataset().

◆ end() [2/2]

template<class DatasetType>
const_iterator shark::DataView< DatasetType >::end ( ) const
inline

Definition at line 223 of file DataView.h.

◆ front() [1/2]

template<class DatasetType>
reference shark::DataView< DatasetType >::front ( )
inline

Definition at line 175 of file DataView.h.

◆ front() [2/2]

template<class DatasetType>
const_reference shark::DataView< DatasetType >::front ( ) const
inline

Definition at line 179 of file DataView.h.

◆ index()

template<class DatasetType>
std::size_t shark::DataView< DatasetType >::index ( std::size_t  position) const
inline

Position of the element in the dataset.

This is useful for bagging, when identical elements among several subsets are to be identified.

Definition at line 196 of file DataView.h.

Referenced by shark::DataView< shark::Data< LabelType > const >::DataView(), and shark::DataView< shark::Data< LabelType > const >::operator[]().

◆ operator[]() [1/2]

template<class DatasetType>
reference shark::DataView< DatasetType >::operator[] ( std::size_t  position)
inline

Definition at line 164 of file DataView.h.

◆ operator[]() [2/2]

template<class DatasetType>
const_reference shark::DataView< DatasetType >::operator[] ( std::size_t  position) const
inline

Definition at line 169 of file DataView.h.

◆ positionInBatch()

template<class DatasetType>
std::size_t shark::DataView< DatasetType >::positionInBatch ( std::size_t  position) const
inline

◆ size()


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