1 | #ifndef _theplu_yat_utility_wenni_ |
---|
2 | #define _theplu_yat_utility_wenni_ |
---|
3 | |
---|
4 | // $Id: WeNNI.h 1726 2009-01-15 21:15:26Z jari $ |
---|
5 | |
---|
6 | /* |
---|
7 | Copyright (C) 2004 Jari Häkkinen |
---|
8 | Copyright (C) 2005 Jari Häkkinen, Peter Johansson |
---|
9 | Copyright (C) 2006 Jari Häkkinen |
---|
10 | Copyright (C) 2007 Jari Häkkinen, Peter Johansson |
---|
11 | Copyright (C) 2008 Peter Johansson |
---|
12 | Copyright (C) 2009 Jari Häkkinen |
---|
13 | |
---|
14 | This file is part of the yat library, http://dev.thep.lu.se/yat |
---|
15 | |
---|
16 | The yat library is free software; you can redistribute it |
---|
17 | and/or modify it under the terms of the GNU General Public License |
---|
18 | as published by the Free Software Foundation; either version 3 of |
---|
19 | the License, or (at your option) any later version. |
---|
20 | |
---|
21 | The yat library is distributed in the hope that it will be |
---|
22 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
---|
23 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
24 | General Public License for more details. |
---|
25 | |
---|
26 | You should have received a copy of the GNU General Public License |
---|
27 | along with yat. If not, see <http://www.gnu.org/licenses/>. |
---|
28 | */ |
---|
29 | |
---|
30 | #include "NNI.h" |
---|
31 | #include "Matrix.h" |
---|
32 | |
---|
33 | #include <iostream> |
---|
34 | |
---|
35 | namespace theplu { |
---|
36 | namespace yat { |
---|
37 | namespace utility { |
---|
38 | |
---|
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 | */ |
---|
55 | class WeNNI : public NNI |
---|
56 | { |
---|
57 | public: |
---|
58 | /// |
---|
59 | /// Constructor |
---|
60 | /// |
---|
61 | WeNNI(const utility::Matrix& matrix,const utility::Matrix& weight, |
---|
62 | const unsigned int neighbours); |
---|
63 | |
---|
64 | /** |
---|
65 | \brief Function doing WeNNI imputation. |
---|
66 | |
---|
67 | Perform WeNNI on data in \a matrix with continuous uncertainty |
---|
68 | weights in \a weight using \a neighbours for the new impute |
---|
69 | value. |
---|
70 | |
---|
71 | The return value can be used as an indication of how well the |
---|
72 | imputation worked. The return value should be zero if proper |
---|
73 | pre-processing of data is done. An example of bad data is a |
---|
74 | matrix with a column of zero weights, another is a |
---|
75 | corresponding situation with a row with all weights zero. |
---|
76 | |
---|
77 | \return The number of rows that have at least one value not |
---|
78 | imputed. |
---|
79 | */ |
---|
80 | unsigned int estimate(void); |
---|
81 | |
---|
82 | /// |
---|
83 | /// @return A const reference to imputed_data_raw. |
---|
84 | /// |
---|
85 | const utility::Matrix& imputed_data_raw(void) const |
---|
86 | { return imputed_data_raw_; } |
---|
87 | |
---|
88 | |
---|
89 | private: |
---|
90 | |
---|
91 | utility::Matrix imputed_data_raw_; |
---|
92 | }; |
---|
93 | |
---|
94 | }}} // of namespace utility, yat, and theplu |
---|
95 | |
---|
96 | #endif |
---|