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_< boost::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 |
std::size_t | index (std::size_t position) const |
returns the position of the element inside the dataset 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 63 of file DataView.h.
typedef IteratorBase<const_reference, DataView<DatasetType> const > shark::DataView< DatasetType >::const_iterator |
Definition at line 141 of file DataView.h.
typedef dataset_type::const_element_reference shark::DataView< DatasetType >::const_reference |
Definition at line 68 of file DataView.h.
typedef IteratorBase<reference,DataView<DatasetType> > shark::DataView< DatasetType >::iterator |
Definition at line 140 of file DataView.h.
typedef boost::mpl::if_< boost::is_const<DatasetType>, typename dataset_type::const_element_reference, typename dataset_type::element_reference >::type shark::DataView< DatasetType >::reference |
Definition at line 76 of file DataView.h.
|
inline |
Definition at line 143 of file DataView.h.
|
inline |
Definition at line 144 of file DataView.h.
|
inline |
create a subset of the dataset type using only the elemnt indexed by indices
Definition at line 160 of file DataView.h.
|
inline |
Definition at line 189 of file DataView.h.
|
inline |
Definition at line 192 of file DataView.h.
|
inline |
Definition at line 202 of file DataView.h.
Referenced by shark::dataDimension(), shark::inputDimension(), shark::labelDimension(), shark::numberOfClasses(), and shark::toDataset().
|
inline |
Definition at line 195 of file DataView.h.
|
inline |
Definition at line 198 of file DataView.h.
|
inline |
returns the position of the element inside the dataset
This is useful for bagging, when identical elements among several subsets are to be identified.
Definition at line 181 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 167 of file DataView.h.
|
inline |
Definition at line 172 of file DataView.h.
|
inline |
Definition at line 185 of file DataView.h.
Referenced by shark::createCVSameSizeBalanced(), shark::DataView< shark::Data< LabelType > const >::end(), shark::MissingFeaturesKernelExpansion< InputType >::eval(), shark::exportKernelMatrix(), main(), shark::DataView< shark::Data< LabelType > const >::operator[](), shark::randomSubBatch(), shark::randomSubset(), and shark::toDataset().