-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
71 lines (49 loc) · 1.95 KB
/
main.cpp
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
#include <iostream>
#include <vector>
#include <array>
#include <fstream>
#include "map.h"
#include "json.h"
#include "linearregression.h"
using namespace std;
using json = nlohmann::json;
int main(){
Point2d a(0, 100);
Point2d b(100, 100);
Point2d c(100, 0);
vector<Point2d> rslt;
rslt = getBezierCurve(a, b, c, 100);
// label feature1 feature2
vector<array<double, 2>> features = getFeatureData(rslt);
vector<array<double, 2>> labels = getLabeldata(rslt);
json jsonfile;
auto line1 = json::array();
line1.push_back(json::array( {0, 0} ));
line1.push_back(json::array( {0, 200} ));
auto line2 = json::array();
line2.push_back(json::array( {0, 0} ));
line2.push_back(json::array( {200, 0} ));
jsonfile["line1"] = line1;
jsonfile["line2"] = line2;
jsonfile["p0"] = json::array({ 100, 100 }); // control point
jsonfile["p1"] = json::array({ 0, 100 });// mid point of l1
jsonfile["p2"] = json::array({ 100, 0 });// mid point of l2
cout << " getTrainData here no plobrem..." << features.size() << endl;
jsonfile["features"] = json::array();
jsonfile["labels"] = json::array();
for(int i=0; i< features.size(); i++){
// cout << "getTrainData features: "<< data[i][0] << ' ' << data[i][1] << " --- label: " << data[i][2] << ' ' << data[i][3] << endl;
jsonfile["features"].push_back(json::array( {features[i][0], features[i][1]}));
}
for(int i=0; i< labels.size(); i++){
// cout << "getTrainData features: "<< data[i][0] << ' ' << data[i][1] << " --- label: " << data[i][2] << ' ' << data[i][3] << endl;
jsonfile["labels"].push_back(json::array( {labels[i][0], labels[i][1]}));
}
string filename = "data.json";
ofstream file(filename);
file << setw(4) << jsonfile << endl;
file.close();
cout << "Saved successfully at " << filename << endl;
LinearRegression lr (features, labels);
return 0;
}