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::BinSplitter Class Reference

#include <BinSplitter.h>

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

List of all members.

Public Member Functions

 BinSplitter ()
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 BinSplitterdeepCopy (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.
virtual void setDataSet (VMat the_dataset)
 Sets the dataset on which the splits are to be based.

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< Binnerbinner
int column
string column_spec

Static Public Attributes

static StaticInitializer _static_initializer_

Static Protected Member Functions

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

Protected Attributes

TVec< TVec< int > > bins
 Store the bins computed by the Binner.

Private Types

typedef Splitter inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

Definition at line 52 of file BinSplitter.h.


Member Typedef Documentation

Reimplemented from PLearn::Splitter.

Definition at line 57 of file BinSplitter.h.


Constructor & Destructor Documentation

PLearn::BinSplitter::BinSplitter ( )

Definition at line 53 of file BinSplitter.cc.

    : column(0),
      column_spec("")
{
}

Member Function Documentation

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

Declares name and deepCopy methods.

Reimplemented from PLearn::Splitter.

Definition at line 62 of file BinSplitter.cc.

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

Reimplemented from PLearn::Splitter.

Definition at line 62 of file BinSplitter.cc.

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

Reimplemented from PLearn::Splitter.

Definition at line 62 of file BinSplitter.cc.

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

Reimplemented from PLearn::Splitter.

Definition at line 62 of file BinSplitter.cc.

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

Reimplemented from PLearn::Object.

Definition at line 62 of file BinSplitter.cc.

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

Reimplemented from PLearn::Splitter.

Definition at line 62 of file BinSplitter.cc.

void PLearn::BinSplitter::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 96 of file BinSplitter.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::Object.

Definition at line 89 of file BinSplitter.cc.

Referenced by build().

{
}

Here is the caller graph for this function:

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

Reimplemented from PLearn::Object.

Definition at line 62 of file BinSplitter.cc.

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

Declares this class' options.

Reimplemented from PLearn::Splitter.

Definition at line 67 of file BinSplitter.cc.

References binner, PLearn::OptionBase::buildoption, column, column_spec, PLearn::declareOption(), and PLearn::Splitter::declareOptions().

{
    declareOption(ol, "binner", &BinSplitter::binner, OptionBase::buildoption,
                  "The binner used to create the bins.");

    declareOption(ol, "column", &BinSplitter::column, OptionBase::buildoption,
                  "The column used to defined the bins.");

    declareOption(ol, "column_spec", &BinSplitter::column_spec, OptionBase::buildoption,
                  "Alternatively, this option can be used to override the 'column' option:\n"
                  " - 'first_input' : the first input column\n"
                  " - 'last_input'  : the last input column\n"
                  " - 'first_target': the first target column\n"
                  " - 'last_target' : the last target column");

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

Here is the call graph for this function:

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

Reimplemented from PLearn::Splitter.

Definition at line 108 of file BinSplitter.h.

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

Reimplemented from PLearn::Splitter.

Definition at line 62 of file BinSplitter.cc.

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

Reimplemented from PLearn::Object.

Definition at line 62 of file BinSplitter.cc.

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

Reimplemented from PLearn::Object.

Definition at line 62 of file BinSplitter.cc.

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

Reimplemented from PLearn::Object.

Definition at line 62 of file BinSplitter.cc.

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

Returns split number i.

Implements PLearn::Splitter.

Definition at line 135 of file BinSplitter.cc.

References bins, PLearn::Splitter::dataset, i, PLearn::TVec< T >::length(), and nSetsPerSplit().

{
    TVec<VMat> sets(nSetsPerSplit());
    for (int i = 0; i < sets.length(); i++) {
        sets[i] = new SelectRowsVMatrix(dataset, bins[i]);
    }
    return sets;
}

Here is the call graph for this function:

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

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::Splitter.

Definition at line 102 of file BinSplitter.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("BinSplitter::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!");
}

Here is the call graph for this function:

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

Returns the number of sets per split.

Implements PLearn::Splitter.

Definition at line 127 of file BinSplitter.cc.

References binner.

Referenced by getSplit().

{
    return binner->nBins();
}

Here is the caller graph for this function:

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

Returns the number of available different "splits".

Implements PLearn::Splitter.

Definition at line 119 of file BinSplitter.cc.

{
    return 1;
}
void PLearn::BinSplitter::setDataSet ( VMat  the_dataset) [virtual]

Sets the dataset on which the splits are to be based.

Reimplemented from PLearn::Splitter.

Definition at line 147 of file BinSplitter.cc.

References binner, bins, PLearn::VMat::column(), column, column_spec, PLERROR, PLearn::Splitter::setDataSet(), PLearn::VMat::toMat(), PLearn::TMat< T >::toVec(), and PLearn::VMat::width().

                                             {
    inherited::setDataSet(the_dataset);
    int col = column;
    if (column_spec != "") {
        if (column_spec == "first_input")
            col = 0;
        else if (column_spec == "last_input")
            col = the_dataset->inputsize() - 1;
        else if (column_spec == "first_target")
            col = the_dataset->inputsize();
        else if (column_spec == "last_target")
            col = the_dataset->inputsize() + the_dataset->targetsize() - 1;
        else
            PLERROR("In BinSplitter::setDataSet - Wrong value for 'column_spec'");
        if (col < 0)
            PLERROR("In BinSplitter::setDataSet - Found a negative column, check the dataset sizes are correctly defined");
    }
    else if (column >= the_dataset->width())
        PLERROR("In BinSplitter::setDataSet - The column number is higher than available");
    Vec col_vec = the_dataset.column(col)->toMat().toVec();
    if (!binner)
        PLERROR("In BinSplitter::setDataSet - You must provide a binner first.");
    bins = binner->getBins(col_vec);
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::Splitter.

Definition at line 108 of file BinSplitter.h.

Definition at line 75 of file BinSplitter.h.

Referenced by declareOptions(), nSetsPerSplit(), and setDataSet().

Store the bins computed by the Binner.

Definition at line 67 of file BinSplitter.h.

Referenced by getSplit(), and setDataSet().

Definition at line 76 of file BinSplitter.h.

Referenced by declareOptions(), and setDataSet().

Definition at line 77 of file BinSplitter.h.

Referenced by declareOptions(), and setDataSet().


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