-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
46 lines (34 loc) · 995 Bytes
/
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
#include "include/fileutils.h"
#include "include/kmeans.h"
#include "include/centroid.h"
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
#include <chrono>
#include <unistd.h>
#include <ratio>
#include <stdlib.h>
#include <stdio.h>
typedef std::chrono::high_resolution_clock Time;
typedef std::chrono::milliseconds ms;
typedef std::chrono::duration<float> fsec;
using namespace fileutils;
int main(int argc, char *argv[])
{
if(argc < 3)
{
std::cerr << "Please provide a path to data, the number of max iterations, and the number of clusters to initialize." << std::endl;
return -1;
}
std::string data_path = argv[1];
int iterations = atoi(argv[2]);
int K = atoi(argv[3]);
std::vector<CrimeRecord> records = parseCSV(data_path);
KMeans kmeans(K, iterations);
kmeans.Initialize(records);
kmeans.Run();
//kmeans.WriteCentroidsToFile("results/CentroidsLocation.txt");
//kmeans.WriteAllToFile("results/Points.txt");
return 0;
}