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

#include <UniformizeVMatrix.h>

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

List of all members.

Public Member Functions

 UniformizeVMatrix ()
 Default constructor.
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual UniformizeVMatrixdeepCopy (CopiesMap &copies) const
virtual void build ()
 Simply calls inherited::build() then build_().
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.

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

real max
real min
int nquantiles
real threshold_ratio
VMat train_source
bool uniformize_input
bool uniformize_target
bool uniformize_weight
bool uniformize_extra

Static Public Attributes

static StaticInitializer _static_initializer_

Protected Member Functions

virtual void getNewRow (int i, const Vec &v) const
 Fill the vector 'v' with the content of the i-th row.

Static Protected Member Functions

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

Protected Attributes

TVec< intfeatures_to_uniformize
 List of the source's features that need to be uniformized.
PP< UniformizeLearneruniformize_learner
 The underlying learner that performs the actual normalization.
PP< PLearnerOutputVMatrixuniformized_source
 The data that this VMatrix views, i.e.

Private Types

typedef SourceVMatrix inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

Definition at line 49 of file UniformizeVMatrix.h.


Member Typedef Documentation

Reimplemented from PLearn::SourceVMatrix.

Definition at line 51 of file UniformizeVMatrix.h.


Constructor & Destructor Documentation

PLearn::UniformizeVMatrix::UniformizeVMatrix ( )

Default constructor.

Definition at line 59 of file UniformizeVMatrix.cc.

                                    :
    max(1),
    min(0),
    nquantiles(1000),
    threshold_ratio(10),
    uniformize_input(true),
    uniformize_target(false),
    uniformize_weight(false),
    uniformize_extra(false),
    uniformize_learner( new UniformizeLearner() ),
    uniformized_source( new PLearnerOutputVMatrix() )
{}

Member Function Documentation

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

Declares name and deepCopy methods.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 54 of file UniformizeVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 54 of file UniformizeVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 54 of file UniformizeVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 54 of file UniformizeVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 54 of file UniformizeVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 54 of file UniformizeVMatrix.cc.

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

Simply calls inherited::build() then build_().

Reimplemented from PLearn::SourceVMatrix.

Definition at line 127 of file UniformizeVMatrix.cc.

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

Here is the call graph for this function:

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

This does the actual building.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 136 of file UniformizeVMatrix.cc.

References PLearn::TVec< T >::append(), features_to_uniformize, max, min, nquantiles, PLASSERT, PLearn::TVec< T >::resize(), PLearn::SourceVMatrix::setMetaInfoFromSource(), PLearn::SourceVMatrix::source, train_source, uniformize_extra, uniformize_input, uniformize_learner, uniformize_target, uniformize_weight, uniformized_source, and PLearn::VMat::width().

Referenced by build().

{
    if (!source)
        return;

    PLASSERT( max >= min );

    if (train_source) {
        PLASSERT( train_source->width() == source->width() );
        PLASSERT( train_source->inputsize()  == source->inputsize() &&
                train_source->targetsize() == source->targetsize() &&
                train_source->weightsize() == source->weightsize() &&
                train_source->extrasize()  == source->extrasize() );
    }

    VMat the_source = train_source ? train_source : source;

    PLASSERT( the_source->inputsize() >= 0 && the_source->targetsize() >= 0 &&
            the_source->weightsize() >= 0 && the_source->extrasize() >= 0 );

    // Find which dimensions to uniformize.
    features_to_uniformize.resize(0);
    int col = 0;
    if (uniformize_input)
        features_to_uniformize.append(
                TVec<int>(col, col + the_source->inputsize() - 1, 1));
    col += the_source->inputsize();
    if (uniformize_target)
        features_to_uniformize.append(
                TVec<int>(col, col + the_source->targetsize() - 1, 1));
    col += the_source->targetsize();
    if (uniformize_weight)
        features_to_uniformize.append(
                TVec<int>(col, col + the_source->weightsize() - 1, 1));
    col += the_source->weightsize();
    if (uniformize_extra)
        features_to_uniformize.append(
                TVec<int>(col, col + the_source->extrasize() - 1, 1));
    col += the_source->extrasize();

    // Build the UniformizeLearner and associated PLearnerOutputVMatrix.
    uniformize_learner->forget();
    uniformize_learner->which_fieldnums = features_to_uniformize;
    uniformize_learner->nquantiles = this->nquantiles;
    uniformize_learner->build();
    uniformize_learner->setTrainingSet(the_source);
    uniformize_learner->train();
    TVec< PP<PLearner> > learners;
    learners.append((UniformizeLearner*) uniformize_learner);
    uniformized_source->learners = learners;
    uniformized_source->source = this->source;
    uniformized_source->build();

    // Obtain meta information from source.
    setMetaInfoFromSource();
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 54 of file UniformizeVMatrix.cc.

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

Declares the class options.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 75 of file UniformizeVMatrix.cc.

References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::SourceVMatrix::declareOptions(), max, min, nquantiles, threshold_ratio, train_source, uniformize_extra, uniformize_input, uniformize_target, and uniformize_weight.

{
    declareOption(ol, "min", &UniformizeVMatrix::min,
                             OptionBase::buildoption,
        "The lower bound of the [min,max] interval values are mapped to.");

    declareOption(ol, "max", &UniformizeVMatrix::max,
                             OptionBase::buildoption,
        "The upper bound of the [min,max] interval values are mapped to.");

    declareOption(ol, "threshold_ratio", &UniformizeVMatrix::threshold_ratio,
                                         OptionBase::buildoption,
        "A source's feature will be uniformized when the following holds:\n"
        "(max - min) / stddev > threshold_ratio.");

    declareOption(ol, "uniformize_input",
                  &UniformizeVMatrix::uniformize_input,
                  OptionBase::buildoption,
        "Whether or not to uniformize the input part.");

    declareOption(ol, "uniformize_target",
                  &UniformizeVMatrix::uniformize_target,
                  OptionBase::buildoption,
        "Whether or not to uniformize the target part.");

    declareOption(ol, "uniformize_weight",
                  &UniformizeVMatrix::uniformize_weight,
                  OptionBase::buildoption,
        "Whether or not to uniformize the weight part.");

    declareOption(ol, "uniformize_extra",
                  &UniformizeVMatrix::uniformize_extra,
                  OptionBase::buildoption,
        "Whether or not to uniformize the extra part.");

    declareOption(ol, "nquantiles",
                  &UniformizeVMatrix::nquantiles,
                  OptionBase::buildoption,
        "Number of intervals used to divide the sorted values.");

    declareOption(ol, "train_source", &UniformizeVMatrix::train_source,
                                      OptionBase::buildoption,
        "An optional VMat that will be used instead of 'source' to compute\n"
        "the transformation parameters from the distribution statistics.");

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

Here is the call graph for this function:

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 79 of file UniformizeVMatrix.h.

:

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 54 of file UniformizeVMatrix.cc.

void PLearn::UniformizeVMatrix::getNewRow ( int  i,
const Vec v 
) const [protected, virtual]

Fill the vector 'v' with the content of the i-th row.

v is assumed to be the right size. ### This function must be overridden in your class

Reimplemented from PLearn::SourceVMatrix.

Definition at line 196 of file UniformizeVMatrix.cc.

References features_to_uniformize, j, PLearn::TVec< T >::length(), max, min, PLASSERT, uniformize_learner, and uniformized_source.

{
    PLASSERT( uniformize_learner->stage > 0 );
    uniformized_source->getRow(i, v);
    for (int j = 0; j < features_to_uniformize.length(); j++)
        v[j] = min + (max - min) * v[j];
}

Here is the call graph for this function:

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 54 of file UniformizeVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 54 of file UniformizeVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 54 of file UniformizeVMatrix.cc.

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

Member Data Documentation

Reimplemented from PLearn::SourceVMatrix.

Definition at line 79 of file UniformizeVMatrix.h.

List of the source's features that need to be uniformized.

Definition at line 91 of file UniformizeVMatrix.h.

Referenced by build_(), getNewRow(), and makeDeepCopyFromShallowCopy().

Definition at line 56 of file UniformizeVMatrix.h.

Referenced by build_(), declareOptions(), and getNewRow().

Definition at line 57 of file UniformizeVMatrix.h.

Referenced by build_(), declareOptions(), and getNewRow().

Definition at line 58 of file UniformizeVMatrix.h.

Referenced by build_(), and declareOptions().

Definition at line 59 of file UniformizeVMatrix.h.

Referenced by declareOptions().

Definition at line 60 of file UniformizeVMatrix.h.

Referenced by build_(), declareOptions(), and makeDeepCopyFromShallowCopy().

Definition at line 64 of file UniformizeVMatrix.h.

Referenced by build_(), and declareOptions().

Definition at line 61 of file UniformizeVMatrix.h.

Referenced by build_(), and declareOptions().

The underlying learner that performs the actual normalization.

Definition at line 101 of file UniformizeVMatrix.h.

Referenced by build_(), getNewRow(), and makeDeepCopyFromShallowCopy().

Definition at line 62 of file UniformizeVMatrix.h.

Referenced by build_(), and declareOptions().

Definition at line 63 of file UniformizeVMatrix.h.

Referenced by build_(), and declareOptions().

The data that this VMatrix views, i.e.

the uniformized version of its source.

Definition at line 105 of file UniformizeVMatrix.h.

Referenced by build_(), getNewRow(), and makeDeepCopyFromShallowCopy().


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