-
Notifications
You must be signed in to change notification settings - Fork 2
/
additiveModel.h
106 lines (78 loc) · 2.3 KB
/
additiveModel.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* Author : Subhransu Maji
*
* Headers for additive model
*
* Version 1.0
*/
#ifndef _ADDITIVEMODEL_H
#define _ADDITIVEMODEL_H
// problem parameters
struct parameter {
//encoding type(0 splines, 1 Fourier, 2 Hermite)
int encoding;
// basis degree (0 constant, 1 linear, 2 quadratic, 3 cubic)
int degree;
// regularization degree (0 identity, 1 first derviative, 2 second derivative)
int reg;
//number of pices of spline (#knots-1)
int numbins;
//bias term added to the data
double bias;
//regularization parameters for pos/neg
double Cp;
double Cn;
//dual violation epsilon
double eps;
};
// possible encodings
enum ENCODING {SPLINE, TRIGONOMETRIC, HERMITE};
//spline model
class additiveModel{
public:
//encoding type(0 splines, 1 Fourier, 2 Hermite)
int encoding;
// basis degree (0 constant, 1 linear, 2 quadratic, 3 cubic for splines|deg for Fourier,Hermite )
int degree;
// regularization degree (0 identity, 1 first derviative, 2 second derivative)
int reg;
//number of divisions of the data
int numbins;
//number of basis functions
int numbasis;
// training data dimensions
int dim;
// weight dimension
int wdim;
//min and max of each data dimension
double *xmin;
double *xmax;
//mean and variance of each data dimesion
double *xmean;
double *xvar;
//learned model and bias
double *w;
double bias;
//parameters for the encoding
double *st; //square root step size
double *a;
double *b;
// weights to normalize the dimensions
double *dimwts;
//constructors
additiveModel();
additiveModel(const parameter *, double **, int, int);
//methods
void train(double **x, const double *, const int, const parameter *);
void predict(double **, double *, double *, const int);
void getAccuracy(double *, double *, const int, int&, double&, double&, double& );
void display();
void getBasisIndex(double x, int dimidx, int &ei, double &ai);
void bSplineEncoder(double x, int dimidx, int &ei, double *wts);
void trigEncoder(double x, int dimidx, double *wts);
void hermiteEncoder(double x, int dimidx, double *wts);
void projectDense(int ei, double *wts, double st, double *wd);
void projectDenseW(int ei, double *wts, double st, double *wd);
//desctructor
~additiveModel();
};
#endif