-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathml.cpp
More file actions
81 lines (72 loc) · 1.51 KB
/
ml.cpp
File metadata and controls
81 lines (72 loc) · 1.51 KB
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
/* ml.cpp */
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
class matrix {
};
class vector {
};
class regressor {
public:
virtual void fit(matrix train_x, vector train_y) = 0;
virtual vector predict(matrix test_x) = 0;
};
class linearRegressor : public regressor {
vector parameters;
public:
void fit(matrix train_x, vector _train_y){
};
vector predict(matrix test_x){
vector est_y;
return est_y;
};
};
class polyRegressor : public regressor {
vector parameters;
public:
void fit(matrix train_x, vector _train_y){
};
vector predict(matrix test_x){
vector est_y;
return est_y;
};
};
class gpRegressor : public regressor {
vector parameters;
public:
void fit(matrix train_x, vector _train_y){
};
vector predict(matrix test_x){
vector est_y;
return est_y;
};
};
class noRegressorException {
};
class regressorCreator {
public:
static regressor* create(string regressorType){
if(regressorType == "linear"){
return new linearRegressor;
}else if(regressorType == "poly"){
return new polyRegressor;
}else if(regressorType == "gp"){
return new gpRegressor;
}else{
throw new noRegressorException;
}
}
};
int main()
{
string regressorType;
matrix train_x, test_x;
vector train_y, est_y;
regressorCreator rc;
cout << "どの回帰モデルを使いますか?" << endl;
cin >> regressorType;
regressor* rp = rc.create(regressorType);
rp->fit(train_x, train_y);
est_y = rp->predict(test_x);
}