Closed Kiyoshika closed 3 years ago
Implemented in v0.5.0.1 branch (in progress as of 1 August 2021)
#include <iostream>
#include "data/DataSet.h"
#include "models/clustering/KMeans.h"
using namespace std;
int main() {
DataSet xdata;
// a sample data set with unlabeled decimal values
xdata.load("test.csv");
// k = 3, max_iter = 1000
Cluster *kmeans = new KMeans(3, 1000);
vector<int> clusters = kmeans->fit(xdata.cast_data_double());
for (int i = 0; i < clusters.size(); ++i)
{
cout << clusters[i] << " ";
}
delete kmeans;
return 0;
}
Implement KMeans clustering algorithm.