forked from mothur/mothur
-
Notifications
You must be signed in to change notification settings - Fork 1
/
abstractdecisiontree.hpp
executable file
·77 lines (56 loc) · 2.66 KB
/
abstractdecisiontree.hpp
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// abstractdecisiontree.hpp
// rrf-fs-prototype
//
// Created by Abu Zaher Faridee on 7/22/12.
// Copyright (c) 2012 Schloss Lab. All rights reserved.
//
#ifndef RF_ABSTRACTDECISIONTREE_HPP
#define RF_ABSTRACTDECISIONTREE_HPP
#include "mothurout.h"
#include "macros.h"
#include "rftreenode.hpp"
#define DEBUG_MODE
/**************************************************************************************************/
struct IntPairVectorSorter{
bool operator() (const pair<int, int>& firstPair, const pair<int, int>& secondPair) {
return firstPair.first < secondPair.first;
}
};
/**************************************************************************************************/
class AbstractDecisionTree{
public:
AbstractDecisionTree(vector<vector<int> >& baseDataSet,
vector<int> globalDiscardedFeatureIndices,
OptimumFeatureSubsetSelector optimumFeatureSubsetSelector,
string treeSplitCriterion);
virtual ~AbstractDecisionTree(){}
protected:
virtual int createBootStrappedSamples();
virtual int getMinEntropyOfFeature(vector<int> featureVector, vector<int> outputVector, double& minEntropy, int& featureSplitValue, double& intrinsicValue);
virtual int getBestSplitAndMinEntropy(vector< pair<int, int> > featureOutputPairs, vector<int> splitPoints, double& minEntropy, int& minEntropyIndex, double& relatedIntrinsicValue);
virtual double calcIntrinsicValue(int numLessThanValueAtSplitPoint, int numGreaterThanValueAtSplitPoint, int numSamples);
virtual double calcSplitEntropy(vector< pair<int, int> > featureOutputPairs, int splitIndex, int numOutputClasses, bool);
virtual int getSplitPopulation(RFTreeNode* node, vector< vector<int> >& leftChildSamples, vector< vector<int> >& rightChildSamples);
virtual bool checkIfAlreadyClassified(RFTreeNode* treeNode, int& outputClass);
vector< vector<int> >& baseDataSet;
int numSamples;
int numFeatures;
int numOutputClasses;
vector<int> outputClasses;
vector< vector<int> > bootstrappedTrainingSamples;
vector<int> bootstrappedTrainingSampleIndices;
vector< vector<int> > bootstrappedTestSamples;
vector<int> bootstrappedTestSampleIndices;
vector<vector<int> > testSampleFeatureVectors;
RFTreeNode* rootNode;
int nodeIdCount;
map<int, int> nodeMisclassificationCounts;
vector<int> globalDiscardedFeatureIndices;
int optimumFeatureSubsetSize;
string treeSplitCriterion;
MothurOut* m;
private:
};
/**************************************************************************************************/
#endif