-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclusterer.h
52 lines (43 loc) · 1.55 KB
/
clusterer.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
#ifndef CONTROLLER_H
#define CONTROLLER_H
#include <mlpack/core.hpp>
#include <QObject>
#include <cmath>
#include <mlpack/methods/kmeans/kmeans.hpp>
#include <mlpack/methods/kmeans/refined_start.hpp>
#include <QMap>
#include "fstream"
#include <ctime>
#include <QProgressDialog>
class MainWindow;
using namespace mlpack;
using namespace mlpack::kmeans;
using namespace mlpack::metric;
class Clusterer : public QObject
{
Q_OBJECT
public:
Clusterer(arma::mat &dataset, const size_t clusters, int metric, int maxIterations, const QString &directory, const QString &file, QProgressBar * progress, bool testingMode);
void createFiles();
public slots:
void runClustering();
signals:
void finished(QString message, bool success);
private:
arma::mat dataset;
size_t clusters;
int metric;
int maxIterations;
QString directory;
QString file;
QProgressBar * progressBar;
bool testingMode;
QMap<int, arma::Col<double>> * calculateMeans (arma::mat data, arma::Row<size_t> originalAssignments);
arma::Row<double> getMean (arma::mat data, size_t startCol, size_t endCol);
QString pointToString(arma::mat &data, size_t pointColumn);
QString colToString(const arma::Col<double> &data);
QMap <int, int> clusterEquivalences(const QMap<int, arma::Col<double>> &originalCentroids, const arma::mat &newCentroids, int metric);
double getDistance (const arma::Col<double> &pointA, const arma::Col<double> &pointB, int metric);
void saveToFile (const std::string &path, QMap<int, arma::Col<double>> * dictionary);
};
#endif // CONTROLLER_H