forked from cuteboydot/Bayes-classification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NaiveBayesDocument.h
45 lines (35 loc) · 1.1 KB
/
NaiveBayesDocument.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
#pragma once
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <stdio.h>
#include <float.h>
typedef struct inputdata {
int nCnt;
int * pData;
int nClass;
} INPUTDATA;
class CNaiveBayesDocument
{
public:
CNaiveBayesDocument(void);
~CNaiveBayesDocument(void);
void init(int nSizeOutputPattern, int nSizeDocWords, int nSizeRecord, INPUTDATA ** ppDataList, bool bUseSmooth);
void train();
void classfication(INPUTDATA * pData);
private:
// datas for training
int m_nSizeOutputPattern; // number of output pattern
int m_nSizeDocWords; // number of words in input datas
int m_nSizeRecord; // number of records
INPUTDATA ** m_ppDataList; // input datas of records
bool m_bUseSmooth;
// prob parameters
int * m_pNumClass; // number of records in each class
int * m_pNumTotWordClass; // number of total words in each class
int ** m_ppNumWordClass; // number of each word in each class
double * m_pProbClass; // 𝑷(𝒄)
double ** m_ppProbWordClass; // 𝑷(𝒙|𝒄), sum of xi = d
};