721
edits
Line 33: | Line 33: | ||
We will feed this data into the classifier via two vectors. The first vector contains all the points and the second one contains the class labels. Note that the indices of the points and class labels should be the same. Such that, when we traverse the vector of points in a for-loop, we can always find out which class it belongs to, by just looking at the same position (index) in the vector with class labels. | We will feed this data into the classifier via two vectors. The first vector contains all the points and the second one contains the class labels. Note that the indices of the points and class labels should be the same. Such that, when we traverse the vector of points in a for-loop, we can always find out which class it belongs to, by just looking at the same position (index) in the vector with class labels. | ||
<syntaxhighlight lang="c++"> | |||
vector<Point2D> points = {p0, p1, p2, p3}; | |||
vector<int> classLabels = {0, 0, 1, 1}; | |||
KMeans clusterer = KMeans(points, classLabels, 2); | |||
</syntaxhighlight> | |||
There are a few new elements that we added to our code this week. We added a new class called 'KMeans'. Inside this class will be the guts of our classifier. | There are a few new elements that we added to our code this week. We added a new class called 'KMeans'. Inside this class will be the guts of our classifier. |