-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathKnn.h
52 lines (43 loc) · 1.56 KB
/
Knn.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Knn.h
// k nearest neighbors
#ifndef KNN_H
#define KNN_H
#include "KnnCache.h"
// determine indices of nearest neighbors to inputs[queryIndex] in inputs[][]
// exclude query point from these indices
extern void Knn_nearest_indices(unsigned nObs,
unsigned nDims,
double *inputsP, // inputs[nObs][nDims],
unsigned nNeighbors,
unsigned *indicesP, // indices[nNeighbors]
unsigned queryIndex);
// re-estimate an existing observation
// don't use the observation in the estimate
// return the estimate
// queryIndex must be in the cache
extern double Knn_reestimate_queryIndex(unsigned nObs,
unsigned nDims,
double *inputsP, // inputs[nObs][nDims],
double *targetsP, // targets[nObs],
unsigned k,
unsigned queryIndex,
unsigned nNeighbors,
KnnCache_T cache);
// estimate a new observation
// return the estimate
extern double Knn_estimate_query(unsigned nObs,
unsigned nDims,
double *inputsP, // inputs[nObs][nDims],
double *targetsP, // targets[nObs],
unsigned k,
double *queryP); // query[nDims]);
// re-estimate an existing observation
// use the observation in the estimate
extern double Knn_smooth(unsigned nObs,
unsigned nDims,
double *inputsP, // inputs[nObs][nDims],
double *targetsP, // targets[nObs],
unsigned k,
unsigned queryIndex);
#undef T
#endif