1#ifndef FSTDATAACCESSOR_H
2#define FSTDATAACCESSOR_H
119template<
typename DATATYPE,
typename IDXTYPE>
120class Data_Accessor :
public Clonable
124 Data_Accessor() {
notify(
"Data_Accessor constructor");}
220 Data_Accessor*
clone()
const override =0;
Forward iterator over Block_Range; drives the wrapped getFirstBlock()/getNextBlock() cursor at the ra...
Definition data_accessor.hpp:175
iterator & operator++()
advances to the next block; becomes an end iterator once the loop is exhausted
Definition data_accessor.hpp:180
bool _done
whether iteration is exhausted
Definition data_accessor.hpp:184
Block_Range * _r
the owning range
Definition data_accessor.hpp:183
bool operator!=(const iterator &o) const
range-for only ever compares against end(); true until exhaustion
Definition data_accessor.hpp:181
iterator(Block_Range *r, const bool done)
Constructs an end iterator when done is true; otherwise fetches the first block via r,...
Definition data_accessor.hpp:178
Block _cur
the current block
Definition data_accessor.hpp:185
const Block & operator*() const
the current block (data pointer + size)
Definition data_accessor.hpp:179
RAII range over consecutive data blocks of one DataPart in the current split.
Definition data_accessor.hpp:172
const DataPart _part
the DataPart selected
Definition data_accessor.hpp:200
const unsigned int _depth
this range's owned loopdepth slot
Definition data_accessor.hpp:201
iterator begin()
an iterator positioned at the first block, or already at end() if there are none
Definition data_accessor.hpp:190
iterator end()
the sentinel end iterator
Definition data_accessor.hpp:191
unsigned int loopdepth() const
the owned slot (e.g. for getBlockIndex())
Definition data_accessor.hpp:192
Data_Accessor * _da
the accessor iterated
Definition data_accessor.hpp:199
Block_Range(Data_Accessor *da, const DataPart part)
Acquires a private loopdepth slot from da for the range's lifetime; part selects which DataPart the r...
Definition data_accessor.hpp:188
abstract class, defines interface for data access implementations
Definition data_accessor.hpp:121
void release_block_loop_slot(const unsigned int depth)
Returns the loopdepth slot acquired by acquire_block_loop_slot() so a future Block_Range can reuse it...
Definition data_accessor.hpp:237
virtual bool getFirstSplit()=0
data access iteration (to support, e.g., loops in cross-validation)
Data_Accessor * sharing_clone() const override=0
virtual bool getFirstBlock(const DataPart ofwhat, PPattern &firstpattern, IDXTYPE &patterns, const unsigned int loopdepth=0)=0
returns pointer to first consecutive block of data of requested DataPart type in the current split (a...
virtual void substitute(const DataPart source, const DataPart target)=0
enables change of meaning of DataPart types, for use in specialized data access scenarios like in bia...
virtual bool getNextBlock(const DataPart ofwhat, PPattern &firstpattern, IDXTYPE &patterns, const unsigned int loopdepth=0)=0
returns pointer to next consecutive block of data of requested DataPart type in the current split (ac...
virtual bool getNextSplit()=0
data access iteration (to support, e.g., loops in cross-validation)
virtual IDXTYPE getClassSize(const unsigned int c) const =0
returns size (number of samples in) of class c
virtual void resubstitute()=0
resets standard DataPart types' meaning, i.e. undoes every substitute() call
virtual unsigned int getNoOfFeatures() const =0
returns data dimensionality
virtual unsigned int getNoOfClasses() const =0
returns number of classes
virtual unsigned int getNoOfSplits() const =0
data access iteration (to support, e.g., loops in cross-validation)
unsigned int acquire_block_loop_slot()
Reserves and returns a free loopdepth (reusing a released one if available, else growing the pool by ...
Definition data_accessor.hpp:231
virtual IDXTYPE getNoOfPatterns(const DataPart ofwhat) const =0
returns number of patterns in all consecutive blocks of data of requested DataPart type in the curren...
virtual int getClass() const =0
returns active class
virtual IDXTYPE getBlockIndex(const unsigned int loopdepth=0) const =0
returns index of the current consecutive block of data of requested DataPart type in the current spli...
Data_Accessor * clone() const override=0
const DATATYPE * PPattern
one data sample: a raw pointer to its (read-only) feature vector, getNoOfFeatures() entries long
Definition data_accessor.hpp:123
Block_Range blocks(const DataPart ofwhat)
RAII block range over the current split - prefer over the deprecated getFirstBlock()/getNextBlock() c...
Definition data_accessor.hpp:204
virtual IDXTYPE getClassSizeSum() const =0
returns summed size (number of samples in) of all classes, i.e., no. of all patterns in data
virtual unsigned int getSplitIndex() const =0
data access iteration (to support, e.g., loops in cross-validation)
Data_Accessor * stateless_clone() const override=0
virtual IDXTYPE getNoOfBlocks(const DataPart ofwhat) const =0
returns the number of consecutive blocks the requested DataPart is made of in the current split
static const unsigned int _first_acquired_loopdepth
Definition data_accessor.hpp:228
virtual void setClass(const int c)=0
sets active class from which get*Block() will fetch data
std::vector< bool > _block_slot_used
Definition data_accessor.hpp:229
Defines interface for classes that may need to get cloned.
FST4 specific error passing class.
The Feature Selection Toolbox 4 library: every library component – data access, criteria and classifi...
Definition data_accessor.hpp:80
void notify(const std::string msg)
Prints msg followed by a newline via syncout::print(); a no-op unless the preprocessor macro DEBUG is...
Definition global.hpp:112
DataPart
Selects which part of a split's data a block-access call reads.
Definition data_accessor.hpp:83
@ TRAINTEST
both parts concatenated (train followed by test)
Definition data_accessor.hpp:87
@ ALL
every pattern regardless of split (the whole class)
Definition data_accessor.hpp:88
@ NONE
no part (used internally, e.g. for traintestphase state before a phase is chosen)
Definition data_accessor.hpp:84
@ TEST
the split's test part
Definition data_accessor.hpp:86
@ TRAIN
the split's training part
Definition data_accessor.hpp:85
one consecutive block of patterns as yielded by Block_Range/blocks()
Definition data_accessor.hpp:161
PPattern data
pointer to the first pattern of the block
Definition data_accessor.hpp:162
IDXTYPE size
number of patterns in the block
Definition data_accessor.hpp:163