|
@@ -1,5 +1,5 @@
|
|
|
/**
|
|
|
- * @file DTBOblique.cpp
|
|
|
+ * @file DTBObliqueLS.cpp
|
|
|
* @brief random oblique decision tree
|
|
|
* @author Sven Sickert
|
|
|
* @date 10/15/2014
|
|
@@ -8,7 +8,7 @@
|
|
|
#include <iostream>
|
|
|
#include <time.h>
|
|
|
|
|
|
-#include "DTBOblique.h"
|
|
|
+#include "DTBObliqueLS.h"
|
|
|
#include "vislearning/features/fpfeatures/ConvolutionFeature.h"
|
|
|
|
|
|
#include "core/vector/Algorithms.h"
|
|
@@ -21,7 +21,7 @@ using namespace OBJREC;
|
|
|
using namespace std;
|
|
|
using namespace NICE;
|
|
|
|
|
|
-DTBOblique::DTBOblique ( const Config *conf, string section )
|
|
|
+DTBObliqueLS::DTBObliqueLS ( const Config *conf, string section )
|
|
|
{
|
|
|
saveIndices = conf->gB( section, "save_indices", false);
|
|
|
useShannonEntropy = conf->gB( section, "use_shannon_entropy", false );
|
|
@@ -39,12 +39,12 @@ DTBOblique::DTBOblique ( const Config *conf, string section )
|
|
|
|
|
|
}
|
|
|
|
|
|
-DTBOblique::~DTBOblique()
|
|
|
+DTBObliqueLS::~DTBObliqueLS()
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
-bool DTBOblique::entropyLeftRight (
|
|
|
+bool DTBObliqueLS::entropyLeftRight (
|
|
|
const FeatureValuesUnsorted & values,
|
|
|
double threshold,
|
|
|
double* stat_left,
|
|
@@ -94,7 +94,7 @@ bool DTBOblique::entropyLeftRight (
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-bool DTBOblique::adaptDataAndLabelForMultiClass (
|
|
|
+bool DTBObliqueLS::adaptDataAndLabelForMultiClass (
|
|
|
const int posClass,
|
|
|
const int negClass,
|
|
|
NICE::Matrix & X,
|
|
@@ -146,7 +146,7 @@ bool DTBOblique::adaptDataAndLabelForMultiClass (
|
|
|
}
|
|
|
|
|
|
/** refresh data matrix X and label vector y */
|
|
|
-void DTBOblique::getDataAndLabel(
|
|
|
+void DTBObliqueLS::getDataAndLabel(
|
|
|
const FeaturePool &fp,
|
|
|
const Examples &examples,
|
|
|
const std::vector<int> &examples_selection,
|
|
@@ -184,7 +184,7 @@ void DTBOblique::getDataAndLabel(
|
|
|
|
|
|
}
|
|
|
|
|
|
-void DTBOblique::regularizeDataMatrix(
|
|
|
+void DTBObliqueLS::regularizeDataMatrix(
|
|
|
const NICE::Matrix &X,
|
|
|
NICE::Matrix &XTXreg,
|
|
|
const int regOption,
|
|
@@ -255,13 +255,13 @@ void DTBOblique::regularizeDataMatrix(
|
|
|
|
|
|
// no regularization
|
|
|
default:
|
|
|
- std::cerr << "DTBOblique::regularizeDataMatrix: No regularization applied!"
|
|
|
+ std::cerr << "DTBObliqueLS::regularizeDataMatrix: No regularization applied!"
|
|
|
<< std::endl;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void DTBOblique::findBestSplitThreshold (
|
|
|
+void DTBObliqueLS::findBestSplitThreshold (
|
|
|
FeatureValuesUnsorted &values,
|
|
|
SplitInfo &bestSplitInfo,
|
|
|
const NICE::Vector &beta,
|
|
@@ -274,7 +274,7 @@ void DTBOblique::findBestSplitThreshold (
|
|
|
double maxValue = (max_element ( values.begin(), values.end() ))->first;
|
|
|
|
|
|
if ( maxValue - minValue < 1e-7 )
|
|
|
- std::cerr << "DTBOblique: Difference between min and max of features values to small!"
|
|
|
+ std::cerr << "DTBObliqueLS: Difference between min and max of features values to small!"
|
|
|
<< " [" << minValue << "," << maxValue << "]" << std::endl;
|
|
|
|
|
|
// get best thresholds using complete search
|
|
@@ -331,7 +331,7 @@ void DTBOblique::findBestSplitThreshold (
|
|
|
}
|
|
|
|
|
|
/** recursive building method */
|
|
|
-DecisionNode *DTBOblique::buildRecursive(
|
|
|
+DecisionNode *DTBObliqueLS::buildRecursive(
|
|
|
const FeaturePool & fp,
|
|
|
const Examples & examples,
|
|
|
std::vector<int> & examples_selection,
|
|
@@ -343,7 +343,7 @@ DecisionNode *DTBOblique::buildRecursive(
|
|
|
{
|
|
|
|
|
|
#ifdef DEBUGTREE
|
|
|
- std::cerr << "DTBOblique: Examples: " << (int)examples_selection.size()
|
|
|
+ std::cerr << "DTBObliqueLS: Examples: " << (int)examples_selection.size()
|
|
|
<< ", Depth: " << (int)depth << ", Entropy: " << e << std::endl;
|
|
|
#endif
|
|
|
|
|
@@ -358,7 +358,7 @@ DecisionNode *DTBOblique::buildRecursive(
|
|
|
|
|
|
{
|
|
|
#ifdef DEBUGTREE
|
|
|
- std::cerr << "DTBOblique: Stopping criteria applied!" << std::endl;
|
|
|
+ std::cerr << "DTBObliqueLS: Stopping criteria applied!" << std::endl;
|
|
|
#endif
|
|
|
node->trainExamplesIndices = examples_selection;
|
|
|
return node;
|
|
@@ -427,6 +427,10 @@ DecisionNode *DTBOblique::buildRecursive(
|
|
|
gotInnerIteration = true;
|
|
|
}
|
|
|
}
|
|
|
+// f->setRandomParameterVector();
|
|
|
+// beta = f->getParameterVector();
|
|
|
+// f->calcFeatureValues( examples, examples_selection, values);
|
|
|
+// findBestSplitThreshold ( values, bestSplitInfo, beta, e, maxClassNo );
|
|
|
|
|
|
// supress strange behaviour for values near zero (8.88178e-16)
|
|
|
if (bestSplitInfo.entropyLeft < 1.0e-10 ) bestSplitInfo.entropyLeft = 0.0;
|
|
@@ -436,7 +440,7 @@ DecisionNode *DTBOblique::buildRecursive(
|
|
|
if ( bestSplitInfo.informationGain < minimumInformationGain )
|
|
|
{
|
|
|
#ifdef DEBUGTREE
|
|
|
- std::cerr << "DTBOblique: Minimum information gain reached!" << std::endl;
|
|
|
+ std::cerr << "DTBObliqueLS: Minimum information gain reached!" << std::endl;
|
|
|
#endif
|
|
|
delete [] bestSplitInfo.distLeft;
|
|
|
delete [] bestSplitInfo.distRight;
|
|
@@ -469,7 +473,7 @@ DecisionNode *DTBOblique::buildRecursive(
|
|
|
#ifdef DEBUGTREE
|
|
|
// node->f->store( std::cerr );
|
|
|
// std::cerr << std::endl;
|
|
|
- std::cerr << "DTBOblique: Information Gain: " << bestSplitInfo.informationGain
|
|
|
+ std::cerr << "DTBObliqueLS: Information Gain: " << bestSplitInfo.informationGain
|
|
|
<< ", Left Entropy: " << bestSplitInfo.entropyLeft << ", Right Entropy: "
|
|
|
<< bestSplitInfo.entropyRight << std::endl;
|
|
|
#endif
|
|
@@ -485,7 +489,7 @@ DecisionNode *DTBOblique::buildRecursive(
|
|
|
if ( r != 0 )
|
|
|
distribution_right_sparse[k] = r;
|
|
|
//#ifdef DEBUGTREE
|
|
|
-// std::cerr << "DTBOblique: Split of Class " << k << " ("
|
|
|
+// std::cerr << "DTBObliqueLS: Split of Class " << k << " ("
|
|
|
// << l << " <-> " << r << ") " << std::endl;
|
|
|
//#endif
|
|
|
}
|
|
@@ -524,7 +528,7 @@ DecisionNode *DTBOblique::buildRecursive(
|
|
|
}
|
|
|
|
|
|
/** initial building method */
|
|
|
-DecisionNode *DTBOblique::build ( const FeaturePool & fp,
|
|
|
+DecisionNode *DTBObliqueLS::build ( const FeaturePool & fp,
|
|
|
const Examples & examples,
|
|
|
int maxClassNo )
|
|
|
{
|