|
@@ -81,26 +81,26 @@ GPHIKClassifier::GPHIKClassifier( const Config *_conf,
|
|
|
|
|
|
GPHIKClassifier::~GPHIKClassifier()
|
|
|
{
|
|
|
- if ( gphyper != NULL )
|
|
|
- delete gphyper;
|
|
|
+ if ( this->gphyper != NULL )
|
|
|
+ delete this->gphyper;
|
|
|
}
|
|
|
|
|
|
void GPHIKClassifier::initFromConfig(const Config *_conf,
|
|
|
const string & _confSection
|
|
|
)
|
|
|
{
|
|
|
- this->noise = _conf->gD(confSection, "noise", 0.01);
|
|
|
+ this->d_noise = _conf->gD( _confSection, "noise", 0.01);
|
|
|
|
|
|
this->confSection = _confSection;
|
|
|
- this->verbose = _conf->gB(confSection, "verbose", false);
|
|
|
- this->debug = _conf->gB(confSection, "debug", false);
|
|
|
+ this->b_verbose = _conf->gB( _confSection, "verbose", false);
|
|
|
+ this->b_debug = _conf->gB( _confSection, "debug", false);
|
|
|
this->uncertaintyPredictionForClassification
|
|
|
- = _conf->gB( confSection, "uncertaintyPredictionForClassification", false );
|
|
|
+ = _conf->gB( _confSection, "uncertaintyPredictionForClassification", false );
|
|
|
|
|
|
|
|
|
|
|
|
//how do we approximate the predictive variance for classification uncertainty?
|
|
|
- string s_varianceApproximation = _conf->gS(confSection, "varianceApproximation", "approximate_fine"); //default: fine approximative uncertainty prediction
|
|
|
+ string s_varianceApproximation = _conf->gS(_confSection, "varianceApproximation", "approximate_fine"); //default: fine approximative uncertainty prediction
|
|
|
if ( (s_varianceApproximation.compare("approximate_rough") == 0) || ((s_varianceApproximation.compare("1") == 0)) )
|
|
|
{
|
|
|
this->varianceApproximation = APPROXIMATE_ROUGH;
|
|
@@ -113,7 +113,7 @@ void GPHIKClassifier::initFromConfig(const Config *_conf,
|
|
|
this->varianceApproximation = APPROXIMATE_FINE;
|
|
|
|
|
|
//security check - compute at least one eigenvalue for this approximation strategy
|
|
|
- this->gphyper->setNrOfEigenvaluesToConsiderForVarApprox ( std::max( _conf->gI(confSection, "nrOfEigenvaluesToConsiderForVarApprox", 1 ), 1) );
|
|
|
+ this->gphyper->setNrOfEigenvaluesToConsiderForVarApprox ( std::max( _conf->gI(_confSection, "nrOfEigenvaluesToConsiderForVarApprox", 1 ), 1) );
|
|
|
}
|
|
|
else if ( (s_varianceApproximation.compare("exact") == 0) || ((s_varianceApproximation.compare("3") == 0)) )
|
|
|
{
|
|
@@ -130,7 +130,7 @@ void GPHIKClassifier::initFromConfig(const Config *_conf,
|
|
|
this->gphyper->setNrOfEigenvaluesToConsiderForVarApprox ( 0 );
|
|
|
}
|
|
|
|
|
|
- if ( this->verbose )
|
|
|
+ if ( this->b_verbose )
|
|
|
std::cerr << "varianceApproximationStrategy: " << s_varianceApproximation << std::endl;
|
|
|
|
|
|
//NOTE init all member pointer variables here as well
|
|
@@ -183,7 +183,7 @@ void GPHIKClassifier::classify ( const SparseVector * _example,
|
|
|
|
|
|
_scores.clear();
|
|
|
|
|
|
- if ( this->debug )
|
|
|
+ if ( this->b_debug )
|
|
|
{
|
|
|
std::cerr << "GPHIKClassifier::classify (sparse)" << std::endl;
|
|
|
_example->store( std::cerr );
|
|
@@ -191,7 +191,7 @@ void GPHIKClassifier::classify ( const SparseVector * _example,
|
|
|
|
|
|
_result = gphyper->classify ( *_example, _scores );
|
|
|
|
|
|
- if ( this->debug )
|
|
|
+ if ( this->b_debug )
|
|
|
{
|
|
|
_scores.store ( std::cerr );
|
|
|
std::cerr << "_result: " << _result << std::endl;
|
|
@@ -203,7 +203,7 @@ void GPHIKClassifier::classify ( const SparseVector * _example,
|
|
|
|
|
|
if ( this->uncertaintyPredictionForClassification )
|
|
|
{
|
|
|
- if ( this->debug )
|
|
|
+ if ( this->b_debug )
|
|
|
{
|
|
|
std::cerr << "GPHIKClassifier::classify -- uncertaintyPredictionForClassification is true" << std::endl;
|
|
|
}
|
|
@@ -220,7 +220,7 @@ void GPHIKClassifier::classify ( const SparseVector * _example,
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if ( this->debug )
|
|
|
+ if ( this->b_debug )
|
|
|
{
|
|
|
std::cerr << "GPHIKClassifier::classify -- uncertaintyPredictionForClassification is false" << std::endl;
|
|
|
}
|
|
@@ -242,7 +242,7 @@ void GPHIKClassifier::classify ( const NICE::Vector * _example,
|
|
|
|
|
|
_scores.clear();
|
|
|
|
|
|
- if ( this->debug )
|
|
|
+ if ( this->b_debug )
|
|
|
{
|
|
|
std::cerr << "GPHIKClassifier::classify (non-sparse)" << std::endl;
|
|
|
std::cerr << *_example << std::endl;
|
|
@@ -250,7 +250,7 @@ void GPHIKClassifier::classify ( const NICE::Vector * _example,
|
|
|
|
|
|
_result = this->gphyper->classify ( *_example, _scores );
|
|
|
|
|
|
- if ( this->debug )
|
|
|
+ if ( this->b_debug )
|
|
|
{
|
|
|
std::cerr << "GPHIKClassifier::classify (non-sparse) -- classification done " << std::endl;
|
|
|
}
|
|
@@ -293,7 +293,7 @@ void GPHIKClassifier::train ( const std::vector< const NICE::SparseVector *> & _
|
|
|
fthrow(Exception, "Given examples do not match label vector in size -- aborting!" );
|
|
|
}
|
|
|
|
|
|
- if (verbose)
|
|
|
+ if (b_verbose)
|
|
|
{
|
|
|
std::cerr << "GPHIKClassifier::train" << std::endl;
|
|
|
}
|
|
@@ -301,21 +301,21 @@ void GPHIKClassifier::train ( const std::vector< const NICE::SparseVector *> & _
|
|
|
Timer t;
|
|
|
t.start();
|
|
|
|
|
|
- FastMinKernel *fmk = new FastMinKernel ( _examples, noise, this->debug );
|
|
|
+ FastMinKernel *fmk = new FastMinKernel ( _examples, d_noise, this->b_debug );
|
|
|
|
|
|
this->gphyper->setFastMinKernel ( fmk );
|
|
|
|
|
|
t.stop();
|
|
|
- if (verbose)
|
|
|
+ if (b_verbose)
|
|
|
std::cerr << "Time used for setting up the fmk object: " << t.getLast() << std::endl;
|
|
|
|
|
|
|
|
|
- if (verbose)
|
|
|
+ if (b_verbose)
|
|
|
std::cerr << "Learning ..." << endl;
|
|
|
|
|
|
// go go go
|
|
|
this->gphyper->optimize ( _labels );
|
|
|
- if (verbose)
|
|
|
+ if (b_verbose)
|
|
|
std::cerr << "optimization done" << std::endl;
|
|
|
|
|
|
if ( ( this->varianceApproximation != NONE ) )
|
|
@@ -348,7 +348,7 @@ void GPHIKClassifier::train ( const std::vector< const NICE::SparseVector *> & _
|
|
|
this->b_isTrained = true;
|
|
|
|
|
|
// clean up all examples ??
|
|
|
- if (verbose)
|
|
|
+ if (b_verbose)
|
|
|
std::cerr << "Learning finished" << std::endl;
|
|
|
}
|
|
|
|
|
@@ -369,28 +369,28 @@ void GPHIKClassifier::train ( const std::vector< const NICE::SparseVector *> & _
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if ( this->verbose )
|
|
|
+ if ( this->b_verbose )
|
|
|
std::cerr << "GPHIKClassifier::train" << std::endl;
|
|
|
|
|
|
Timer t;
|
|
|
t.start();
|
|
|
|
|
|
- FastMinKernel *fmk = new FastMinKernel ( _examples, noise, this->debug );
|
|
|
+ FastMinKernel *fmk = new FastMinKernel ( _examples, d_noise, this->b_debug );
|
|
|
this->gphyper->setFastMinKernel ( fmk );
|
|
|
|
|
|
t.stop();
|
|
|
- if ( this->verbose )
|
|
|
+ if ( this->b_verbose )
|
|
|
std::cerr << "Time used for setting up the fmk object: " << t.getLast() << std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
- if ( this->verbose )
|
|
|
+ if ( this->b_verbose )
|
|
|
std::cerr << "Learning ..." << std::endl;
|
|
|
|
|
|
// go go go
|
|
|
this->gphyper->optimize ( _binLabels );
|
|
|
|
|
|
- if ( this->verbose )
|
|
|
+ if ( this->b_verbose )
|
|
|
std::cerr << "optimization done, now prepare for the uncertainty prediction" << std::endl;
|
|
|
|
|
|
if ( ( this->varianceApproximation != NONE ) )
|
|
@@ -423,7 +423,7 @@ void GPHIKClassifier::train ( const std::vector< const NICE::SparseVector *> & _
|
|
|
this->b_isTrained = true;
|
|
|
|
|
|
// clean up all examples ??
|
|
|
- if ( this->verbose )
|
|
|
+ if ( this->b_verbose )
|
|
|
std::cerr << "Learning finished" << std::endl;
|
|
|
}
|
|
|
|
|
@@ -578,21 +578,21 @@ void GPHIKClassifier::restore ( std::istream & _is,
|
|
|
_is >> tmp; // end of block
|
|
|
tmp = this->removeEndTag ( tmp );
|
|
|
}
|
|
|
- else if ( tmp.compare("noise") == 0 )
|
|
|
+ else if ( tmp.compare("d_noise") == 0 )
|
|
|
{
|
|
|
- _is >> noise;
|
|
|
+ _is >> d_noise;
|
|
|
_is >> tmp; // end of block
|
|
|
tmp = this->removeEndTag ( tmp );
|
|
|
}
|
|
|
- else if ( tmp.compare("verbose") == 0 )
|
|
|
+ else if ( tmp.compare("b_verbose") == 0 )
|
|
|
{
|
|
|
- _is >> verbose;
|
|
|
+ _is >> b_verbose;
|
|
|
_is >> tmp; // end of block
|
|
|
tmp = this->removeEndTag ( tmp );
|
|
|
}
|
|
|
- else if ( tmp.compare("debug") == 0 )
|
|
|
+ else if ( tmp.compare("b_debug") == 0 )
|
|
|
{
|
|
|
- _is >> debug;
|
|
|
+ _is >> b_debug;
|
|
|
_is >> tmp; // end of block
|
|
|
tmp = this->removeEndTag ( tmp );
|
|
|
}
|
|
@@ -654,18 +654,18 @@ void GPHIKClassifier::store ( std::ostream & _os,
|
|
|
_os << b_isTrained << std::endl;
|
|
|
_os << this->createEndTag( "b_isTrained" ) << std::endl;
|
|
|
|
|
|
- _os << this->createStartTag( "noise" ) << std::endl;
|
|
|
- _os << noise << std::endl;
|
|
|
- _os << this->createEndTag( "noise" ) << std::endl;
|
|
|
+ _os << this->createStartTag( "d_noise" ) << std::endl;
|
|
|
+ _os << d_noise << std::endl;
|
|
|
+ _os << this->createEndTag( "d_noise" ) << std::endl;
|
|
|
|
|
|
|
|
|
- _os << this->createStartTag( "verbose" ) << std::endl;
|
|
|
- _os << verbose << std::endl;
|
|
|
- _os << this->createEndTag( "verbose" ) << std::endl;
|
|
|
+ _os << this->createStartTag( "b_verbose" ) << std::endl;
|
|
|
+ _os << b_verbose << std::endl;
|
|
|
+ _os << this->createEndTag( "b_verbose" ) << std::endl;
|
|
|
|
|
|
- _os << this->createStartTag( "debug" ) << std::endl;
|
|
|
- _os << debug << std::endl;
|
|
|
- _os << this->createEndTag( "debug" ) << std::endl;
|
|
|
+ _os << this->createStartTag( "b_debug" ) << std::endl;
|
|
|
+ _os << b_debug << std::endl;
|
|
|
+ _os << this->createEndTag( "b_debug" ) << std::endl;
|
|
|
|
|
|
_os << this->createStartTag( "uncertaintyPredictionForClassification" ) << std::endl;
|
|
|
_os << uncertaintyPredictionForClassification << std::endl;
|