PLearn 0.1
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Static Protected Member Functions | Private Types | Private Member Functions
PLearn::FractionSplitter Class Reference

#include <FractionSplitter.h>

Inheritance diagram for PLearn::FractionSplitter:
Inheritance graph
[legend]
Collaboration diagram for PLearn::FractionSplitter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 FractionSplitter ()
virtual void build ()
 Post-constructor.
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual FractionSplitterdeepCopy (CopiesMap &copies) const
virtual int nsplits () const
 Returns the number of available different "splits".
virtual int nSetsPerSplit () const
 Returns the number of sets per split.
virtual TVec< VMatgetSplit (int i=0)
 Returns split number i.

Static Public Member Functions

static string _classname_ ()
 Declares name and deepCopy methods.
static OptionList_getOptionList_ ()
static RemoteMethodMap_getRemoteMethodMap_ ()
static Object_new_instance_for_typemap_ ()
static bool _isa_ (const Object *o)
static void _static_initialize_ ()
static const PPathdeclaringFile ()

Public Attributes

bool one_is_absolute
bool round_to_closest
TMat< pair< real, real > > splits

Static Public Attributes

static StaticInitializer _static_initializer_

Static Protected Member Functions

static void declareOptions (OptionList &ol)
 Declares this class' options.

Private Types

typedef Splitter inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

Definition at line 48 of file FractionSplitter.h.


Member Typedef Documentation

Reimplemented from PLearn::Splitter.

Definition at line 53 of file FractionSplitter.h.


Constructor & Destructor Documentation

PLearn::FractionSplitter::FractionSplitter ( )

Definition at line 48 of file FractionSplitter.cc.


Member Function Documentation

string PLearn::FractionSplitter::_classname_ ( ) [static]

Declares name and deepCopy methods.

Reimplemented from PLearn::Splitter.

Definition at line 56 of file FractionSplitter.cc.

OptionList & PLearn::FractionSplitter::_getOptionList_ ( ) [static]

Reimplemented from PLearn::Splitter.

Definition at line 56 of file FractionSplitter.cc.

RemoteMethodMap & PLearn::FractionSplitter::_getRemoteMethodMap_ ( ) [static]

Reimplemented from PLearn::Splitter.

Definition at line 56 of file FractionSplitter.cc.

bool PLearn::FractionSplitter::_isa_ ( const Object o) [static]

Reimplemented from PLearn::Splitter.

Definition at line 56 of file FractionSplitter.cc.

Object * PLearn::FractionSplitter::_new_instance_for_typemap_ ( ) [static]

Reimplemented from PLearn::Object.

Definition at line 56 of file FractionSplitter.cc.

StaticInitializer FractionSplitter::_static_initializer_ & PLearn::FractionSplitter::_static_initialize_ ( ) [static]

Reimplemented from PLearn::Splitter.

Definition at line 56 of file FractionSplitter.cc.

void PLearn::FractionSplitter::build ( ) [virtual]

Post-constructor.

The normal implementation should call simply inherited::build(), then this class's build_(). This method should be callable again at later times, after modifying some option fields to change the "architecture" of the object.

Reimplemented from PLearn::Object.

Definition at line 101 of file FractionSplitter.cc.

References PLearn::Object::build(), and build_().

Here is the call graph for this function:

void PLearn::FractionSplitter::build_ ( ) [private]

This does the actual building.

Reimplemented from PLearn::Object.

Definition at line 94 of file FractionSplitter.cc.

Referenced by build().

{
}

Here is the caller graph for this function:

string PLearn::FractionSplitter::classname ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 56 of file FractionSplitter.cc.

void PLearn::FractionSplitter::declareOptions ( OptionList ol) [static, protected]

Declares this class' options.

Reimplemented from PLearn::Splitter.

Definition at line 61 of file FractionSplitter.cc.

References PLearn::OptionBase::advanced_level, PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::Splitter::declareOptions(), one_is_absolute, round_to_closest, and splits.

{

    declareOption(ol, "round_to_closest", &FractionSplitter::round_to_closest, OptionBase::buildoption,
                  "If set to 1, then the integer value found when using fractions will\n"
                  "be the closest integer, instead of the integer part.");

    declareOption(ol, "splits", &FractionSplitter::splits, OptionBase::buildoption,
                  "A matrix of start:end pairs. Each row represents a split. \n"
                  "Each start:end element represents a range of samples in the dataset to be splitted. \n"
                  "start and end, which are positions in the datataset, can be specified as either \n"
                  "a fraction of the dataset length (if <=1), or an absolute number of elements (if >1).\n"
                  "The range includes all samples from start to end, but excluding the end sample \n"
                  "(so that, for ex., the same value can be used as the start of the next range \n"
                  "without having the two ranges ovelap). \n"
                  "The value 1 is a bit special as it always means \"until last element inclusive\".\n"
                  "Ex: 1 2 [ 0:0.80, 0.80:1 ]  yields a single split with the first part being the first 80% \n"
                  "of the data, and the second the next 20% \n");

    declareOption(ol, "one_is_absolute",
                  &FractionSplitter::one_is_absolute, OptionBase::buildoption,
        "If true, then 1 is always considered as an absolute index, not as a\n"
        "fraction giving the end of the dataset. This can be useful if you\n"
        "actually want a split with a single element in it.",
        OptionBase::advanced_level);

    // Now call the parent class' declareOptions
    inherited::declareOptions(ol);
}

Here is the call graph for this function:

static const PPath& PLearn::FractionSplitter::declaringFile ( ) [inline, static]

Reimplemented from PLearn::Splitter.

Definition at line 106 of file FractionSplitter.h.

FractionSplitter * PLearn::FractionSplitter::deepCopy ( CopiesMap copies) const [virtual]

Reimplemented from PLearn::Splitter.

Definition at line 56 of file FractionSplitter.cc.

OptionList & PLearn::FractionSplitter::getOptionList ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 56 of file FractionSplitter.cc.

OptionMap & PLearn::FractionSplitter::getOptionMap ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 56 of file FractionSplitter.cc.

RemoteMethodMap & PLearn::FractionSplitter::getRemoteMethodMap ( ) const [virtual]

Reimplemented from PLearn::Object.

Definition at line 56 of file FractionSplitter.cc.

TVec< VMat > PLearn::FractionSplitter::getSplit ( int  i = 0) [virtual]

Returns split number i.

Implements PLearn::Splitter.

Definition at line 124 of file FractionSplitter.cc.

References PLearn::Splitter::dataset, PLearn::TVec< T >::first(), i, PLearn::is_equal(), PLearn::TVec< T >::length(), PLearn::VMat::length(), n, one_is_absolute, round_to_closest, splits, and PLearn::VMat::subMatRows().

{
    TVec< pair<real,real> > frac_k = splits(k);
    int n = frac_k.length();
    TVec<VMat> vms(n);
    int l = dataset.length();
    int start = 0;
    int end = 0;
    for(int i=0; i<n; i++)
    {
        real fstart = frac_k[i].first;
        real fend = frac_k[i].second;

        if(fstart>1 || (one_is_absolute && is_equal(fstart, 1))) // absolute position
            start = int(round(fstart));
        else {// relative position
            if (round_to_closest) {
                start = int(fstart*l + 0.5);
            } else {
                start = int(fstart*l);
            }
        }

        if(fend>1 || (one_is_absolute && is_equal(fend, 1))) // absolute end position
            end = int(round(fend));
        else if(is_equal(fend,1)) // until last element inclusive
            end = l;
        else {// relative end position
            if (round_to_closest) {
                end = int(fend*l + 0.5);
            } else {
                end = int(fend*l);
            }
        }

        vms[i] = dataset.subMatRows(start, end-start);
    }
    return vms;
}

Here is the call graph for this function:

void PLearn::FractionSplitter::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::Splitter.

Definition at line 107 of file FractionSplitter.cc.

References PLearn::deepCopyField(), PLearn::Splitter::makeDeepCopyFromShallowCopy(), and splits.

Here is the call graph for this function:

int PLearn::FractionSplitter::nSetsPerSplit ( ) const [virtual]

Returns the number of sets per split.

Implements PLearn::Splitter.

Definition at line 118 of file FractionSplitter.cc.

References splits, and PLearn::TMat< T >::width().

{
    return splits.width();
}

Here is the call graph for this function:

int PLearn::FractionSplitter::nsplits ( ) const [virtual]

Returns the number of available different "splits".

Implements PLearn::Splitter.

Definition at line 113 of file FractionSplitter.cc.

References PLearn::TMat< T >::length(), and splits.

{
    return splits.length();
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::Splitter.

Definition at line 106 of file FractionSplitter.h.

Definition at line 70 of file FractionSplitter.h.

Referenced by declareOptions(), and getSplit().

Definition at line 71 of file FractionSplitter.h.

Referenced by declareOptions(), and getSplit().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines