Changeset 1725
- Timestamp:
- Jan 15, 2009, 5:57:36 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/data/knni_matrix.data
r420 r1725 6 6 7 7 .8624 .286482 .83248 .72846 .28468 .2347 .23234 .98973 .29874 .32894 .1234 8 .8624 .286482 .83248 .72846 .28468.2347 .23234 .98973 .29874 .32894 .12348 .8624 .286482 .83248 .72846 NaN .2347 .23234 .98973 .29874 .32894 .1234 9 9 .2342 .23878 .97437 .76236 .32764 .3474 .43276 .34555 .29948 .34598 .1234 10 10 .2347 .56783 .78435 .35763 .23468 .7384 .23578 .345533 .235948 .32458 .1234 -
trunk/yat/utility/WeNNI.cc
r1554 r1725 6 6 Copyright (C) 2006 Jari Häkkinen 7 7 Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson 8 Copyright (C) 2009 Jari Häkkinen 8 9 9 10 This file is part of the yat library, http://dev.thep.lu.se/yat … … 45 46 46 47 47 48 48 // \hat{x_{ij}}=\frac{ \sum_{k=1,N} \frac{w_{kj}*x_{kj}}{d_{ki}} } 49 49 // { \sum_{k=1,N} \frac{w_{kj} }{d_{ki}} } … … 66 66 // Avoid division with zero (perfect match vectors) 67 67 double d=(distance[*k].second ? distance[*k].second : small_number); 68 new_value+=(weight_(distance[*k].first,j) * 69 data_(distance[*k].first,j)/d); 70 norm+=weight_(distance[*k].first,j)/d; 68 double w=weight_(distance[*k].first,j)/d; 69 if (w) { 70 new_value += w*data_(distance[*k].first,j); 71 norm += w; 72 } 71 73 } 72 74 // No impute if no contributions from neighbours. 73 if (norm) {75 if (norm) { 74 76 imputed_data_raw_(i,j) = new_value/norm; 75 imputed_data_(i,j)= 76 weight_(i,j)*data_(i,j) + (1-weight_(i,j))* imputed_data_raw_(i,j); 77 double w=weight_(i,j); 78 if (w) 79 imputed_data_(i,j) = w*data_(i,j) + (1-w)*imputed_data_raw_(i,j); 80 else 81 imputed_data_(i,j) = imputed_data_raw_(i,j); 77 82 } 78 83 else -
trunk/yat/utility/WeNNI.h
r1487 r1725 10 10 Copyright (C) 2007 Jari Häkkinen, Peter Johansson 11 11 Copyright (C) 2008 Peter Johansson 12 Copyright (C) 2009 Jari Häkkinen 12 13 13 14 This file is part of the yat library, http://dev.thep.lu.se/yat … … 36 37 namespace utility { 37 38 38 /// 39 /// @brief Weighted Nearest Neighbour Imputation 40 /// 41 /// WeNNI is a continuous weights generalization of the (binary 42 /// weights) kNNI algorithm presented by Troyanskaya et al. A 43 /// reference to this paper is found in the NNI document referred to 44 /// in the NNI class documentation. The NNI document also describes 45 /// WeNNI in depth. 46 /// 47 /// @see NNI and kNNI 48 /// 39 /** 40 \brief Weighted Nearest Neighbour Imputation 41 42 WeNNI is a continuous weights generalization of the (binary 43 weights) kNNI algorithm presented by Troyanskaya et al. A 44 reference to this paper is found in the NNI document referred to 45 in the NNI class documentation. The NNI document also describes 46 WeNNI in depth. 47 48 \note Missing values should be represented with a zero 49 weight. WeNNI will treat the corresponding data values as zero, 50 i.e., this implies that NaNs and Infs with zero weight will not 51 have any impact on calculations.a 52 53 \see NNI and kNNI 54 */ 49 55 class WeNNI : public NNI 50 56 {
Note: See TracChangeset
for help on using the changeset viewer.