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 |
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.
typedef IteratorBase<const_reference, DataView<DatasetType> const > shark::DataView< DatasetType >::const_iterator |
Definition at line 138 of file DataView.h.
typedef dataset_type::const_element_reference shark::DataView< DatasetType >::const_reference |
Definition at line 65 of file DataView.h.
typedef IteratorBase<reference,DataView<DatasetType> > shark::DataView< DatasetType >::iterator |
Definition at line 137 of file DataView.h.
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.
|
inline |
Definition at line 140 of file DataView.h.
|
inline |
Definition at line 141 of file DataView.h.
|
inline |
create a subset of the dataset type using only the elemnt indexed by indices
Definition at line 157 of file DataView.h.
|
inline |
Definition at line 183 of file DataView.h.
|
inline |
Definition at line 187 of file DataView.h.
|
inline |
Index of the batch holding the element.
Definition at line 201 of file DataView.h.
Referenced by shark::DataView< shark::Data< LabelType > const >::dataset(), and shark::DifferenceKernelMatrix< InputType, CacheType >::DifferenceKernelMatrix().
|
inline |
Definition at line 214 of file DataView.h.
Referenced by shark::toDataset().
|
inline |
Definition at line 217 of file DataView.h.
|
inline |
Definition at line 227 of file DataView.h.
Referenced by shark::dataDimension(), shark::inputDimension(), shark::labelDimension(), shark::numberOfClasses(), and shark::toDataset().
|
inline |
Definition at line 220 of file DataView.h.
Referenced by shark::toDataset().
|
inline |
Definition at line 223 of file DataView.h.
|
inline |
Definition at line 175 of file DataView.h.
|
inline |
Definition at line 179 of file DataView.h.
|
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[]().
|
inline |
Definition at line 164 of file DataView.h.
|
inline |
Definition at line 169 of file DataView.h.
|
inline |
Index inside the batch holding the element.
Definition at line 206 of file DataView.h.
Referenced by shark::DataView< shark::Data< LabelType > const >::dataset(), and shark::DifferenceKernelMatrix< InputType, CacheType >::DifferenceKernelMatrix().
|
inline |
Definition at line 210 of file DataView.h.
Referenced by shark::DataView< shark::Data< LabelType > const >::back(), shark::createCVSameSizeBalanced(), shark::DataView< shark::Data< LabelType > const >::end(), shark::exportKernelMatrix(), shark::DataView< shark::Data< LabelType > const >::front(), main(), shark::LinearSAGTrainer< InputType, LabelType >::numberOfParameters(), shark::DataView< shark::Data< LabelType > const >::operator[](), shark::randomSubBatch(), shark::randomSubset(), and shark::toDataset().