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

#include <StackedSplitter.h>

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

List of all members.

Public Member Functions

 StackedSplitter ()
 Default constructor.
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 StackedSplitterdeepCopy (CopiesMap &copies) const
virtual void setDataSet (VMat the_dataset)
 Overridden to forward to the initial splitter.
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

PP< Splitterinitial_splitter
TVec< PP< Splitter > > top_splitters

Static Public Attributes

static StaticInitializer _static_initializer_

Static Protected Member Functions

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

Protected Attributes

int last_k_init
 The last split asked to the initial splitter.
TVec< VMatlast_split_init
 The last split returned by the initial splitter.

Private Types

typedef Splitter inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

Definition at line 52 of file StackedSplitter.h.


Member Typedef Documentation

Reimplemented from PLearn::Splitter.

Definition at line 57 of file StackedSplitter.h.


Constructor & Destructor Documentation

PLearn::StackedSplitter::StackedSplitter ( )

Default constructor.

Definition at line 53 of file StackedSplitter.cc.

    : last_k_init(-1)
{
}

Member Function Documentation

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

Declares name and deepCopy methods.

Reimplemented from PLearn::Splitter.

Definition at line 63 of file StackedSplitter.cc.

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

Reimplemented from PLearn::Splitter.

Definition at line 63 of file StackedSplitter.cc.

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

Reimplemented from PLearn::Splitter.

Definition at line 63 of file StackedSplitter.cc.

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

Reimplemented from PLearn::Splitter.

Definition at line 63 of file StackedSplitter.cc.

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

Reimplemented from PLearn::Object.

Definition at line 63 of file StackedSplitter.cc.

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

Reimplemented from PLearn::Splitter.

Definition at line 63 of file StackedSplitter.cc.

void PLearn::StackedSplitter::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 90 of file StackedSplitter.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::Object.

Definition at line 99 of file StackedSplitter.cc.

References i, initial_splitter, PLearn::TVec< T >::isNotEmpty(), PLearn::TVec< T >::length(), nsplits(), PLERROR, and top_splitters.

Referenced by build().

{
    // ### This method should do the real building of the object,
    // ### according to set 'options', in *any* situation.
    // ### Typical situations include:
    // ###  - Initial building of an object from a few user-specified options
    // ###  - Building of a "reloaded" object: i.e. from the complete set of all serialised options.
    // ###  - Updating or "re-building" of an object after a few "tuning" options have been modified.
    // ### You should assume that the parent class' build_() has already been called.
    if (initial_splitter && top_splitters.isNotEmpty()) {
        if (initial_splitter->nSetsPerSplit() != top_splitters.length())
            PLERROR("In StackedSplitter::build_ - initial_splitter->nSetsPerSplit() != top_splitters.length()");
        // Replace each null splitter with a NoSplitSplitter
        for (int i = 0; i < top_splitters.length(); i++)
            if (!top_splitters[i])
                top_splitters[i] = new NoSplitSplitter();
        // Make sure all splitters have a consistent number of splits.
        int ns = top_splitters[0]->nsplits();
        for (int i = 1; i < top_splitters.length(); i++)
            if (top_splitters[i]->nsplits() != ns)
                PLERROR("In StackedSplitter::build_ - All splitters in 'top_splitters' must give the same number of splits");
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 63 of file StackedSplitter.cc.

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

Declares this class' options.

Reimplemented from PLearn::Splitter.

Definition at line 68 of file StackedSplitter.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::Splitter::declareOptions(), initial_splitter, and top_splitters.

{
    // ### Declare all of this object's options here
    // ### For the "flags" of each option, you should typically specify
    // ### one of OptionBase::buildoption, OptionBase::learntoption or
    // ### OptionBase::tuningoption. Another possible flag to be combined with
    // ### is OptionBase::nosave

    declareOption(ol, "initial_splitter", &StackedSplitter::initial_splitter, OptionBase::buildoption,
                  "The initial splitter to be used.");

    declareOption(ol, "top_splitters", &StackedSplitter::top_splitters, OptionBase::buildoption,
                  "The splitters applied on each set of the initial splitter. One must provide\n"
                  "initial_splitters->nSetsPerSplit() splitters (*0 means no splitter).");

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

Here is the call graph for this function:

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

Reimplemented from PLearn::Splitter.

Definition at line 109 of file StackedSplitter.h.

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

Reimplemented from PLearn::Splitter.

Definition at line 63 of file StackedSplitter.cc.

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

Reimplemented from PLearn::Object.

Definition at line 63 of file StackedSplitter.cc.

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

Reimplemented from PLearn::Object.

Definition at line 63 of file StackedSplitter.cc.

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

Reimplemented from PLearn::Object.

Definition at line 63 of file StackedSplitter.cc.

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

Returns split number i.

Implements PLearn::Splitter.

Definition at line 126 of file StackedSplitter.cc.

References PLearn::TVec< T >::append(), i, initial_splitter, last_k_init, last_split_init, PLearn::TVec< T >::length(), and top_splitters.

{
    TVec<VMat> result;
    int k_init = k / top_splitters[0]->nsplits();
    int k_top = k % top_splitters[0]->nsplits();
    if (k_init != last_k_init) {
        // We need to recompute the split given by the initial splitter.
        last_split_init = initial_splitter->getSplit(k_init);
        last_k_init = k_init;
        // Assign each set to its top splitter.
        for (int i = 0; i < top_splitters.length(); i++) {
            top_splitters[i]->setDataSet(last_split_init[i]);
        }
    }
    for (int i = 0; i < top_splitters.length(); i++) {
        result->append(top_splitters[i]->getSplit(k_top));
    }
    return result;
}

Here is the call graph for this function:

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

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::Splitter.

Definition at line 149 of file StackedSplitter.cc.

References PLearn::Splitter::makeDeepCopyFromShallowCopy(), and PLERROR.

{
    inherited::makeDeepCopyFromShallowCopy(copies);

    // ### Call deepCopyField on all "pointer-like" fields
    // ### that you wish to be deepCopied rather than
    // ### shallow-copied.
    // ### ex:
    // deepCopyField(trainvec, copies);

    // ### Remove this line when you have fully implemented this method.
    PLERROR("StackedSplitter::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!");
}

Here is the call graph for this function:

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

Returns the number of sets per split.

Implements PLearn::Splitter.

Definition at line 166 of file StackedSplitter.cc.

References i, PLearn::TVec< T >::length(), and top_splitters.

{
    int count = 0;
    for (int i = 0; i < top_splitters.length(); i++) {
        count += top_splitters[i]->nSetsPerSplit();
    }
    return count;
}

Here is the call graph for this function:

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

Returns the number of available different "splits".

Implements PLearn::Splitter.

Definition at line 178 of file StackedSplitter.cc.

References initial_splitter, and top_splitters.

Referenced by build_().

{
    return initial_splitter->nsplits() * top_splitters[0]->nsplits();
}

Here is the caller graph for this function:

void PLearn::StackedSplitter::setDataSet ( VMat  the_dataset) [virtual]

Overridden to forward to the initial splitter.

Reimplemented from PLearn::Splitter.

Definition at line 186 of file StackedSplitter.cc.

References initial_splitter, and last_k_init.

                                                 {
    initial_splitter->setDataSet(the_dataset);
    // Reset 'last_k_init' since the dataset has changed.
    last_k_init = -1;
}

Member Data Documentation

Reimplemented from PLearn::Splitter.

Definition at line 109 of file StackedSplitter.h.

Definition at line 78 of file StackedSplitter.h.

Referenced by build_(), declareOptions(), getSplit(), nsplits(), and setDataSet().

The last split asked to the initial splitter.

Definition at line 67 of file StackedSplitter.h.

Referenced by getSplit(), and setDataSet().

The last split returned by the initial splitter.

Definition at line 70 of file StackedSplitter.h.

Referenced by getSplit().

Definition at line 79 of file StackedSplitter.h.

Referenced by build_(), declareOptions(), getSplit(), nSetsPerSplit(), and nsplits().


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