-
Notifications
You must be signed in to change notification settings - Fork 0
/
kmeans.h
67 lines (46 loc) · 1.98 KB
/
kmeans.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
58
59
60
61
62
63
64
65
66
67
//
// kmeans.h
// MovieGross
//
//
// Copyright © 2016 ArsenKevinMD. All rights reserved.
//
#ifndef kmeans_h
#define kmeans_h
#include <vector>
#include "movie.h"
//K-Means Clustering Namespace
namespace KmeansCluster {
//Data Structure to help K-Means Clustering
class KMeans{
private:
//setup three clusters for the clustering and two for last centroids and current centroids
std::vector<MovieData::Movie>cluster1,cluster2,cluster3,last,current,all;
public:
//method find the closest cluster to add
void addToClosest(MovieData::Movie&aMovie);
//method to initialize rand centroids and clusters
void initialize(std::vector<MovieData::Movie> movies);
//method to get the mean of a cluster
std::vector<float> mean(std::vector<MovieData::Movie>&cluster);
//method to get centroid closest to mean of cluster
MovieData::Movie getCentroid(std::vector<MovieData::Movie>&cluster,std::vector<float> mean);
//method to get the centroid of a cluster
MovieData::Movie centroid(std::vector<MovieData::Movie>&movies);
//method to setup centroids
bool setupCentroids();
//method to make the clusters
void cluster();
//method to get the distance from a point to rest of cluster
float avgDistance(std::vector<MovieData::Movie>&cluster,int index);
//method to find distance from cluster from a point
float distanceFromCluster(MovieData::Movie&c,std::vector<MovieData::Movie>&cluster);
//method to return silhoute value
float silh(std::vector<MovieData::Movie>&a,std::vector<MovieData::Movie>&b,int index);
//method to print the silhoute for each cluster
void printSil();
//method to predict movie gross
float predict(MovieData::Movie aMovie);
};
}
#endif /* kmeans_h */