680 |
11 Oct 06 |
jari |
1 |
#ifndef _theplu_yat_utility_knni_ |
4200 |
19 Aug 22 |
peter |
2 |
#define _theplu_yat_utility_knni_ |
616 |
31 Aug 06 |
jari |
3 |
|
145 |
05 Sep 04 |
jari |
// $Id$ |
145 |
05 Sep 04 |
jari |
5 |
|
570 |
05 Apr 06 |
jari |
6 |
/* |
2119 |
12 Dec 09 |
peter |
Copyright (C) 2004 Jari Häkkinen |
2119 |
12 Dec 09 |
peter |
Copyright (C) 2005 Jari Häkkinen, Peter Johansson |
2119 |
12 Dec 09 |
peter |
Copyright (C) 2006 Jari Häkkinen |
4359 |
23 Aug 23 |
peter |
Copyright (C) 2007 Peter Johansson |
4359 |
23 Aug 23 |
peter |
Copyright (C) 2008 Jari Häkkinen, Peter Johansson |
2119 |
12 Dec 09 |
peter |
Copyright (C) 2009 Jari Häkkinen |
4207 |
26 Aug 22 |
peter |
Copyright (C) 2022 Peter Johansson |
570 |
05 Apr 06 |
jari |
14 |
|
1437 |
25 Aug 08 |
peter |
This file is part of the yat library, http://dev.thep.lu.se/yat |
570 |
05 Apr 06 |
jari |
16 |
|
675 |
10 Oct 06 |
jari |
The yat library is free software; you can redistribute it and/or |
675 |
10 Oct 06 |
jari |
modify it under the terms of the GNU General Public License as |
1486 |
09 Sep 08 |
jari |
published by the Free Software Foundation; either version 3 of the |
675 |
10 Oct 06 |
jari |
License, or (at your option) any later version. |
570 |
05 Apr 06 |
jari |
21 |
|
675 |
10 Oct 06 |
jari |
The yat library is distributed in the hope that it will be useful, |
675 |
10 Oct 06 |
jari |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
675 |
10 Oct 06 |
jari |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
570 |
05 Apr 06 |
jari |
General Public License for more details. |
570 |
05 Apr 06 |
jari |
26 |
|
570 |
05 Apr 06 |
jari |
You should have received a copy of the GNU General Public License |
1487 |
10 Sep 08 |
jari |
along with yat. If not, see <http://www.gnu.org/licenses/>. |
570 |
05 Apr 06 |
jari |
29 |
*/ |
570 |
05 Apr 06 |
jari |
30 |
|
680 |
11 Oct 06 |
jari |
31 |
#include "NNI.h" |
145 |
05 Sep 04 |
jari |
32 |
|
145 |
05 Sep 04 |
jari |
33 |
#include <vector> |
145 |
05 Sep 04 |
jari |
34 |
|
145 |
05 Sep 04 |
jari |
35 |
namespace theplu { |
680 |
11 Oct 06 |
jari |
36 |
namespace yat { |
301 |
30 Apr 05 |
peter |
37 |
namespace utility { |
145 |
05 Sep 04 |
jari |
38 |
|
145 |
05 Sep 04 |
jari |
39 |
/// |
767 |
22 Feb 07 |
peter |
/// @brief kNNimpute |
767 |
22 Feb 07 |
peter |
41 |
/// |
177 |
01 Oct 04 |
jari |
/// kNNI is the binary weight implementation of NNI. This follows |
178 |
01 Oct 04 |
jari |
/// the work done by Troyanskaya et al. cited in the NNI document |
177 |
01 Oct 04 |
jari |
/// referred to in the NNI class documentation. |
145 |
05 Sep 04 |
jari |
45 |
/// |
177 |
01 Oct 04 |
jari |
/// This is a special case of the WeNNI, but is maintained since it |
177 |
01 Oct 04 |
jari |
/// is faster than the more general WeNNI. |
177 |
01 Oct 04 |
jari |
48 |
/// |
177 |
01 Oct 04 |
jari |
/// @see NNI and WeNNI |
177 |
01 Oct 04 |
jari |
50 |
/// |
145 |
05 Sep 04 |
jari |
51 |
class kNNI : public NNI |
145 |
05 Sep 04 |
jari |
52 |
{ |
145 |
05 Sep 04 |
jari |
53 |
public: |
228 |
01 Feb 05 |
peter |
54 |
/// |
228 |
01 Feb 05 |
peter |
/// Constructor |
228 |
01 Feb 05 |
peter |
56 |
/// |
4125 |
14 Jan 22 |
peter |
57 |
kNNI(const MatrixBase& matrix, const MatrixBase& weight, |
1271 |
09 Apr 08 |
peter |
58 |
const unsigned int neighbours); |
228 |
01 Feb 05 |
peter |
59 |
|
1726 |
15 Jan 09 |
jari |
60 |
/** |
1726 |
15 Jan 09 |
jari |
\brief Function doing kNNI imputation. |
1726 |
15 Jan 09 |
jari |
62 |
|
1726 |
15 Jan 09 |
jari |
Perform kNNI on data in \a matrix with binary uncertainty |
1726 |
15 Jan 09 |
jari |
weights in \a weight using \a neighbours for the new impute |
1726 |
15 Jan 09 |
jari |
value. |
1726 |
15 Jan 09 |
jari |
66 |
|
1726 |
15 Jan 09 |
jari |
The return value can be used as an indication of how well the |
1726 |
15 Jan 09 |
jari |
imputation worked. The return value should be zero if proper |
1726 |
15 Jan 09 |
jari |
pre-processing of data is done. An example of bad data is a |
1726 |
15 Jan 09 |
jari |
matrix with a column of zero weights, another is a |
1726 |
15 Jan 09 |
jari |
corresponding situation with a row with all weights zero. |
1726 |
15 Jan 09 |
jari |
72 |
|
1726 |
15 Jan 09 |
jari |
\return The number of rows that have at least one value not |
1726 |
15 Jan 09 |
jari |
imputed. |
1726 |
15 Jan 09 |
jari |
75 |
*/ |
1271 |
09 Apr 08 |
peter |
76 |
unsigned int estimate(void); |
146 |
08 Sep 04 |
jari |
77 |
|
146 |
08 Sep 04 |
jari |
78 |
private: |
1271 |
09 Apr 08 |
peter |
79 |
std::vector<size_t> mv_rows_; // index to rows that have values to estimate |
145 |
05 Sep 04 |
jari |
80 |
}; |
145 |
05 Sep 04 |
jari |
81 |
|
687 |
16 Oct 06 |
jari |
82 |
}}} // of namespace utility, yat, and theplu |
145 |
05 Sep 04 |
jari |
83 |
|
145 |
05 Sep 04 |
jari |
84 |
#endif |