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

#include <AddMissingVMatrix.h>

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

List of all members.

Public Member Functions

 AddMissingVMatrix ()
 Default constructor.
virtual void build ()
 Simply calls inherited::build() then build_().
virtual void makeDeepCopyFromShallowCopy (CopiesMap &copies)
 Transforms a shallow copy into a deep copy.
virtual PP< DictionarygetDictionary (int col) const
 Return the Dictionary object for a certain field, or a null pointer if there isn't one.
virtual void getValues (int row, int col, Vec &values) const
 Gives the possible values for a certain field in the VMatrix.
virtual void getValues (const Vec &input, int col, Vec &values) const
 Gives the possible values of a certain field (column) given the input.
virtual string getValString (int col, real val) const
 Returns the string associated with value val for field# col.
virtual real getStringVal (int col, const string &str) const
 Returns value associated with a string (or MISSING_VALUE if there's no association for this string).
virtual string classname () const
virtual OptionListgetOptionList () const
virtual OptionMapgetOptionMap () const
virtual RemoteMethodMapgetRemoteMethodMap () const
virtual AddMissingVMatrixdeepCopy (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

bool add_missing_target
real missing_prop
int only_on_first
int32_t seed
TVec< intmissing_values_columns
 Columns which will be filled with missing values.

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 this class' options.

Protected Attributes

PP< PRandomrandom_gen

Private Types

typedef SourceVMatrix inherited

Private Member Functions

void build_ ()
 This does the actual building.

Detailed Description

Definition at line 52 of file AddMissingVMatrix.h.


Member Typedef Documentation

Reimplemented from PLearn::SourceVMatrix.

Definition at line 57 of file AddMissingVMatrix.h.


Constructor & Destructor Documentation

PLearn::AddMissingVMatrix::AddMissingVMatrix ( )

Default constructor.

Definition at line 52 of file AddMissingVMatrix.cc.

                                    :
    random_gen(new PRandom()),
    add_missing_target(true),
    missing_prop(0),
    only_on_first(-1),
    seed(-1)
{}

Member Function Documentation

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

Declares name and deepCopy methods.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 69 of file AddMissingVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 69 of file AddMissingVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 69 of file AddMissingVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 69 of file AddMissingVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 69 of file AddMissingVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 69 of file AddMissingVMatrix.cc.

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

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 100 of file AddMissingVMatrix.cc.

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

Referenced by PLearn::add_missing().

{
  // ### Nothing to add here, simply calls build_
  inherited::build();
  build_();
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

This does the actual building.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 110 of file AddMissingVMatrix.cc.

References PLearn::fast_exact_is_equal(), PLearn::TVec< T >::isEmpty(), missing_prop, missing_values_columns, PLERROR, random_gen, seed, PLearn::SourceVMatrix::setMetaInfoFromSource(), PLearn::SourceVMatrix::source, and PLearn::VMatrix::updateMtime().

Referenced by build().

{
    updateMtime(source);
    // Ensure we are not using both a missing values proportion and
    // user-specified missing columns.
    if (!fast_exact_is_equal(missing_prop, 0) &&
            !missing_values_columns.isEmpty())
        PLERROR("In AddMissingVMatrix::build_ - You may only use one of these "
                "two options: 'missing_prop' or 'missing_values_columns'");

    random_gen->manual_seed(seed);
    setMetaInfoFromSource();
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 69 of file AddMissingVMatrix.cc.

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

Declares this class' options.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 74 of file AddMissingVMatrix.cc.

References add_missing_target, PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::SourceVMatrix::declareOptions(), missing_prop, missing_values_columns, only_on_first, and seed.

{
  declareOption(ol, "missing_prop", &AddMissingVMatrix::missing_prop, OptionBase::buildoption,
      "Percentage of missing values.");

  declareOption(ol, "only_on_first", &AddMissingVMatrix::only_on_first, OptionBase::buildoption,
      "Only add missing values in the first 'only_on_first' samples (ignored if < 0).");

  declareOption(ol, "seed", &AddMissingVMatrix::seed, OptionBase::buildoption,
      "Random numbers seed.");

  declareOption(ol, "missing_values_columns", &AddMissingVMatrix::missing_values_columns, OptionBase::buildoption,
      "Columns which will be filled with missing values.");

    declareOption(ol, "add_missing_target",
                  &AddMissingVMatrix::add_missing_target,
                  OptionBase::buildoption,
        "Whether or not to add missing values in the target part.");

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

Here is the call graph for this function:

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 127 of file AddMissingVMatrix.h.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 69 of file AddMissingVMatrix.cc.

PP< Dictionary > PLearn::AddMissingVMatrix::getDictionary ( int  col) const [virtual]

Return the Dictionary object for a certain field, or a null pointer if there isn't one.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 181 of file AddMissingVMatrix.cc.

References PLERROR, PLearn::SourceVMatrix::source, and PLearn::VMatrix::width_.

{
#ifdef BOUNDCHECK
    if(col>=width_)
        PLERROR("access out of bound. Width=%i accessed col=%i",width_,col);
#endif
    return source->getDictionary(col);
}
void PLearn::AddMissingVMatrix::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.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 127 of file AddMissingVMatrix.cc.

References add_missing_target, j, PLearn::TVec< T >::length(), missing_prop, MISSING_VALUE, missing_values_columns, n, only_on_first, random_gen, and PLearn::SourceVMatrix::source.

{
  source->getRow(i, v);
  if (only_on_first >= 0 && i >= only_on_first)
    return;
  int n = v.length();

  if (missing_values_columns.length()>0)
  {
      for (int j = 0; j < missing_values_columns.length(); j++)
          v[missing_values_columns[j]] = MISSING_VALUE;
  }
  else   
  {
      for (int j = 0; j < n; j++) {
          bool is_target = (j >= source->inputsize() &&
                            j < source->inputsize() + source->targetsize());
          if ((add_missing_target || !is_target) &&
          random_gen->uniform_sample() < missing_prop)
          {
              v[j] = MISSING_VALUE;
          }
      }
  }
}

Here is the call graph for this function:

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 69 of file AddMissingVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 69 of file AddMissingVMatrix.cc.

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

Reimplemented from PLearn::SourceVMatrix.

Definition at line 69 of file AddMissingVMatrix.cc.

real PLearn::AddMissingVMatrix::getStringVal ( int  col,
const string &  str 
) const [virtual]

Returns value associated with a string (or MISSING_VALUE if there's no association for this string).

Reimplemented from PLearn::VMatrix.

Definition at line 163 of file AddMissingVMatrix.cc.

References PLERROR, PLearn::SourceVMatrix::source, and PLearn::VMatrix::width_.

{
#ifdef BOUNDCHECK
    if(col>=width_)
        PLERROR("access out of bound. Width=%i accessed col=%i",width_,col);
#endif
    return source->getStringVal(col,str);
}
string PLearn::AddMissingVMatrix::getValString ( int  col,
real  val 
) const [virtual]

Returns the string associated with value val for field# col.

Or returns "" if no string is associated.

Reimplemented from PLearn::VMatrix.

Definition at line 172 of file AddMissingVMatrix.cc.

References PLERROR, PLearn::SourceVMatrix::source, and PLearn::VMatrix::width_.

{
#ifdef BOUNDCHECK
    if(col>=width_)
        PLERROR("access out of bound. Width=%i accessed col=%i",width_,col);
#endif
    return source->getValString(col,val);
}
void PLearn::AddMissingVMatrix::getValues ( int  row,
int  col,
Vec values 
) const [virtual]

Gives the possible values for a certain field in the VMatrix.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 191 of file AddMissingVMatrix.cc.

References PLERROR, PLearn::SourceVMatrix::source, and PLearn::VMatrix::width_.

{
#ifdef BOUNDCHECK
    if(col>=width_)
        PLERROR("access out of bound. Width=%i accessed col=%i",width_,col);
#endif
    source->getValues(row,col,values);
}
void PLearn::AddMissingVMatrix::getValues ( const Vec input,
int  col,
Vec values 
) const [virtual]

Gives the possible values of a certain field (column) given the input.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 200 of file AddMissingVMatrix.cc.

References PLERROR, PLearn::SourceVMatrix::source, and PLearn::VMatrix::width_.

{
#ifdef BOUNDCHECK
    if(col>=width_)
        PLERROR("access out of bound. Width=%i accessed col=%i",width_,col);
#endif
    source->getValues(input, col,values);
}
void PLearn::AddMissingVMatrix::makeDeepCopyFromShallowCopy ( CopiesMap copies) [virtual]

Transforms a shallow copy into a deep copy.

Reimplemented from PLearn::SourceVMatrix.

Definition at line 156 of file AddMissingVMatrix.cc.

References PLearn::deepCopyField(), PLearn::SourceVMatrix::makeDeepCopyFromShallowCopy(), missing_values_columns, and random_gen.

Here is the call graph for this function:


Member Data Documentation

Reimplemented from PLearn::SourceVMatrix.

Definition at line 127 of file AddMissingVMatrix.h.

Definition at line 73 of file AddMissingVMatrix.h.

Referenced by declareOptions(), and getNewRow().

Definition at line 74 of file AddMissingVMatrix.h.

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

Columns which will be filled with missing values.

Definition at line 78 of file AddMissingVMatrix.h.

Referenced by PLearn::add_missing(), build_(), declareOptions(), getNewRow(), and makeDeepCopyFromShallowCopy().

Definition at line 75 of file AddMissingVMatrix.h.

Referenced by declareOptions(), and getNewRow().

Definition at line 61 of file AddMissingVMatrix.h.

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

Definition at line 76 of file AddMissingVMatrix.h.

Referenced by build_(), and declareOptions().


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