PLearn 0.1
|
#include <AddMissingVMatrix.h>
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< Dictionary > | getDictionary (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 OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual AddMissingVMatrix * | deepCopy (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 PPath & | declaringFile () |
Public Attributes | |
bool | add_missing_target |
real | missing_prop |
int | only_on_first |
int32_t | seed |
TVec< int > | missing_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< PRandom > | random_gen |
Private Types | |
typedef SourceVMatrix | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
Definition at line 52 of file AddMissingVMatrix.h.
typedef SourceVMatrix PLearn::AddMissingVMatrix::inherited [private] |
Reimplemented from PLearn::SourceVMatrix.
Definition at line 57 of file AddMissingVMatrix.h.
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) {}
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.
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_(); }
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(); }
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); }
static const PPath& PLearn::AddMissingVMatrix::declaringFile | ( | ) | [inline, static] |
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_.
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; } } } }
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.
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_.
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_.
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_.
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_.
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.
{ inherited::makeDeepCopyFromShallowCopy(copies); deepCopyField(random_gen, copies); deepCopyField(missing_values_columns, copies); }
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().
PP<PRandom> PLearn::AddMissingVMatrix::random_gen [protected] |
Definition at line 61 of file AddMissingVMatrix.h.
Referenced by build_(), getNewRow(), and makeDeepCopyFromShallowCopy().
int32_t PLearn::AddMissingVMatrix::seed |
Definition at line 76 of file AddMissingVMatrix.h.
Referenced by build_(), and declareOptions().