-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataPoint.h
More file actions
33 lines (27 loc) · 834 Bytes
/
DataPoint.h
File metadata and controls
33 lines (27 loc) · 834 Bytes
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
//
// Created by dhruva on 4/9/25.
//
#ifndef DATAPOINT_H
#define DATAPOINT_H
#include <string>
#include <utility>
#include <vector>
struct DataPoint {
std::vector<float> features;
std::string label;
DataPoint()
{
this->features = std::vector<float>();
this->label = "";
}
DataPoint(std::vector<float> features, std::string label)
{
this->features = std::move(features);
this->label = std::move(label);
}
std::string toString() const;
static double calculateEuclideanDistance(const DataPoint &a, const DataPoint &b);
static std::vector<DataPoint> findKClosestPoints(const DataPoint& datapoint, const std::vector<DataPoint> &dataPoints, int k);
static std::string findMajorityLabel(const std::vector<DataPoint> &neighbours);
};
#endif //DATAPOINT_H