-
Notifications
You must be signed in to change notification settings - Fork 0
/
mlmodel.h
49 lines (49 loc) · 1.21 KB
/
mlmodel.h
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
#pragma once
#define MLMODEL_ASSERT(x) assert(x)
template<class DataType> class MLModel
{
/******************construct******************/
public:
MLModel()
{}
~MLModel()
{}
/******************communication******************/
virtual void sendMsg(char * msg)
{}
/******************data******************/
public:
virtual bool getTrainningData(DataType xData, DataType yData)
{
/*TrainningDataX:d*m矩阵*,d为属性数,m为样例数/
/*TrainningDataY:1*m矩阵,m为样例数*/
MLMODEL_ASSERT(isDataMatch(xData, yData));
TrainningDataX = xData;
TrainningDataY = yData;
return true;
}
virtual bool getTestData(DataType xData, DataType yData)
{
/*TrainningDataX:d*m矩阵*,d为属性数,m为样例数/
/*TrainningDataY:1*m矩阵,m为样例数*/
MLMODEL_ASSERT(isDataMatch(xData, yData));
TestDataX = xData;
TestDataY = yData;
return true;
}
virtual bool isDataMatch(DataType &xData, DataType &yData)
{
return true;
}
protected:
DataType TrainningDataX;
DataType TrainningDataY;
DataType TestDataX;
DataType TestDataY;
/******************learning method******************/
public:
virtual bool learn() = 0;
/******************recognition method******************/
public:
virtual DataType recognize(DataType input) = 0;
};