# Changeset 177

Ignore:
Timestamp:
Oct 1, 2004, 10:55:28 AM (19 years ago)
Message:

Location:
trunk/src
Files:
6 edited

Unmodified
Removed
• ## trunk/src/NNI.cc

 r173 using namespace std; NNI::NNI(gslapi::matrix& matrix,const gslapi::matrix& weight, // For a discussion and motivation for various algorithm // implementations here see the paper cited in the class definition // documentation. NNI::NNI(const gslapi::matrix& matrix,const gslapi::matrix& weight, const u_int neighbours) : data_(matrix), imputed_data_(matrix), neighbours_(neighbours), // d_{ij}^2=\frac {\sum_{1,N} w_{il} w_{jl} (x_{il}-x_{jl})^2 } //                {\sum_{l,N} w_{il} w_{jl} } // 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 vector > NNI::calculate_distances(const u_int row) const { // Contributing nearest neighbours are added up to the user set // number, and neighbours are disqualified if their element (column) // weight is zero vector NNI::nearest_neighbours(const u_int column, const vector >& d) const
• ## trunk/src/NNI.h

 r172 /// /// A missing value estimator /// NNI is an abstract base class defining the interface for nearest /// neighbour imputation (NNI) algorithms. /// /// NNI algorithms implemented here is discussed in documents /// created in the WeNNI project. This document will be released for /// public access, and the necessary information for retrieving that /// document will be provided here. /// /// Short introduction to NNI is that one may want to improve /// (correct) uncertain data. Here, the data to be imputed is stored in a /// matrix where rows similar to each other are used to adjust /// uncertain data. The data matrix is accompanied by a weight /// (uncertainty) matrix defining what data is to be considered as /// 'certain' and what data is uncertain. The weight matrix can be /// binary with 1's indicating that the data does not need /// corrections, whereas a 0 means that the data should be replaced /// by an imputed value. Naturally, the weight matrix can also be /// continuos where values between 0 and 1 defines how certain a /// data element is. /// /// The imputation depends on how similarity of rows of data is /// defined and on the number of closest neighbours (here; rows) to /// use in the imputation can be set. /// /// Implementation issues /// /// The current implementation treats rows where all data are tagget /// are completely uncertatin, i.e. all weights are zero, by /// ignoring these lines in nearest neighbourhood /// calculations. Importantly, this type of data are not changed /// (imputed) either since there is no close neighbourhood defined /// for this data. /// /// Rows that is completely identical in an imputation algorithm /// sense will give problems since the distance between will usually /// become zero. This is solved by setting zero distance to a small /// number. Identical rows in this context are basically a /// comparison between elements with non-zero uncertainty weights /// only, and all these elemnts are equal. Zero weight elemenets are /// not used in the comparison since these are considered as /// non/sense values. /// class NNI { public: /// /// \a matrix is changed. /// NNI(gslapi::matrix& matrix,const gslapi::matrix& weight, /// Base constructor for the nearest neighbour imputation /// algorithms. NNI(const gslapi::matrix& matrix,const gslapi::matrix& weight, const u_int neighbours); virtual ~NNI(void) {}; /// @return A const reference to the modified data. const gslapi::matrix& imputed_data(void) const { return imputed_data_; } const vector >&) const; gslapi::matrix& data_; const gslapi::matrix& data_; gslapi::matrix imputed_data_; u_int neighbours_;
• ## trunk/src/WeNNI.cc

 r176 WeNNI::WeNNI(gslapi::matrix& matrix,const gslapi::matrix& flag, WeNNI::WeNNI(const gslapi::matrix& matrix,const gslapi::matrix& flag, const u_int neighbours) : NNI(matrix,flag,neighbours) // \hat{x_{j}}=\frac{ \sum_{i,N} \frac{w_{ij}*x_i}{d_{ij}} } //                  { \sum_{i,N} \frac{w_{ij}    }{d_{ij}} } // \hat{x_{ij}}=\frac{ \sum_{k=1,N} \frac{w_{kj}*x_{kj}}{d_{ki}} } //                   { \sum_{k=1,N} \frac{w_{kj}       }{d_{ki}} } // where N is defined in the paper cited in the NNI class definition // documentation. void WeNNI::estimate(void) {
• ## trunk/src/WeNNI.h

 r146 /// /// A missing value estimator /// WeNNI is a continous weights generalization of the (binary /// weights) kNNI algorithm presented by Troyanska et al. A /// reference to this paper is found in the NNI document referred to /// in the NNI class documentation. The NNI document also describes /// WeNNI in depth. /// /// @see NNI and kNNI /// class WeNNI : public NNI { public: /// Perform WeNNI on data in \a matrix with continious uncertainty /// weights in \a weight using \a neighbours for the new impute /// value. /// /// \a matrix is changed. /// WeNNI(gslapi::matrix& matrix,const gslapi::matrix& weight, /// @note The algorithm is initiated within the constructor and /// the result is fetched with the NNI::imputed_data method. WeNNI(const gslapi::matrix& matrix,const gslapi::matrix& weight, const u_int neighbours);
• ## trunk/src/kNNI.cc

 r174 namespace cpptools { kNNI::kNNI(gslapi::matrix& matrix,const gslapi::matrix& flag, kNNI::kNNI(const gslapi::matrix& matrix,const gslapi::matrix& flag, const u_int neighbours) : NNI(matrix,flag,neighbours) // \hat{x_{j}}=\frac{ \sum_{1,k} \frac{x_i}{d_{ij}} } //                  { \sum_{1,k} \frac{1  }{d_{ij}} }, // \hat{x_{ij}}=\frac{ \sum_{k=1,N} \frac{x_{kj}}{d_{ki}} } //                   { \sum_{k=1,N} \frac{1     }{d_{ki}} }, // where N is defined in the paper cited in the NNI class definition // documentation. void kNNI::estimate(void) {
• ## trunk/src/kNNI.h

 r146 /// /// A missing value estimator /// kNNI is the binary weight implementation of NNI. This follows /// the work done by Troyanska 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 NNI and WeNNI /// class kNNI : public NNI { public: /// Perform kNNI on data in \a matrix with binary uncertainty /// weights in \a weight using \a neighbours for the new impute /// value. /// /// \a matrix is changed. /// kNNI(gslapi::matrix& matrix,const gslapi::matrix& weight, /// @note The algorithm is initiated within the constructor and /// the result is fetched with the NNI::imputed_data method. kNNI(const gslapi::matrix& matrix,const gslapi::matrix& weight, const u_int neighbours);
Note: See TracChangeset for help on using the changeset viewer.