|
PLearn 0.1
|
#include <ClassSubsetVMatrix.h>


Public Member Functions | |
| ClassSubsetVMatrix () | |
| Default constructor. | |
| ClassSubsetVMatrix (VMat the_source, const TVec< int > &the_classes, bool call_build_=true) | |
| Convenience constructor. | |
| ClassSubsetVMatrix (VMat the_source, int the_class, bool call_build_=true) | |
| Convenience constructor. | |
| virtual void | build () |
| Simply calls inherited::build() then build_(). | |
| virtual real | get (int i, int j) const |
| These methods are implemented by buffering calls to getNewRow. | |
| virtual void | getSubRow (int i, int j, Vec v) const |
| fills v with the subrow i laying between columns j (inclusive) and j+v.length() (exclusive) | |
| virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
| Transforms a shallow copy into a deep copy. | |
| virtual string | classname () const |
| virtual OptionList & | getOptionList () const |
| virtual OptionMap & | getOptionMap () const |
| virtual RemoteMethodMap & | getRemoteMethodMap () const |
| virtual ClassSubsetVMatrix * | 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 | |
| TVec< int > | classes |
| Classes of examples to keep. | |
| bool | redistribute_classes |
| Indication that the class values should be redistributed between 0 and classes.length()-1, based on the order in classes. | |
| bool | one_vs_minus_one_classification |
| Indication that, if classes contains 2 class indexes, than they should be mapped to -1 (the first index) and 1. | |
Static Public Attributes | |
| static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
| static void | declareOptions (OptionList &ol) |
| Declares this class' options. | |
Private Types | |
| typedef SelectRowsVMatrix | inherited |
Private Member Functions | |
| void | build_ () |
| This does the actual building. | |
Private Attributes | |
| Vec | input |
| Vec | target |
| real | weight |
Definition at line 52 of file ClassSubsetVMatrix.h.
typedef SelectRowsVMatrix PLearn::ClassSubsetVMatrix::inherited [private] |
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 57 of file ClassSubsetVMatrix.h.
| PLearn::ClassSubsetVMatrix::ClassSubsetVMatrix | ( | ) |
Default constructor.
Definition at line 58 of file ClassSubsetVMatrix.cc.
:
redistribute_classes(false),
one_vs_minus_one_classification(false)
{}
| PLearn::ClassSubsetVMatrix::ClassSubsetVMatrix | ( | VMat | the_source, |
| const TVec< int > & | the_classes, | ||
| bool | call_build_ = true |
||
| ) |
Convenience constructor.
Note that the vector 'the_classes' is copied and thus may be modified afterwards.
Definition at line 63 of file ClassSubsetVMatrix.cc.
References build_(), and PLearn::SourceVMatrix::source.
:
// There is no need to explicitely call the parent's constructor since
// the whole build process will be done in build_() if necessary.
classes(the_classes.copy()),
redistribute_classes(false),
one_vs_minus_one_classification(false)
{
source = the_source;
if (call_build_)
build_();
}

| PLearn::ClassSubsetVMatrix::ClassSubsetVMatrix | ( | VMat | the_source, |
| int | the_class, | ||
| bool | call_build_ = true |
||
| ) |
Convenience constructor.
Definition at line 77 of file ClassSubsetVMatrix.cc.
References build_(), and PLearn::SourceVMatrix::source.
:
// There is no need to explicitely call the parent's constructor since
// the whole build process will be done in build_() if necessary.
classes(TVec<int>(1, the_class)),
redistribute_classes(false),
one_vs_minus_one_classification(false)
{
source = the_source;
if (call_build_)
build_();
}

| string PLearn::ClassSubsetVMatrix::_classname_ | ( | ) | [static] |
Declares name and deepCopy methods.
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 53 of file ClassSubsetVMatrix.cc.
| OptionList & PLearn::ClassSubsetVMatrix::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 53 of file ClassSubsetVMatrix.cc.
| RemoteMethodMap & PLearn::ClassSubsetVMatrix::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 53 of file ClassSubsetVMatrix.cc.
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 53 of file ClassSubsetVMatrix.cc.
| Object * PLearn::ClassSubsetVMatrix::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 53 of file ClassSubsetVMatrix.cc.
| StaticInitializer ClassSubsetVMatrix::_static_initializer_ & PLearn::ClassSubsetVMatrix::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 53 of file ClassSubsetVMatrix.cc.
| void PLearn::ClassSubsetVMatrix::build | ( | ) | [virtual] |
Simply calls inherited::build() then build_().
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 119 of file ClassSubsetVMatrix.cc.
References PLearn::SelectRowsVMatrix::build(), and build_().
{
inherited::build();
build_();
}

| void PLearn::ClassSubsetVMatrix::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 128 of file ClassSubsetVMatrix.cc.
References PLearn::SelectRowsVMatrix::build(), classes, PLearn::TVec< T >::clear(), PLearn::TVec< T >::find(), PLearn::VMat::getExample(), i, PLearn::SelectRowsVMatrix::indices, input, PLearn::VMatrix::inputsize(), PLearn::TVec< T >::length(), PLearn::VMat::length(), one_vs_minus_one_classification, PLERROR, PLearn::TVec< T >::push_back(), PLearn::TVec< T >::resize(), PLearn::VMatrix::setMetaInfoFrom(), PLearn::SourceVMatrix::source, target, PLearn::VMatrix::targetsize(), and weight.
Referenced by build(), and ClassSubsetVMatrix().
{
if (source) {
setMetaInfoFrom(source);
input.resize(inputsize());
target.resize(targetsize());
indices.clear();
for(int i=0;i<source->length();i++)
{
source->getExample(i,input,target,weight);
if(classes.find((int)target[0]) != -1)
indices.push_back(i);
}
//if(indices.length() == 0)
// PLERROR("In ClassSubsetVMatrix::build_(): no examples kept");
inherited::build();
if(one_vs_minus_one_classification && classes.length()!=2)
PLERROR("In ClassSubsetVMatrix::build_(): no examples kept");
}
}


| string PLearn::ClassSubsetVMatrix::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 53 of file ClassSubsetVMatrix.cc.
| void PLearn::ClassSubsetVMatrix::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares this class' options.
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 93 of file ClassSubsetVMatrix.cc.
References PLearn::OptionBase::buildoption, classes, PLearn::declareOption(), PLearn::SelectRowsVMatrix::declareOptions(), one_vs_minus_one_classification, and redistribute_classes.
{
// ### Declare all of this object's options here
// ### For the "flags" of each option, you should typically specify
// ### one of OptionBase::buildoption, OptionBase::learntoption or
// ### OptionBase::tuningoption. Another possible flag to be combined with
// ### is OptionBase::nosave
declareOption(ol, "classes", &ClassSubsetVMatrix::classes, OptionBase::buildoption,
"Classes of examples to keep.\n");
declareOption(ol, "redistribute_classes", &ClassSubsetVMatrix::redistribute_classes, OptionBase::buildoption,
"Indication that the class values should be redistributed between 0 and classes.length()-1,\n"
"based on the order of apperance in the vector classes.\n");
declareOption(ol, "one_vs_minus_one_classification", &ClassSubsetVMatrix::one_vs_minus_one_classification, OptionBase::buildoption,
"Indication that, if classes contains 2 class indexes,\n"
"than they should be mapped to -1 (the first index) and 1.\n");
// Now call the parent class' declareOptions
inherited::declareOptions(ol);
}

| static const PPath& PLearn::ClassSubsetVMatrix::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 128 of file ClassSubsetVMatrix.h.
| ClassSubsetVMatrix * PLearn::ClassSubsetVMatrix::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 53 of file ClassSubsetVMatrix.cc.
These methods are implemented by buffering calls to getNewRow.
returns element (i,j)
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 149 of file ClassSubsetVMatrix.cc.
References classes, PLearn::TVec< T >::find(), PLearn::SelectRowsVMatrix::indices, PLearn::VMatrix::inputsize(), one_vs_minus_one_classification, redistribute_classes, and PLearn::SourceVMatrix::source.
{
if(!redistribute_classes || j != inputsize())
return source->get(indices[i], j);
else
{
if(one_vs_minus_one_classification)
return 2*classes.find((int)source->get(indices[i], j))-1;
else
return classes.find((int)source->get(indices[i], j));
}
}

| OptionList & PLearn::ClassSubsetVMatrix::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 53 of file ClassSubsetVMatrix.cc.
| OptionMap & PLearn::ClassSubsetVMatrix::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 53 of file ClassSubsetVMatrix.cc.
| RemoteMethodMap & PLearn::ClassSubsetVMatrix::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 53 of file ClassSubsetVMatrix.cc.
fills v with the subrow i laying between columns j (inclusive) and j+v.length() (exclusive)
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 162 of file ClassSubsetVMatrix.cc.
References classes, PLearn::TVec< T >::find(), PLearn::VMat::getSubRow(), PLearn::SelectRowsVMatrix::indices, PLearn::VMatrix::inputsize(), j, PLearn::TVec< T >::length(), one_vs_minus_one_classification, redistribute_classes, and PLearn::SourceVMatrix::source.
{
source->getSubRow(indices[i], j, v);
if(redistribute_classes && j+v.length() > inputsize())
{
if(one_vs_minus_one_classification)
v[inputsize()-j] = 2*classes.find((int)v[inputsize()-j])-1;
else
v[inputsize()-j] = classes.find((int)v[inputsize()-j]);
}
}

| void PLearn::ClassSubsetVMatrix::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 178 of file ClassSubsetVMatrix.cc.
References classes, PLearn::deepCopyField(), input, PLearn::SelectRowsVMatrix::makeDeepCopyFromShallowCopy(), and target.
{
inherited::makeDeepCopyFromShallowCopy(copies);
deepCopyField(classes,copies);
deepCopyField(input,copies);
deepCopyField(target,copies);
//PLERROR("ClassSubsetVMatrix::makeDeepCopyFromShallowCopy not fully (correctly) implemented yet!");
}

Reimplemented from PLearn::SelectRowsVMatrix.
Definition at line 128 of file ClassSubsetVMatrix.h.
Classes of examples to keep.
Definition at line 74 of file ClassSubsetVMatrix.h.
Referenced by build_(), declareOptions(), get(), getSubRow(), and makeDeepCopyFromShallowCopy().
Vec PLearn::ClassSubsetVMatrix::input [private] |
Definition at line 59 of file ClassSubsetVMatrix.h.
Referenced by build_(), and makeDeepCopyFromShallowCopy().
Indication that, if classes contains 2 class indexes, than they should be mapped to -1 (the first index) and 1.
Definition at line 83 of file ClassSubsetVMatrix.h.
Referenced by build_(), declareOptions(), get(), and getSubRow().
Indication that the class values should be redistributed between 0 and classes.length()-1, based on the order in classes.
Definition at line 79 of file ClassSubsetVMatrix.h.
Referenced by declareOptions(), get(), and getSubRow().
Vec PLearn::ClassSubsetVMatrix::target [private] |
Definition at line 59 of file ClassSubsetVMatrix.h.
Referenced by build_(), and makeDeepCopyFromShallowCopy().
real PLearn::ClassSubsetVMatrix::weight [private] |
Definition at line 60 of file ClassSubsetVMatrix.h.
Referenced by build_().
1.7.4