yat  0.20.3pre
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
theplu::yat::utility::kNNI Class Reference

kNNimpute More...

#include <yat/utility/kNNI.h>

Inheritance diagram for theplu::yat::utility::kNNI:
theplu::yat::utility::NNI

Public Member Functions

 kNNI (const MatrixBase &matrix, const MatrixBase &weight, const unsigned int neighbours)
 
unsigned int estimate (void)
 Function doing kNNI imputation. More...
 
const utility::Matriximputed_data (void) const
 
const std::vector< size_t > & not_imputed (void) const
 

Protected Member Functions

std::vector< std::pair< size_t, double > > calculate_distances (const size_t) const
 
std::vector< size_t > nearest_neighbours (const size_t, const std::vector< std::pair< size_t, double > > &) const
 

Protected Attributes

const utility::MatrixBasedata_
 
utility::Matrix imputed_data_
 
unsigned int neighbours_
 
std::vector< size_t > not_imputed_
 
const utility::MatrixBaseweight_
 

Detailed Description

kNNimpute

kNNI is the binary weight implementation of NNI. This follows the work done by Troyanskaya et al. cited in the NNI document referred to in the NNI class documentation.

This is a special case of the WeNNI, but is maintained since it is faster than the more general WeNNI.

See also
NNI and WeNNI

Constructor & Destructor Documentation

◆ kNNI()

theplu::yat::utility::kNNI::kNNI ( const MatrixBase matrix,
const MatrixBase weight,
const unsigned int  neighbours 
)

Constructor

Member Function Documentation

◆ calculate_distances()

std::vector<std::pair<size_t,double> > theplu::yat::utility::NNI::calculate_distances ( const size_t  ) const
protectedinherited

$ d_{ij}^2=\frac {\sum_{k=1}^C w_{ik} w_{jk} (x_{ik}-x_{jk})^2 }{\sum_{k=l}^C w_{ik} w_{jk} } $ where C is the number of columns

◆ estimate()

unsigned int theplu::yat::utility::kNNI::estimate ( void  )
virtual

Function doing kNNI imputation.

Perform kNNI on data in matrix with binary uncertainty weights in weight using neighbours for the new impute value.

The return value can be used as an indication of how well the imputation worked. The return value should be zero if proper pre-processing of data is done. An example of bad data is a matrix with a column of zero weights, another is a corresponding situation with a row with all weights zero.

Returns
The number of rows that have at least one value not imputed.

Implements theplu::yat::utility::NNI.

◆ imputed_data()

const utility::Matrix& theplu::yat::utility::NNI::imputed_data ( void  ) const
inherited
Returns
A const reference to the modified data.

◆ nearest_neighbours()

std::vector<size_t> theplu::yat::utility::NNI::nearest_neighbours ( const size_t  ,
const std::vector< std::pair< size_t, double > > &   
) const
protectedinherited

Contributing nearest neighbours are added up to the user set number, and neighbours are disqualified if their element (column) weight is zero

◆ not_imputed()

const std::vector<size_t>& theplu::yat::utility::NNI::not_imputed ( void  ) const
inherited
Returns
indices of rows in data matrix not imputed

Member Data Documentation

◆ data_

const utility::MatrixBase& theplu::yat::utility::NNI::data_
protectedinherited

original data matrix

◆ imputed_data_

utility::Matrix theplu::yat::utility::NNI::imputed_data_
protectedinherited

data after imputation

◆ neighbours_

unsigned int theplu::yat::utility::NNI::neighbours_
protectedinherited

number of neighbor to use

◆ not_imputed_

std::vector<size_t> theplu::yat::utility::NNI::not_imputed_
protectedinherited

which rows are not imputed due to lack of data

◆ weight_

const utility::MatrixBase& theplu::yat::utility::NNI::weight_
protectedinherited

weight matrix


The documentation for this class was generated from the following file:

Generated on Sat Feb 18 2023 03:31:45 for yat by  doxygen 1.8.14