|
PLearn 0.1
|
A field that recodes its source field according to an OutputCoder object. More...
#include <SDBVMat.h>


Public Member Functions | |
| SDBVMFieldDiscrete (SDBVMSource source, int num_classes=0, real missing_values_mapping=MISSING_VALUE, SDBVMOutputCoding oc=SDBVMNumeric, VMField::FieldType ft=VMField::DiscrGeneral) | |
| SDBVMFieldDiscrete (SDBVMSource source, SDBVMOutputCoder *oc, int num_classes=0, real missing_values_mapping=MISSING_VALUE, VMField::FieldType ft=VMField::DiscrGeneral) | |
| Version of the constructor that takes an OutputCoder object. | |
| virtual void | convertField (const SDBWithStats &sdb, const Row &row, const Vec &output) const |
| virtual int | fieldWidth () const |
| Width that the field occupies in the VMat. | |
| virtual SDBVMOutputCoding | getOutputCoding () const |
| virtual real | getDiscreteValue (const SDBWithStats &sdb, const Row &row) const =0 |
| int | getNumClasses () const |
| Return the number of possible discrete values from 0 to N-1. | |
| void | setNumClasses (int) |
| Call this function to set the number of classes (don't play with num_classes_ directly ==> important) | |
| void | setOutputCoder (SDBVMOutputCoder *oc) |
| Set the currently-active output coder (captures ownership of passed object) | |
Protected Attributes | |
| int | num_classes_ |
| must be >0 for one-hot coding | |
| PSDBVMOutputCoder | output_coder_ |
| perform actual formatting | |
Private Types | |
| typedef SDBVMFieldSource1 | inherited |
A field that recodes its source field according to an OutputCoder object.
typedef SDBVMFieldSource1 PLearn::SDBVMFieldDiscrete::inherited [private] |
Reimplemented from PLearn::SDBVMFieldSource1.
Reimplemented in PLearn::SDBVMFieldDateGreater, PLearn::SDBVMFieldCodeAsIs, PLearn::SDBVMFieldRemapReals, PLearn::SDBVMFieldRemapStrings, PLearn::SDBVMFieldRemapIntervals, and PLearn::SDBVMFieldMultiDiscrete.
| PLearn::SDBVMFieldDiscrete::SDBVMFieldDiscrete | ( | SDBVMSource | source, |
| int | num_classes = 0, |
||
| real | missing_values_mapping = MISSING_VALUE, |
||
| SDBVMOutputCoding | oc = SDBVMNumeric, |
||
| VMField::FieldType | ft = VMField::DiscrGeneral |
||
| ) |
All constructors now specify the number of classes (between 0 and n-1), and whether one_hot output coding is desired (true) or direct integer codes (false, the default). By default, num_classes is not known at construction time, and must be set by derived classes. A remapping for missing values can also be provided.
Definition at line 588 of file SDBVMat.cc.
References output_coder_.
: inherited(source,missing_values_mapping,ft), num_classes_(num_classes), output_coder_(new SDBVMOutputCoder(oc, missing_values_mapping)) { output_coder_->setNumClasses(num_classes); }
| PLearn::SDBVMFieldDiscrete::SDBVMFieldDiscrete | ( | SDBVMSource | source, |
| SDBVMOutputCoder * | oc, | ||
| int | num_classes = 0, |
||
| real | missing_values_mapping = MISSING_VALUE, |
||
| VMField::FieldType | ft = VMField::DiscrGeneral |
||
| ) |
Version of the constructor that takes an OutputCoder object.
Definition at line 597 of file SDBVMat.cc.
References output_coder_.
: inherited(source, missing_values_mapping,ft), num_classes_(num_classes), output_coder_(oc) { output_coder_->setNumClasses(num_classes); }
| void PLearn::SDBVMFieldDiscrete::convertField | ( | const SDBWithStats & | sdb, |
| const Row & | row, | ||
| const Vec & | output | ||
| ) | const [virtual] |
This function is implemented as a call to a virtual function getDiscreteValue(), followed by a call to setOutput of the OutputCoder.
Implements PLearn::SDBVMField.
Reimplemented in PLearn::SDBVMFieldDateGreater.
Definition at line 605 of file SDBVMat.cc.
References getDiscreteValue(), and output_coder_.
{
real value = getDiscreteValue(sdb, row);
output_coder_->setOutput(value, output);
}

| int PLearn::SDBVMFieldDiscrete::fieldWidth | ( | ) | const [virtual] |
Width that the field occupies in the VMat.
Implements PLearn::SDBVMField.
Reimplemented in PLearn::SDBVMFieldDateGreater.
Definition at line 612 of file SDBVMat.cc.
References output_coder_.
{
return output_coder_->fieldWidth();
}
| virtual real PLearn::SDBVMFieldDiscrete::getDiscreteValue | ( | const SDBWithStats & | sdb, |
| const Row & | row | ||
| ) | const [pure virtual] |
This function must be overridden in derived classes to get the correctly-mapped discrete value obtained from the SDB. The semantics prescribe missing values to be remapped to missing_values_mapping_.
Implemented in PLearn::SDBVMFieldDateGreater, PLearn::SDBVMFieldCodeAsIs, PLearn::SDBVMFieldRemapReals, PLearn::SDBVMFieldRemapStrings, PLearn::SDBVMFieldRemapIntervals, and PLearn::SDBVMFieldMultiDiscrete.
Referenced by convertField().

| int PLearn::SDBVMFieldDiscrete::getNumClasses | ( | ) | const [inline] |
Return the number of possible discrete values from 0 to N-1.
Definition at line 645 of file SDBVMat.h.
{ return num_classes_; }
| SDBVMOutputCoding PLearn::SDBVMFieldDiscrete::getOutputCoding | ( | ) | const [virtual] |
Reimplemented from PLearn::SDBVMField.
Definition at line 617 of file SDBVMat.cc.
References output_coder_.
{
return output_coder_->getOutputCoding();
}
| void PLearn::SDBVMFieldDiscrete::setNumClasses | ( | int | num_classes | ) |
Call this function to set the number of classes (don't play with num_classes_ directly ==> important)
Definition at line 622 of file SDBVMat.cc.
References num_classes_, and output_coder_.
Referenced by PLearn::SDBVMFieldRemapIntervals::SDBVMFieldRemapIntervals(), PLearn::SDBVMFieldRemapReals::SDBVMFieldRemapReals(), PLearn::SDBVMFieldRemapStrings::SDBVMFieldRemapStrings(), and PLearn::SDBVMFieldMultiDiscrete::setFields().
{
num_classes_ = num_classes;
output_coder_->setNumClasses(num_classes);
}

| void PLearn::SDBVMFieldDiscrete::setOutputCoder | ( | SDBVMOutputCoder * | oc | ) | [inline] |
Set the currently-active output coder (captures ownership of passed object)
Definition at line 653 of file SDBVMat.h.
{ output_coder_ = oc; }
int PLearn::SDBVMFieldDiscrete::num_classes_ [protected] |
must be >0 for one-hot coding
Definition at line 657 of file SDBVMat.h.
Referenced by setNumClasses().
perform actual formatting
Definition at line 658 of file SDBVMat.h.
Referenced by convertField(), fieldWidth(), getOutputCoding(), SDBVMFieldDiscrete(), and setNumClasses().
1.7.4