-
Notifications
You must be signed in to change notification settings - Fork 5
/
LassoRegression.h
50 lines (28 loc) · 956 Bytes
/
LassoRegression.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
//
// Created by user on 08.10.2018.
//
#ifndef LASSOREGRESSION_LASSOREGRESSION_H
#define LASSOREGRESSION_LASSOREGRESSION_H
#include <vector>
class LassoRegression {
public:
double **features;
double *weights;
double *target;
unsigned long numberOfSamples;
unsigned long numberOfFeatures;
LassoRegression(std::vector<std::vector<double>> samples, std::vector<double> target);
double *predictions();
double *ro();
double coordinateDescentStep(int weightIdx, double alpha);
double *cyclicalCoordinateDescent(double tolerance, double alpha);
void dumpWeightsToFile();
private:
double **featuresMatrix(std::vector<std::vector<double>> samples);
double **normalizeFeatures(double **matrix);
double **emptyMatrix();
double *initialWeights();
double *targetAsArray(std::vector<double> target);
double *feature(int featureIdx);
};
#endif //LASSOREGRESSION_LASSOREGRESSION_H