-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFuzzyCMeans.h
112 lines (90 loc) · 2.23 KB
/
FuzzyCMeans.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#ifndef FUZZYCMEANS_H
#define FUZZYCMEANS_H
#include "DataTypes.h"
#include "Point.h"
#include "Cluster.h"
class FuzzyCMeans
{
/*!
* The dimension of the input data (i.e., number of features).
*/
int dimension;
/*!
* The number of clusters.
*/
int k;
/*!
*
* The maximum number of iterations for the algorithm to converge.
*/
int maxNumOfIterations;
/*!
* Fuzzifier.
*/
int m;
/*! The threshold controlling the convergence of the algorithm.
*
*/
double eps;
public:
/*!
* Data to be clustered.
*/
std::vector<Point> points;
/*!
* The clusters to be constructed
*/
std::vector<Cluster> clusters;
public:
/*!
* Constructor 1.
* @param dataFilename the name of the file in which the data to be clustered are stored.
* @param paramsFilename the name of the configuration file.
*/
FuzzyCMeans(std::string dataFilename, std::string paramsFilename);
/*!
* Constructor 2.
* @param dataFilename the name of the file in which the data to be clustered are stored.
* @param paramsFilename the name of the configuration file.
*/
FuzzyCMeans(std::string dataFilename, int dimension_, int k_, int maxNumOfIterations_, int m_, double eps_);
/*!
* Destructor.
*/
~FuzzyCMeans();
/*!
* It computes the clusters in every iteration of the algorithm.
*/
void computeClusters();
/*!
* It computes the membership coefficients of points to clusters in every iteration of the algorithm.
*/
void computeNewMembershipCoefficients();
/*!
* It updates the membership coefficients of points to clusters in every iteration of the algorithm.
*/
void updateMembershipCoefficients();
/*!
* It checks if the algorithm converged.
* @return true if the algorithm converged, false otherwise.
*/
bool isOver();
/*!
* It runs the Fuzzy c-means routine.
*/
void runFuzzyCMeans();
/*!
* It prints the partition matrix to the standard output.
*/
void printPartitionMatrix();
/*!
* It prints the centroids to the standard output.
*/
void printCentroids();
/*!
* It computes the value of the objective function that controls the convergence of the algorithm.
* @return the value of the objective function.
*/
double computeObjectiveFunction();
};
#endif // FUZZYCMEANS_H