PLearn 0.1
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Static Protected Member Functions | Private Types | Private Member Functions
PLearn::ImputationVMatrix Class Reference

#include <ImputationVMatrix.h>

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

List of all members.

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 ImputationVMatrixdeepCopy (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 PPathdeclaringFile ()

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.

Detailed Description

Definition at line 55 of file ImputationVMatrix.h.


Member Typedef Documentation


Constructor & Destructor Documentation

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.

{
}

Member Function Documentation

string PLearn::ImputationVMatrix::_classname_ ( ) [static]
OptionList & PLearn::ImputationVMatrix::_getOptionList_ ( ) [static]
RemoteMethodMap & PLearn::ImputationVMatrix::_getRemoteMethodMap_ ( ) [static]
bool PLearn::ImputationVMatrix::_isa_ ( const Object o) [static]
StaticInitializer ImputationVMatrix::_static_initializer_ & PLearn::ImputationVMatrix::_static_initialize_ ( ) [static]
void PLearn::ImputationVMatrix::build ( ) [virtual]
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().

{
}

Here is the caller graph for this function:

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);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static const PPath& PLearn::ImputationVMatrix::declaringFile ( ) [inline, static]
ImputationVMatrix * PLearn::ImputationVMatrix::deepCopy ( CopiesMap copies) const [virtual]
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);
      ...
  }
Parameters:
copiesA 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().

Here is the call graph for this function:

Here is the caller graph for this function:

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);
        }
        }*/
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 63 of file ImputationVMatrix.h.

Referenced by declareOptions(), and testResultantVMatrix().


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