-
Notifications
You must be signed in to change notification settings - Fork 0
/
mlr.h
57 lines (48 loc) · 1.43 KB
/
mlr.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
// SWAMI KARUPPASWAMI THUNNAI
#pragma once
#define DEBUG 1
#define NODEBUG 0
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <future>
#include <mutex>
#include "dataioclass.h"
#include "itrainpredict.h"
/*
Similar class of scikit-learn's GaussianNB
Written By: Visweswaran N on 2019-09-02
Edited By: https://github.com/JUNZ1 Aug/2020
*/
class LinearRegression : public DataIOClass, public ITrainPredict
{
private:
// Independent variable X
std::vector<std::vector<double>> X={};
std::vector<double> y;
std::vector<double> bias;
unsigned short int verbose=0;
private:
void print(std::string message);
public:
LinearRegression();
LinearRegression(const LinearRegression& copyFromThis);
LinearRegression(LinearRegression&& moveFromThis);
LinearRegression(std::string model_name);
virtual ~LinearRegression(){};
LinearRegression& operator = (const LinearRegression& copyFromThis);
LinearRegression& operator = (LinearRegression&& moveFromThis);
LinearRegression(std::vector<std::vector<double>> X, std::vector<double> y, unsigned short int verbose) : X(X), y(y), verbose(verbose) {};
public:
void fit();
double predict(std::vector<double> test);
void save_model(std::string model_name);
std::vector<double> get_bias();
public: //Overrited Interfaces
void Train() override;
std::vector<double> Predict(std::vector<double>) override;
private:
std::future<void> TrainFuture;
std::mutex _trainingMutex;
};