|
|
| Data_Splitter_TrainRandom_TestFixed (const IDXTYPE _splits, const IDXTYPE _perctrain, const IDXTYPE _perctest, const bool randomize=false) |
| | same parameters as Data_Splitter_RandomRandom; the test part is always the fixed trailing _perctest % interval of each class
|
|
| Data_Splitter_TrainRandom_TestFixed (const Data_Splitter_TrainRandom_TestFixed &dsp) |
| | copies configuration
|
| virtual std::ostream & | print (std::ostream &os) const override |
| | writes a human-readable identification of the splitter and its configuration; base default writes nothing
|
| Data_Splitter_RandomRandom< INTERVALCONTAINER, IDXTYPE, BINTYPE > * | clone () const override |
| | dispatches to the DEEP_KIND mechanism (default CLONE_DEEP: Derived's copy-constructor)
|
| Data_Splitter_RandomRandom< INTERVALCONTAINER, IDXTYPE, BINTYPE > * | sharing_clone () const override |
| | dispatches to the SHARING_KIND mechanism (default CLONE_INHERIT: defers to Base, which throws by family convention)
|
| Data_Splitter_RandomRandom< INTERVALCONTAINER, IDXTYPE, BINTYPE > * | stateless_clone () const override |
| | dispatches to the STATELESS_KIND mechanism (default CLONE_INHERIT: defers to Base, which throws by family convention)
|
| Public Member Functions inherited from FST::Data_Splitter_RandomRandom< INTERVALCONTAINER, IDXTYPE, BINTYPE > |
|
| Data_Splitter_RandomRandom (const IDXTYPE _splits, const IDXTYPE _perctrain, const IDXTYPE _perctest, const bool randomize=false) |
| | _splits splits, each drawing _perctrain % of each class for training and _perctest % for testing (non-overlapping); randomize selects a per-instance engine seeded from std::random_device instead of the reproducible library PRNG (see the class warning).
|
|
| Data_Splitter_RandomRandom (const Data_Splitter_RandomRandom &dsp) |
| | Copy constructor. It deliberately does NOT inherit RNG state: in the randomize==true mode each copy seeds its own engine in prepareFirstSplit(), which is what keeps worker-thread clones from all drawing the same "random" splits. Configuration and the split counter transfer.
|
| virtual IDXTYPE | getNoOfSplits () const override |
|
| 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()
|
| 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 |
| 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
|
|
| virtual void | makeRandomSplit (const IDXTYPE n, const std::shared_ptr< INTERVALCONTAINER > list_train, const std::shared_ptr< INTERVALCONTAINER > list_test) override |
| Protected Member Functions inherited from FST::Data_Splitter_RandomRandom< INTERVALCONTAINER, IDXTYPE, BINTYPE > |
| virtual const char * | splitter_name () const override |
| | class name, used in error messages
|
| virtual bool | prepareFirstSplit () override |
| | set up split-sequence state; false = no split can be made
|
| virtual bool | prepareNextSplit () override |
| | advance split-sequence state; false = no more splits
|
| virtual void | splitClassFirst (typename TCC::ClassIterator c, const unsigned int) override |
| | write first-split train/test intervals of class cidx (c is that class's entry in csplit)
|
| virtual void | splitClassNext (typename TCC::ClassIterator c, const unsigned int) override |
| | write next-split train/test intervals of class cidx (a single-split splitter never gets here, since its prepareNextSplit() returns false)
|
| void | fill_randomly (const IDXTYPE n, const BINTYPE id_empty, const BINTYPE id_fill, const IDXTYPE count, const IDXTYPE minidx, const IDXTYPE maxidx) |
| | Randomly relabels count of the still-id_empty slots of _data (within [minidx,maxidx]) to id_fill; draws from the per-instance engine when _randomize, else from the reproducible FST::fst_rand() stream.
|
|
void | fill (const IDXTYPE n, const BINTYPE id_empty, const BINTYPE id_fill, const IDXTYPE minidx, const IDXTYPE maxidx) |
| | Relabels every still-id_empty slot of _data (within [minidx,maxidx]) to id_fill, unconditionally (no randomness).
|
|
void | translate (const IDXTYPE n, const BINTYPE id_fill, const std::shared_ptr< INTERVALCONTAINER > lst) |
| | Converts the binary _data labeling (id_fill vs. everything else) over indices [0,n) into lst's list of consecutive Data_Interval runs.
|
|
void | assert_csplit () const |
| | DEBUG-only: asserts csplit is non-empty and every class has n>0 and non-null train/test lists.
|
| virtual void | finishSplit () |
| | post-loop state update shared by first/next split
|
|
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 inherited from FST::Data_Splitter_RandomRandom< INTERVALCONTAINER, IDXTYPE, BINTYPE > |
|
IDXTYPE | _n_max |
| | actual _data size (capacity; may exceed the current class size n)
|
|
std::unique_ptr< BINTYPE[]> | _data |
| | pattern selection array: one BINTYPE label (id_empty/id_train/id_test) per sample index, reused/reallocated per class in makeRandomSplit()
|
|
const IDXTYPE | perctrain |
| | percentage of each class's samples drawn for training
|
|
const IDXTYPE | perctest |
| | percentage of each class's samples drawn for testing
|
|
const IDXTYPE | splits |
| | number of splits this splitter yields (getNoOfSplits())
|
|
const bool | _randomize |
| | true = seed a per-instance std::mt19937 engine (different splits every run); false = draw from the FST::fst_rand() stream, which makes the splits reproducible at a fixed seed
|
|
std::mt19937 | _rng |
| | per-instance RNG engine; used only when _randomize==true (see prepareFirstSplit())
|
|
IDXTYPE | current_split |
| | 1-based index of the split currently being produced; 0 outside an active split sequence
|
|
std::vector< PClassSplitter > | csplit |
| | one TClassSplitter per data class, indexed by class index; grown on demand by assign()/set_n()
|
template<class INTERVALCONTAINER, typename IDXTYPE, typename BINTYPE>
class FST::Data_Splitter_TrainRandom_TestFixed< INTERVALCONTAINER, IDXTYPE, BINTYPE >
Implements train/test data splitting: equal to Data_Splitter_RandomRandom except that the same test data is returned in each loop.
The train part is drawn at random from the leading part of each class, exactly as Data_Splitter_RandomRandom draws it, and varies from split to split. The test part is fixed: it is always the LAST perctest % of each class, in file order, and is therefore the same samples in every split. Use it when several splits should be compared against one common test set.
- Warning
- Because the test part is chosen by position rather than at random, it inherits whatever structure the sample order has: on data sorted by anything that correlates with a feature, the trailing samples are not a representative test set.