-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
76 lines (51 loc) · 1.31 KB
/
main.cpp
File metadata and controls
76 lines (51 loc) · 1.31 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
#include <iostream>
#include "matrix/Matrix.h"
#include "data/data.h"
#include "cluster/kmeans.h"
#include "cluster/binaryKMeans.h"
using namespace std;
//void print(map<size_t, vector<double*>> m){
// for(auto &i : m){
// cout<<i.first<<endl;
// for(auto j : i.second){
// cout<<j[0]<<", "<<j[1]<<endl;
// }
// }
//}
//
//void printt(map<size_t, double*> barycenter){
// cout<<"100"<<endl;
// for(auto i : barycenter){
// cout<<i.second[0]<<", "<<i.second[1]<<endl;
// }
//}
int main() {
Matrix data = getData1();
data.print();
size_t width = 2;
size_t k = 3;
Time::passed();
Cluster* p = new BinaryKMeans(width, k);
p->fit(data);
print(p->kPoints);
printt(p->barycenter);
cout<<"costTime: "<<Time::passed()<<endl;
cout<<"totalError: "<<p->getInertia()<<endl;
vector<size_t> labels = p->getLabels(data);
for(auto i : labels){
cout<<i<<" ";
}
cout<<endl;
Time::passed();
Cluster* q = new KMeans(width, k);
q->fit(data);
print(q->kPoints);
printt(q->barycenter);
cout<<"costTime: "<<Time::passed()<<endl;
cout<<"totalError: "<<q->getInertia()<<endl;
vector<size_t> labels = q->getLabels(data);
for(auto i : labels){
cout<<i<<" ";
}
return 0;
}