IFD:EAI SoS21/course material/Session 4: Programming the Classifier Part1: Difference between revisions
From Medien Wiki
(Created page with "=Homework= This week your task will be to modify the code from monday's session to work on n-dimensional data points. Clusterer-2D Feel free to fork the repl.it and in...") |
|||
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. | 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 by the user. 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": | |||
[https://replit.com/@abnutzer/SoSe2021-Clusterer2D Clusterer-2D] | |||
The Class PointND should should be structured as shown in the following header file: | The Class PointND should should be structured as shown in the following header file: | ||
<syntaxhighlight lang="c++"> | <syntaxhighlight lang="c++"> | ||
Line 41: | Line 42: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
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! | |||
Revision as of 10:45, 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 by the user. 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