Abstract class, defines interface for data splitting implementations (for use in data accessors). More...
#include <data_splitter.hpp>
Classes | |
| class | TClassSplitter |
| Data splitting support structure; holds one set of intervals (train, test) per each (data)class. More... | |
Public Types | |
| typedef std::shared_ptr< INTERVALCONTAINER > | PIntervaller |
| shared pointer to one class's list of train/test data intervals | |
Public Member Functions | |
| Data_Splitter (const Data_Splitter &dsp) | |
Deep-copies every class's TClassSplitter (own train/test interval lists, not shared with dsp). | |
| void | assign (const unsigned int _clsidx, const PIntervaller _train, const PIntervaller _test) |
Registers class _clsidx's train/test interval lists (growing csplit as needed); the caller retains ownership via the shared pointers. | |
| void | set_n (const unsigned int _clsidx, const IDXTYPE _n) |
Sets class _clsidx's pattern count, which getNoOfSplits() and the concrete prepare*/splitClass* hooks size their splits against (growing csplit as needed). | |
| IDXTYPE | get_n (const unsigned int _clsidx) const |
the pattern count previously set for class _clsidx via set_n() | |
| virtual IDXTYPE | getNoOfSplits () const =0 |
| bool | makeFirstSplit () |
| Produces the first split: prepareFirstSplit(), then splitClassFirst() per class, then finishSplit(). | |
| bool | makeNextSplit () |
| Produces the next split: prepareNextSplit(), then splitClassNext() per class, then finishSplit(). | |
| Data_Splitter * | clone () const override |
| Data_Splitter * | sharing_clone () const override |
| Data_Splitter * | stateless_clone () const override=0 |
| virtual std::ostream & | print (std::ostream &os) const override |
| writes a human-readable identification of the splitter and its configuration; base default writes nothing | |
| Public Member Functions inherited from FST::Clonable | |
| bool | is_clone () const |
| bool | is_sharing () const |
| true if this instance is a sharing_clone() result (referencing, not owning, the source's structures) | |
| bool | is_sharing_clone () const |
| true if this instance is BOTH a clone and sharing – i.e. specifically a sharing_clone() result, not a clone()/stateless_clone() one | |
Protected Types | |
| typedef std::shared_ptr< TClassSplitter > | PClassSplitter |
| shared pointer to one class's TClassSplitter | |
| typedef std::vector< PClassSplitter >::const_iterator | ClassIterator |
| iterator over csplit, as passed to the per-class splitClassFirst()/splitClassNext() hooks | |
Protected Member Functions | |
| void | assert_csplit () const |
| DEBUG-only: asserts csplit is non-empty and every class has n>0 and non-null train/test lists. | |
| virtual const char * | splitter_name () const =0 |
| class name, used in error messages | |
| virtual bool | prepareFirstSplit () |
| set up split-sequence state; false = no split can be made | |
| virtual bool | prepareNextSplit ()=0 |
| advance split-sequence state; false = no more splits | |
| virtual void | splitClassFirst (ClassIterator c, const unsigned int cidx)=0 |
write first-split train/test intervals of class cidx (c is that class's entry in csplit) | |
| virtual void | splitClassNext (ClassIterator c, const unsigned int cidx) |
write next-split train/test intervals of class cidx (a single-split splitter never gets here, since its prepareNextSplit() returns false) | |
| virtual void | finishSplit () |
| post-loop state update shared by first/next split | |
| Protected Member Functions inherited from FST::Clonable | |
| void | set_cloned (const bool cloned=true) |
| marks/unmarks this instance as a clone; call from clone()/stateless_clone() overrides (Clonable_Impl does this automatically) | |
| void | set_sharing (const bool sharing=true) |
| marks/unmarks this instance as sharing (see is_sharing()) | |
| void | set_sharing_cloned (const bool cloned=true, const bool sharing=true) |
| sets both flags at once; call from sharing_clone() overrides (Clonable_Impl does this automatically) | |
Protected Attributes | |
| std::vector< PClassSplitter > | csplit |
| one TClassSplitter per data class, indexed by class index; grown on demand by assign()/set_n() | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Data_Splitter< INTERVALCONTAINER, IDXTYPE > &ds) |
Streams a splitter's print() to os. | |
Abstract class, defines interface for data splitting implementations (for use in data accessors).
A splitter enumerates a sequence of train/test partitions. It does not touch data: it works purely with sample INDEXES, and writes each partition as two lists of index intervals, per class.
Driving a splitter. The owner first calls assign() and set_n() once per class, then iterates for(bool b=makeFirstSplit(); b; b=makeNextSplit()). Each successful call overwrites the train and test interval lists registered through assign(); the lists are only valid until the next call. getNoOfSplits() says how many iterations to expect and requires set_n() to have been called.
What an implementation must guarantee. Every split, for every class:
Implementing one. The template methods makeFirstSplit()/makeNextSplit() own the shared scaffolding – the state assertions, the per-class loop and the error reporting – so a concrete splitter implements only the prepare*, splitClass* and finishSplit hooks, i.e. its actual splitting logic. The call order is: prepareFirstSplit(), then splitClassFirst() once per class in class order, then finishSplit(); and for every later split prepareNextSplit(), then splitClassNext() once per class in class order, then finishSplit(). A prepare hook returning false ends the sequence, and neither splitClass nor finishSplit is called after it.
|
inlineoverridevirtual |
create 1:1 independent clone of the current object. The caller owns the returned object. Families that cannot support a given clone kind implement it to throw fst_error; Clonable_Impl's CLONE_INHERIT slot defers to such a body.
Implements FST::Clonable.
|
inlineprotectedvirtual |
post-loop state update shared by first/next split
Reimplemented in FST::Data_Splitter_CV< INTERVALCONTAINER, IDXTYPE >, and FST::Data_Splitter_Leave1Out< INTERVALCONTAINER, IDXTYPE >.
|
pure virtual |
number of splits this splitter yields (requires class sizes to have been set via set_n())
Implemented in FST::Data_Splitter_5050< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_CV< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_Holdout< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_Leave1Out< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_RandomRandom< INTERVALCONTAINER, IDXTYPE, BINTYPE >, and FST::Data_Splitter_Resub< INTERVALCONTAINER, IDXTYPE >.
| bool FST::Data_Splitter< INTERVALCONTAINER, IDXTYPE >::makeFirstSplit | ( | ) |
Produces the first split: prepareFirstSplit(), then splitClassFirst() per class, then finishSplit().
| bool FST::Data_Splitter< INTERVALCONTAINER, IDXTYPE >::makeNextSplit | ( | ) |
Produces the next split: prepareNextSplit(), then splitClassNext() per class, then finishSplit().
|
inlineprotectedvirtual |
set up split-sequence state; false = no split can be made
Reimplemented in FST::Data_Splitter_CV< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_Leave1Out< INTERVALCONTAINER, IDXTYPE >, and FST::Data_Splitter_RandomRandom< INTERVALCONTAINER, IDXTYPE, BINTYPE >.
|
protectedpure virtual |
advance split-sequence state; false = no more splits
Implemented in FST::Data_Splitter_5050< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_CV< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_Holdout< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_Leave1Out< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_RandomRandom< INTERVALCONTAINER, IDXTYPE, BINTYPE >, and FST::Data_Splitter_Resub< INTERVALCONTAINER, IDXTYPE >.
|
inlineoverridevirtual |
writes a human-readable identification of the splitter and its configuration; base default writes nothing
Reimplemented from FST::Clonable.
Reimplemented in FST::Data_Splitter_5050< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_CV< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_Holdout< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_Leave1Out< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_RandomRandom< INTERVALCONTAINER, IDXTYPE, BINTYPE >, FST::Data_Splitter_Resub< INTERVALCONTAINER, IDXTYPE >, and FST::Data_Splitter_TrainRandom_TestFixed< INTERVALCONTAINER, IDXTYPE, BINTYPE >.
|
inlineoverridevirtual |
create equivalent clone of the current object, permitting read-only access to structures in the source object (allows referencing instead of copying of large memory structures). may be faster and save space but requires more caution with respect to concurrency Use example: Data_Accessor memory data representation cloning
Implements FST::Clonable.
|
protectedpure virtual |
write first-split train/test intervals of class cidx (c is that class's entry in csplit)
Implemented in FST::Data_Splitter_5050< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_CV< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_Holdout< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_Leave1Out< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_RandomRandom< INTERVALCONTAINER, IDXTYPE, BINTYPE >, and FST::Data_Splitter_Resub< INTERVALCONTAINER, IDXTYPE >.
|
inlineprotectedvirtual |
write next-split train/test intervals of class cidx (a single-split splitter never gets here, since its prepareNextSplit() returns false)
Reimplemented in FST::Data_Splitter_CV< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_Leave1Out< INTERVALCONTAINER, IDXTYPE >, and FST::Data_Splitter_RandomRandom< INTERVALCONTAINER, IDXTYPE, BINTYPE >.
|
protectedpure virtual |
class name, used in error messages
Implemented in FST::Data_Splitter_5050< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_CV< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_Holdout< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_Leave1Out< INTERVALCONTAINER, IDXTYPE >, FST::Data_Splitter_RandomRandom< INTERVALCONTAINER, IDXTYPE, BINTYPE >, and FST::Data_Splitter_Resub< INTERVALCONTAINER, IDXTYPE >.
|
overridepure virtual |
create clone of the current object, ignoring internal temporary structures to save speed. Does not replicate exact object state. The clone must be used carefully in a way that ensures internal structure re-initialization Use example: Data_Splitter cloning or Classifier_LIBSVM cloning due to inability to clone external structures defined in LibSVM
Implements FST::Clonable.
Implemented in FST::Clonable_Impl< Data_Splitter_5050, Data_Splitter< INTERVALCONTAINER, IDXTYPE >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >, FST::Clonable_Impl< Data_Splitter_5050< INTERVALCONTAINER, IDXTYPE >, Data_Splitter< INTERVALCONTAINER, IDXTYPE >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >, FST::Clonable_Impl< Data_Splitter_CV, Data_Splitter< INTERVALCONTAINER, IDXTYPE >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >, FST::Clonable_Impl< Data_Splitter_CV< INTERVALCONTAINER, IDXTYPE >, Data_Splitter< INTERVALCONTAINER, IDXTYPE >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >, FST::Clonable_Impl< Data_Splitter_Holdout, Data_Splitter< INTERVALCONTAINER, IDXTYPE >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >, FST::Clonable_Impl< Data_Splitter_Holdout< INTERVALCONTAINER, IDXTYPE >, Data_Splitter< INTERVALCONTAINER, IDXTYPE >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >, FST::Clonable_Impl< Data_Splitter_Leave1Out, Data_Splitter< INTERVALCONTAINER, IDXTYPE >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >, FST::Clonable_Impl< Data_Splitter_Leave1Out< INTERVALCONTAINER, IDXTYPE >, Data_Splitter< INTERVALCONTAINER, IDXTYPE >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >, FST::Clonable_Impl< Data_Splitter_RandomRandom, Data_Splitter< INTERVALCONTAINER, IDXTYPE >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >, FST::Clonable_Impl< Data_Splitter_RandomRandom< INTERVALCONTAINER, IDXTYPE, BINTYPE >, Data_Splitter< INTERVALCONTAINER, IDXTYPE >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >, FST::Clonable_Impl< Data_Splitter_Resub, Data_Splitter< INTERVALCONTAINER, IDXTYPE >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >, FST::Clonable_Impl< Data_Splitter_Resub< INTERVALCONTAINER, IDXTYPE >, Data_Splitter< INTERVALCONTAINER, IDXTYPE >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >, and FST::Clonable_Impl< Data_Splitter_TrainRandom_TestFixed< INTERVALCONTAINER, IDXTYPE, BINTYPE >, Data_Splitter_RandomRandom< INTERVALCONTAINER, IDXTYPE, BINTYPE >, CLONE_INHERIT, CLONE_INHERIT, CLONE_DEEP >.