|
PLearn 0.1
|
#include <ImputationVMatrix.h>


Public Member Functions | |
| ImputationVMatrix () | |
| virtual | ~ImputationVMatrix () |
| virtual void | build () |
| Simply calls inherited::build() then build_(). | |
| virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
| Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be. | |
| void | testResultantVMatrix () |
| virtual ImputationVMatrix * | deepCopy (CopiesMap &copies) const |
Static Public Member Functions | |
| static string | _classname_ () |
| ImputationVMatrix. | |
| static OptionList & | _getOptionList_ () |
| static RemoteMethodMap & | _getRemoteMethodMap_ () |
| static bool | _isa_ (const Object *o) |
| static void | _static_initialize_ () |
| static const PPath & | declaringFile () |
Public Attributes | |
| VMat | source |
| The source VMatrix with missing values. | |
| int | test_level |
Static Public Attributes | |
| static StaticInitializer | _static_initializer_ |
Static Protected Member Functions | |
| static void | declareOptions (OptionList &ol) |
| Declares this class' options. | |
Private Types | |
| typedef VMatrix | inherited |
Private Member Functions | |
| void | build_ () |
| This does the actual building. | |
Definition at line 55 of file ImputationVMatrix.h.
typedef VMatrix PLearn::ImputationVMatrix::inherited [private] |
Reimplemented from PLearn::VMatrix.
Reimplemented in PLearn::MeanMedianModeImputationVMatrix, PLearn::ConditionalMeanImputationVMatrix, PLearn::CovariancePreservationImputationVMatrix, and PLearn::NeighborhoodImputationVMatrix.
Definition at line 57 of file ImputationVMatrix.h.
| PLearn::ImputationVMatrix::ImputationVMatrix | ( | ) |
Definition at line 57 of file ImputationVMatrix.cc.
:
test_level(0)
{
}
| PLearn::ImputationVMatrix::~ImputationVMatrix | ( | ) | [virtual] |
Definition at line 62 of file ImputationVMatrix.cc.
{
}
| string PLearn::ImputationVMatrix::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::VMatrix.
Reimplemented in PLearn::MeanMedianModeImputationVMatrix, PLearn::ConditionalMeanImputationVMatrix, PLearn::CovariancePreservationImputationVMatrix, and PLearn::NeighborhoodImputationVMatrix.
Definition at line 55 of file ImputationVMatrix.cc.
| OptionList & PLearn::ImputationVMatrix::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::VMatrix.
Reimplemented in PLearn::MeanMedianModeImputationVMatrix, PLearn::ConditionalMeanImputationVMatrix, PLearn::CovariancePreservationImputationVMatrix, and PLearn::NeighborhoodImputationVMatrix.
Definition at line 55 of file ImputationVMatrix.cc.
| RemoteMethodMap & PLearn::ImputationVMatrix::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::VMatrix.
Reimplemented in PLearn::MeanMedianModeImputationVMatrix, PLearn::ConditionalMeanImputationVMatrix, PLearn::CovariancePreservationImputationVMatrix, and PLearn::NeighborhoodImputationVMatrix.
Definition at line 55 of file ImputationVMatrix.cc.
Reimplemented from PLearn::VMatrix.
Reimplemented in PLearn::MeanMedianModeImputationVMatrix, PLearn::ConditionalMeanImputationVMatrix, PLearn::CovariancePreservationImputationVMatrix, and PLearn::NeighborhoodImputationVMatrix.
Definition at line 55 of file ImputationVMatrix.cc.
| StaticInitializer ImputationVMatrix::_static_initializer_ & PLearn::ImputationVMatrix::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::VMatrix.
Reimplemented in PLearn::MeanMedianModeImputationVMatrix, PLearn::ConditionalMeanImputationVMatrix, PLearn::CovariancePreservationImputationVMatrix, and PLearn::NeighborhoodImputationVMatrix.
Definition at line 55 of file ImputationVMatrix.cc.
| void PLearn::ImputationVMatrix::build | ( | ) | [virtual] |
Simply calls inherited::build() then build_().
Reimplemented from PLearn::VMatrix.
Reimplemented in PLearn::MeanMedianModeImputationVMatrix, PLearn::ConditionalMeanImputationVMatrix, PLearn::CovariancePreservationImputationVMatrix, and PLearn::NeighborhoodImputationVMatrix.
Definition at line 76 of file ImputationVMatrix.cc.
References PLearn::VMatrix::build(), and build_().
Referenced by PLearn::NeighborhoodImputationVMatrix::build(), and PLearn::MeanMedianModeImputationVMatrix::build().
{
inherited::build();
build_();
}


| void PLearn::ImputationVMatrix::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::VMatrix.
Reimplemented in PLearn::MeanMedianModeImputationVMatrix, PLearn::ConditionalMeanImputationVMatrix, PLearn::CovariancePreservationImputationVMatrix, and PLearn::NeighborhoodImputationVMatrix.
Definition at line 88 of file ImputationVMatrix.cc.
Referenced by build().
{
}

| void PLearn::ImputationVMatrix::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares this class' options.
Reimplemented from PLearn::VMatrix.
Reimplemented in PLearn::MeanMedianModeImputationVMatrix, PLearn::ConditionalMeanImputationVMatrix, PLearn::CovariancePreservationImputationVMatrix, and PLearn::NeighborhoodImputationVMatrix.
Definition at line 66 of file ImputationVMatrix.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::VMatrix::declareOptions(), source, and test_level.
Referenced by PLearn::NeighborhoodImputationVMatrix::declareOptions(), and PLearn::MeanMedianModeImputationVMatrix::declareOptions().
{
declareOption(ol, "source", &ImputationVMatrix::source, OptionBase::buildoption,
"The source VMatrix with missing values that will be filled.\n");
declareOption(ol, "test_level", &ImputationVMatrix::test_level, OptionBase::buildoption,
"The level of test of final matrix. 0 : no test, 1: linear in column or row test, 2: linear in cell\n");
inherited::declareOptions(ol);
}


| static const PPath& PLearn::ImputationVMatrix::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::VMatrix.
Reimplemented in PLearn::MeanMedianModeImputationVMatrix, PLearn::ConditionalMeanImputationVMatrix, PLearn::CovariancePreservationImputationVMatrix, and PLearn::NeighborhoodImputationVMatrix.
Definition at line 80 of file ImputationVMatrix.h.
| ImputationVMatrix * PLearn::ImputationVMatrix::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::VMatrix.
Reimplemented in PLearn::MeanMedianModeImputationVMatrix, PLearn::ConditionalMeanImputationVMatrix, PLearn::CovariancePreservationImputationVMatrix, and PLearn::NeighborhoodImputationVMatrix.
Definition at line 55 of file ImputationVMatrix.cc.
| void PLearn::ImputationVMatrix::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Does the necessary operations to transform a shallow copy (this) into a deep copy by deep-copying all the members that need to be.
This needs to be overridden by every class that adds "complex" data members to the class, such as Vec, Mat, PP<Something>, etc. Typical implementation:
void CLASS_OF_THIS::makeDeepCopyFromShallowCopy(CopiesMap& copies) { inherited::makeDeepCopyFromShallowCopy(copies); deepCopyField(complex_data_member1, copies); deepCopyField(complex_data_member2, copies); ... }
| copies | A map used by the deep-copy mechanism to keep track of already-copied objects. |
Reimplemented from PLearn::VMatrix.
Reimplemented in PLearn::MeanMedianModeImputationVMatrix, PLearn::ConditionalMeanImputationVMatrix, PLearn::CovariancePreservationImputationVMatrix, and PLearn::NeighborhoodImputationVMatrix.
Definition at line 82 of file ImputationVMatrix.cc.
References PLearn::deepCopyField(), PLearn::VMatrix::makeDeepCopyFromShallowCopy(), and source.
Referenced by PLearn::NeighborhoodImputationVMatrix::makeDeepCopyFromShallowCopy(), and PLearn::MeanMedianModeImputationVMatrix::makeDeepCopyFromShallowCopy().
{
deepCopyField(source, copies);
inherited::makeDeepCopyFromShallowCopy(copies);
}


| void PLearn::ImputationVMatrix::testResultantVMatrix | ( | ) |
Definition at line 92 of file ImputationVMatrix.cc.
References PLearn::VMatrix::field_stats, PLearn::VMatrix::getStats(), PLearn::is_missing(), PLearn::VMatrix::length(), PLearn::mean(), PLERROR, PLWARNING, source, PLearn::sqrt(), test_level, PLearn::VMat::width(), and PLearn::VMatrix::width().
Referenced by PLearn::NeighborhoodImputationVMatrix::build().
{
TVec<string> source_names(source->width());
source_names = source->fieldNames();
if(test_level>=1){
for(int row=0;row<length();row++)
for(int col=0;col<width();col++){
real data=get(row,col);
real sourcedata=source->get(row,col);
//test if variable not missing are not changed.
if(!is_missing(sourcedata))
if(data!=sourcedata){
PLERROR("ImputationImputations::testResultantVMatrix() data at [%d,%d] are different but the data is not missing",row,col);
}
//test if missing variable are replaced by a value not missing.
if(is_missing(data))
PLERROR("ImputationImputations::testResultantVMatrix() data at [%d,%d] in the final matrix is missing",row,col);
}
}
if(test_level>=2){ //Must verify if source->getStats is linear
getStats();
source->getStats();
//print the variable that the replacement of missing value change the mean by more then 3 times the stderr
int nberr = 0;
for(int col=0;col<width();col++)
{
real mean = field_stats[col].mean();
real smean = source->getStats(col).mean();
real sstderr = source->getStats(col).stddev()/sqrt(source->getStats(col).nnonmissing());
real val=(mean-smean)/sstderr;
if(fabs(val)>3){
PLWARNING("ImputationImputations::testResultantVMatrix() the variable %d(%s) have a value of %f for abs((mean-sourcemean)/source_stderr)",col,source_names[col].c_str(),val);
nberr++;
}
}
if(nberr>0)
PLWARNING("ImputationImputations::testResultantVMatrix() There have been %d variables with the mean after imputation outside of sourcemean +- 3*source_stderr",nberr);
}
// for(int row=0;row<length();row++)
/* for(int col=0;col<width();col++)
{
StatsCollector sstats=source->getStats(col);
StatsCollector stats=getStats(col);
if(sstats.nmissing()!=0){
real sum=0;
condmean_variable_file_name = source_metadata + "/" + condmean_dir + "/dir/" + source_names[col] + "/Split0/test1_outputs.pmat";
if (!isfile(condmean_variable_file_name))
PLERROR("In ImputationVMatrix::A conditional mean file was not found for variable %s", source_names[col].c_str());
condmean_variable_file = new FileVMatrix(condmean_variable_file_name, false);
if (condmean_variable_file->length() != source_length)
PLERROR("In ImputationVMatrix::Source and conditional mean file length are not equal for variable %s", source_names[col].c_str());
for (int source_row = 0; source_row < source_length; source_row++){
real rdata = condmean_variable_file->get(source_row, 0);
real data = get(source_row, col);
if(!is_missing(rdata))
sum+=pow(data - rdata, 2.0);
}
real mse=sum/stats.nnonmissing();
real diff=mse/sstats.variance();
if(diff >0.9){
perr <<col<<" "<<diff<<endl;
PLWARNING("ImputationImputations::testresultantVMatrix() the variable %d(%s) have a MSEtreecondmean(%f)/MSEmean(%f) of %f",col,source_names[col].c_str(),mse,sstats.variance(),diff);
}
}*/
}


Reimplemented from PLearn::VMatrix.
Reimplemented in PLearn::MeanMedianModeImputationVMatrix, PLearn::ConditionalMeanImputationVMatrix, PLearn::CovariancePreservationImputationVMatrix, and PLearn::NeighborhoodImputationVMatrix.
Definition at line 80 of file ImputationVMatrix.h.
The source VMatrix with missing values.
Definition at line 62 of file ImputationVMatrix.h.
Referenced by PLearn::NeighborhoodImputationVMatrix::build_(), PLearn::MeanMedianModeImputationVMatrix::build_(), declareOptions(), PLearn::NeighborhoodImputationVMatrix::get(), PLearn::MeanMedianModeImputationVMatrix::get(), PLearn::NeighborhoodImputationVMatrix::getColumn(), PLearn::MeanMedianModeImputationVMatrix::getColumn(), PLearn::NeighborhoodImputationVMatrix::getExample(), PLearn::NeighborhoodImputationVMatrix::getRow(), PLearn::MeanMedianModeImputationVMatrix::getRow(), PLearn::NeighborhoodImputationVMatrix::getSubRow(), PLearn::MeanMedianModeImputationVMatrix::getSubRow(), makeDeepCopyFromShallowCopy(), PLearn::Preprocessing::manageTrainTestUnknownSets(), PLearn::MeanMedianModeImputationVMatrix::setMetaDataDir(), and testResultantVMatrix().
Definition at line 63 of file ImputationVMatrix.h.
Referenced by declareOptions(), and testResultantVMatrix().
1.7.4