-
Notifications
You must be signed in to change notification settings - Fork 6
/
knnr.h
73 lines (54 loc) · 1.34 KB
/
knnr.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef KNNR_H
#define KNNR_H
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <math.h>
#include <stdio.h>
using namespace std;
#include "stringtools.h"
#include "utils.h"
#include "print.h"
class KNNR {
private:
double* distances;
double* values;
double* values_print;
int fsize;
int ptskip; //for getting nn
int nlw;
void get_distances(int npts, double* X);
void filter_positive(int k, double* knnd, double* knnw, int* knn);
int find_knn(double* X1, int k, int* knn, double* knnd);
int find_knn(int pt, int k, int* knn, double* knnd);
int check_unique(int pt);
void determine_active();
void reassign_mem(int npts1);
public:
double LOW_WEIGHT;
double pthresh;
double sumw;
double sumd;
int npts;
int knn_N;
int quiet;
double* active; //active features
int* udata; //use these data points
double* X;
int* ids;
double* errlist;
int* knnlist;
double test_points(int k);
double predict_point(int pt, int k);
double predict_point(double* X1, int k);
void load_values(int npts1, int fsize1, double* X1, double* y1);
void load_values_print(int npts1, double* y1);
double get_distance(double* X1, double* X2);
void init();
void reset_active();
void freemem();
};
#endif