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

#include <DisregardRowsVMatrix.h>

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

List of all members.

Public Member Functions

 DisregardRowsVMatrix ()
 Default constructor.
 DisregardRowsVMatrix (VMat source)
 Alternative constructor that takes a VMat and immediately finds missing values.
virtual void build ()
 Simply calls inherited::build() then build_().
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 DisregardRowsVMatrixdeepCopy (CopiesMap &copies) const

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

TVec< string > _inspected_fieldnames
Vec _disregard_values
bool _disregard_missings
int _maximum_length

Static Public Attributes

static StaticInitializer _static_initializer_

Protected Member Functions

virtual void inferIndices ()
 Fills the inherited::indices vector.

Static Protected Member Functions

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

Protected Attributes

TVec< int_inspected_columns
 Stores the inspected_fieldnames column indices.

Private Types

typedef SelectRowsVMatrix inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

A vmat that disregard rows containing any specified values.

Typically, this vmat is used to select the rows of the source vmat which do not contain missing values. However, this behaviour can be changed by setting the 'disregard_missings' flag to false and by providing any real value list through 'disregard_values'.

The default behavior of the class is to inspect all columns of the underlying vmat, but one may specify a subset of the source's fieldnames to restrict the inspection.

Definition at line 63 of file DisregardRowsVMatrix.h.


Member Typedef Documentation

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 66 of file DisregardRowsVMatrix.h.


Constructor & Destructor Documentation

PLearn::DisregardRowsVMatrix::DisregardRowsVMatrix ( )

Default constructor.

Definition at line 66 of file DisregardRowsVMatrix.cc.

PLearn::DisregardRowsVMatrix::DisregardRowsVMatrix ( VMat  source)

Alternative constructor that takes a VMat and immediately finds missing values.

Definition at line 72 of file DisregardRowsVMatrix.cc.

References build(), PLASSERT, and PLearn::SourceVMatrix::source.

    : inherited(),
      _disregard_missings(true),
      _maximum_length(-1)
{
    PLASSERT( the_source );
    source = the_source;
    build();
}

Here is the call graph for this function:


Member Function Documentation

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

Declares name and deepCopy methods.

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 61 of file DisregardRowsVMatrix.cc.

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 61 of file DisregardRowsVMatrix.cc.

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 61 of file DisregardRowsVMatrix.cc.

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 61 of file DisregardRowsVMatrix.cc.

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 61 of file DisregardRowsVMatrix.cc.

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 61 of file DisregardRowsVMatrix.cc.

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

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 132 of file DisregardRowsVMatrix.cc.

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

Referenced by DisregardRowsVMatrix().

Here is the call graph for this function:

Here is the caller graph for this function:

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

This does the actual building.

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 143 of file DisregardRowsVMatrix.cc.

References _inspected_columns, _inspected_fieldnames, PLearn::SelectRowsVMatrix::build(), c, PLearn::endl(), PLearn::SelectRowsVMatrix::indices, inferIndices(), PLearn::TVec< T >::isEmpty(), PLearn::VMat::length(), PLearn::TVec< T >::length(), PLearn::TVec< T >::resize(), PLearn::SourceVMatrix::source, PLearn::VMatrix::updateMtime(), and PLearn::VMatrix::width().

Referenced by build().

{
    if ( !source )
        return;

    updateMtime(source);
    /* Option: inspected_fieldnames */

    // Default: All fields are inspected.
    if ( _inspected_fieldnames.isEmpty() )
    {
        _inspected_columns.resize( width() );
        for ( int c=0; c < width(); c++ )
            _inspected_columns[c] = c;
    }

    // Get the column indices of the fields to inspect.
    else
    {
        _inspected_columns.resize( _inspected_fieldnames.length() );
        for ( int f=0; f < _inspected_fieldnames.length(); f++ )
            _inspected_columns[f] =
                source->fieldIndex( _inspected_fieldnames[f] );
    }

    inferIndices();

    DBG_MODULE_LOG
        << "Out of " << source.length() << " rows, "
        << "kept " << indices.length() << " rows"
        << endl;

    // Calls back the inherited build now that the row indices are known
    inherited::build();
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 61 of file DisregardRowsVMatrix.cc.

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

Declares this class' options.

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 88 of file DisregardRowsVMatrix.cc.

References _disregard_missings, _disregard_values, _inspected_fieldnames, _maximum_length, PLearn::OptionBase::buildoption, PLearn::declareOption(), and PLearn::SelectRowsVMatrix::declareOptions().

{
    declareOption(
        ol, "inspected_fieldnames", &DisregardRowsVMatrix::_inspected_fieldnames,
        OptionBase::buildoption,
        "Field names of the source vmat for which a triggering value (see the\n"
        "disregard_values option) cause this vmat to neglect a row.\n"
        "\n"
        "If empty, all source's fieldnames are used.\n"
        "\n"
        "Default: []." );

    declareOption(
        ol, "disregard_missings", &DisregardRowsVMatrix::_disregard_missings,
        OptionBase::buildoption,
        "Should missing values cause a row to be neglected.\n"
        "\n"
        "Default: 1 (True)" );

    declareOption(
        ol, "disregard_values", &DisregardRowsVMatrix::_disregard_values,
        OptionBase::buildoption,
        "If any of these values is encountered in any column designated in\n"
        "inspected_fieldnames, the whole row is disregarded.\n"
        "\n"
        "Default: [ ]" );

    declareOption(
        ol, "maximum_length", &DisregardRowsVMatrix::_maximum_length,
        OptionBase::buildoption,
        "If positive, only the last 'maximum_length' rows kept from the source\n"
        "vmat will be considered, all other rows being disregarded.\n"
        "\n"
        "Default: -1. " );

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

Here is the call graph for this function:

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 141 of file DisregardRowsVMatrix.h.

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 61 of file DisregardRowsVMatrix.cc.

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 61 of file DisregardRowsVMatrix.cc.

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 61 of file DisregardRowsVMatrix.cc.

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

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 61 of file DisregardRowsVMatrix.cc.

void PLearn::DisregardRowsVMatrix::inferIndices ( ) [protected, virtual]

Fills the inherited::indices vector.

Definition at line 181 of file DisregardRowsVMatrix.cc.

References _disregard_missings, _disregard_values, _inspected_columns, _maximum_length, PLearn::TVec< T >::append(), c, PLearn::TVec< T >::contains(), PLearn::SelectRowsVMatrix::indices, PLearn::is_missing(), PLearn::TVec< T >::length(), PLearn::VMat::length(), PLearn::TVec< T >::resize(), PLearn::SourceVMatrix::source, and PLearn::TVec< T >::subVec().

Referenced by build_().

{
    if ( !source )
        return;

    indices.resize( 0, source.length() );
    for ( int r=0; r < source.length(); r++ )
    {
        bool disregard_row = false;
        for ( int inspected=0;
              inspected < _inspected_columns.length() && !disregard_row;
              ++inspected )
        {
            int c = _inspected_columns[ inspected ];
            if( (_disregard_missings && is_missing( source(r,c) ))
                || _disregard_values.contains( source(r,c) ) )
                disregard_row = true;
        }
        if ( !disregard_row )
            indices.append( r );
    }

    if ( _maximum_length > 0 && indices.length() > _maximum_length )
        indices =
            indices.subVec( indices.length()-_maximum_length, _maximum_length );
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 213 of file DisregardRowsVMatrix.cc.

References _disregard_values, _inspected_columns, _inspected_fieldnames, PLearn::deepCopyField(), and PLearn::SelectRowsVMatrix::makeDeepCopyFromShallowCopy().

Here is the call graph for this function:


Member Data Documentation

Should missing values cause a row to be neglected.

Default: 1 (True)

Definition at line 111 of file DisregardRowsVMatrix.h.

Referenced by declareOptions(), and inferIndices().

If any of these values is encountered in any column designated in inspected_fieldnames, the whole row is disregarded.

Default: [ ]

Definition at line 104 of file DisregardRowsVMatrix.h.

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

Stores the inspected_fieldnames column indices.

Definition at line 74 of file DisregardRowsVMatrix.h.

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

Field names of the source vmat for which a triggering value (see the disregard_values option) cause this vmat to neglect a row.

If empty, all source's fieldnames are used.

Default: [].

Definition at line 96 of file DisregardRowsVMatrix.h.

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

If positive, only the last 'maximum_length' rows kept from the source vmat will be considered, all other rows being disregarded.

Default: -1.

Definition at line 119 of file DisregardRowsVMatrix.h.

Referenced by declareOptions(), and inferIndices().

Reimplemented from PLearn::SelectRowsVMatrix.

Definition at line 141 of file DisregardRowsVMatrix.h.


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