vector<int> Forest::getGlobalDiscardedFeatureIndices() {
try {
- vector<int> globalDiscardedFeatureIndices;
+ //vector<int> globalDiscardedFeatureIndices;
+ //globalDiscardedFeatureIndices.push_back(1);
// calculate feature vectors
- vector< vector<int> > featureVectors(numFeatures, vector<int>(numSamples, 0));
+ vector< vector<int> > featureVectors(numFeatures, vector<int>(numSamples, 0) );
for (int i = 0; i < numSamples; i++) {
if (m->control_pressed) { return globalDiscardedFeatureIndices; }
for (int j = 0; j < numFeatures; j++) { featureVectors[j][i] = dataSet[i][j]; }
#include <iostream>
#include "mothurout.h"
#include "macros.h"
+#include "decisiontree.hpp"
#include "abstractdecisiontree.hpp"
/***********************************************************************/
//this is a re-implementation of the abstractrandomforest class
virtual int populateDecisionTrees() = 0;
virtual int calcForrestErrorRate() = 0;
virtual int calcForrestVariableImportance(string) = 0;
+ virtual int updateGlobalOutOfBagEstimates(DecisionTree* decisionTree) = 0;
/***********************************************************************/
/***********************************************************************/
RandomForest::RandomForest(const vector <vector<int> > dataSet,const int numDecisionTrees,
- const string treeSplitCriterion = "informationGain") : AbstractRandomForest(dataSet, numDecisionTrees, treeSplitCriterion) {
+ const string treeSplitCriterion = "informationGain") : Forest(dataSet, numDecisionTrees, treeSplitCriterion) {
m = MothurOut::getInstance();
}
//could cause maintenance issues later if other types of Abstract decison trees are created that cannot be cast as a decision tree.
for (int i = 0; i < decisionTrees.size(); i++) {
if (m->control_pressed) { return 0; }
+
DecisionTree* decisionTree = dynamic_cast<DecisionTree*>(decisionTrees[i]);
for (int j = 0; j < numFeatures; j++) {
}
/***********************************************************************/
// TODO: need to finalize bettween reference and pointer for DecisionTree [partially solved]
-// TODO: make this pure virtual in superclass
+// DONE: make this pure virtual in superclass
// DONE
int RandomForest::updateGlobalOutOfBagEstimates(DecisionTree* decisionTree) {
try {
#define rrf_fs_prototype_randomforest_hpp
#include "macros.h"
-#include "abstractrandomforest.hpp"
+#include "forest.h"
#include "decisiontree.hpp"
class RandomForest: public Forest {
//NOTE:: if you are going to dynamically cast, aren't you undoing the advantage of abstraction. Why abstract at all?
//could cause maintenance issues later if other types of Abstract decison trees are created that cannot be cast as a decision tree.
- virtual ~RandomForest() {
- for (vector<AbstractDecisionTree*>::iterator it = decisionTrees.begin(); it != decisionTrees.end(); it++) {
- // we know that this is decision tree, so we can do a dynamic_case<DecisionTree*> here
- DecisionTree* decisionTree = dynamic_cast<DecisionTree*>(*it);
- // calling the destructor by deleting
- delete decisionTree;
- }
- }
+// virtual ~RandomForest() {
+// for (vector<AbstractDecisionTree*>::iterator it = decisionTrees.begin(); it != decisionTrees.end(); it++) {
+// // we know that this is decision tree, so we can do a dynamic_case<DecisionTree*> here
+// DecisionTree* decisionTree = dynamic_cast<DecisionTree*>(*it);
+// // calling the destructor by deleting
+// delete decisionTree;
+// }
+// }
int calcForrestErrorRate();
int calcForrestVariableImportance(string);