-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclassifier.hpp
More file actions
50 lines (44 loc) · 1.33 KB
/
classifier.hpp
File metadata and controls
50 lines (44 loc) · 1.33 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef classifier_hpp
#define classifier_hpp
#include <stdio.h>
#include <iostream>
#include <string>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
struct d{
double height, weight;
int label;
};
class Classifier{
private:
int mathModel;
double p[2];
double pWeight[2][250], pHeight[2][250];
int counts[2];
double ExW[2], DxW[2], ExH[2], DxH[2]; //матожидание&дисперсия
double H; //коэфф сглаживания
vector<d>train_set;
void readTrainFile(ifstream &F);
vector<pair<double, double>> readTestFile(ifstream &F);
double probability(double h, double w, int label);
int findNext(int i, double *arr);
public:
Classifier();
~Classifier();
friend Classifier barChart(Classifier A);
friend Classifier normalDistribution (Classifier A);
friend Classifier parzanRozenblatt (Classifier A);
void train(ifstream &F, Classifier (*f)(Classifier A));
void train(vector<d>input, Classifier (*f)(Classifier A));
vector<int> classify(ifstream &F);
vector<int> classify(vector<pair<double, double>>input);
};
Classifier barChart(Classifier A);
Classifier normalDistribution (Classifier A);
Classifier parzanRozenblatt (Classifier A);
#endif /* classifier_hpp */