IFD:EAI SoS21/course material/Session 4: Programming the Classifier Part1: Difference between revisions
From Medien Wiki
Line 1: | Line 1: | ||
=Homework= | =Homework= | ||
This week your task will be to modify the code from monday's session to work on n-dimensional data points. "N-dimensional" means the number of dimension can be chosen | This week your task will be to modify the code from monday's session to work on n-dimensional data points. "N-dimensional" means the number of dimension can be chosen when we instantiate the clusterer. So the same code should work for 2 dimension (as we programmed it already), 3 dimension, 4 dimensions and so on... | ||
Feel free to fork the repl.it and include a new class "PointND": | Feel free to fork the repl.it and include a new class "PointND": |
Revision as of 11:33, 5 May 2021
Homework
This week your task will be to modify the code from monday's session to work on n-dimensional data points. "N-dimensional" means the number of dimension can be chosen when we instantiate the clusterer. So the same code should work for 2 dimension (as we programmed it already), 3 dimension, 4 dimensions and so on...
Feel free to fork the repl.it and include a new class "PointND":
The Class PointND should should be structured as shown in the following header file:
#ifndef PointN_H
#define PointN_H
#include <vector>
using namespace std;
class PointND {
public:
PointND(int dimensions); // constructor for zero point of n-dimensions
PointND(vector<float> newND); // constructor for a point which copies the coordinates from an n-dimensional vector
PointND operator+(PointND& p2);
PointND operator/(float f);
float getDim(int idx_dimension); // get the component of the indexed dimension, (this was getX() and getY() before)
int size() // return how many dimension our current point has!
{
return _pointND.size();
}
void print();
float getDistance(PointND&); // extend the euclidean distance to n dimensions
private:
vector<float> _pointND;
};
#endif
Your task is to:
- Implement a PointND.cpp file that behaves like our class Point2D on n-dimensional points
- Test that class with a 3D distance measurement, and on success
- Modify our clusterer to work with the new PointND class!
Have fun and if you're stuck, write a mail or post a message in the forum!
Best wishes, Clemens