-
Notifications
You must be signed in to change notification settings - Fork 0
/
DRandomForest.h
51 lines (32 loc) · 966 Bytes
/
DRandomForest.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
#include "DTree.h"
#include <ctime>
#include "ThreadPool.h"
class DRandomForest
{
private:
std::vector<DTree> decisionTrees;
unsigned int threadCount;
unsigned int dtreeCount;
unsigned int maxDepth;
unsigned int minSamplesPerSplit;
unsigned int minSamplesPerLeaf;
double impurityThreshold;
double outOfBagError;
bool bootstrappingAllowed;
bool regression;
bool isTrained;
bool multithread;
ImpurityFunctor impurityFunction;
FeatureFunctor featureFunction;
void multiThreadFit(const DData&, unsigned int);
void calculateOutOfBagError();
public:
DRandomForest(unsigned int = 200, unsigned int = 7, unsigned int = 1, unsigned int = 1, double = 0.01,
bool = true, bool = false, bool = true, ImpurityFunctor = calculateShannonEntropy, FeatureFunctor = squareRoot);
void fit(const DData&);
void reset();
DValue classify(const DSample&)const;
bool classifyBatch(const DData&)const;
double getOutOfBagError()const;
};