Public Member Functions | Private Member Functions | Private Attributes | List of all members
lar_content::AdaBoostDecisionTree::StrongClassifier Class Reference

StrongClassifier class used in application of adaptive boost decision tree. More...

Public Member Functions

 StrongClassifier (const pandora::TiXmlHandle *const pXmlHandle)
 Constructor using xml handle to set member variables. More...
 
 StrongClassifier (const StrongClassifier &rhs)
 Copy constructor. More...
 
StrongClassifieroperator= (const StrongClassifier &rhs)
 Assignment operator. More...
 
 ~StrongClassifier ()
 Destructor. More...
 
double Predict (const LArMvaHelper::MvaFeatureVector &features) const
 Predict signal or background based on trained data. More...
 

Private Member Functions

pandora::StatusCode ReadComponent (pandora::TiXmlElement *pCurrentXmlElement)
 Read xml element and if weak classifier add to member variables. More...
 

Private Attributes

WeakClassifiers m_weakClassifiers
 Vector of weak classifers. More...
 

Detailed Description

StrongClassifier class used in application of adaptive boost decision tree.

Definition at line 269 of file LArAdaBoostDecisionTree.h.

Constructor & Destructor Documentation

lar_content::AdaBoostDecisionTree::StrongClassifier::StrongClassifier ( const pandora::TiXmlHandle *const  pXmlHandle)

Constructor using xml handle to set member variables.

Parameters
pXmlHandlexml handle to use when setting member variables
lar_content::AdaBoostDecisionTree::StrongClassifier::StrongClassifier ( const StrongClassifier rhs)

Copy constructor.

Parameters
rhsthe strong classifier to copy

Definition at line 379 of file LArAdaBoostDecisionTree.cc.

380 {
381  for (const WeakClassifier *const pWeakClassifier : rhs.m_weakClassifiers)
382  m_weakClassifiers.emplace_back(new WeakClassifier(*pWeakClassifier));
383 }
WeakClassifiers m_weakClassifiers
Vector of weak classifers.
lar_content::AdaBoostDecisionTree::StrongClassifier::~StrongClassifier ( )

Destructor.

Definition at line 400 of file LArAdaBoostDecisionTree.cc.

401 {
402  for (const WeakClassifier *const pWeakClassifier : m_weakClassifiers)
403  delete pWeakClassifier;
404 }
WeakClassifiers m_weakClassifiers
Vector of weak classifers.

Member Function Documentation

AdaBoostDecisionTree::StrongClassifier & lar_content::AdaBoostDecisionTree::StrongClassifier::operator= ( const StrongClassifier rhs)

Assignment operator.

Parameters
rhsthe strong classifier to assign

Definition at line 387 of file LArAdaBoostDecisionTree.cc.

388 {
389  if (this != &rhs)
390  {
391  for (const WeakClassifier *const pWeakClassifier : rhs.m_weakClassifiers)
392  m_weakClassifiers.emplace_back(new WeakClassifier(*pWeakClassifier));
393  }
394 
395  return *this;
396 }
WeakClassifiers m_weakClassifiers
Vector of weak classifers.
double lar_content::AdaBoostDecisionTree::StrongClassifier::Predict ( const LArMvaHelper::MvaFeatureVector features) const

Predict signal or background based on trained data.

Parameters
featuresthe input features
Returns
return score produced from trained model

Definition at line 408 of file LArAdaBoostDecisionTree.cc.

409 {
410  double score(0.), weights(0.);
411 
412  for (const WeakClassifier *const pWeakClassifier : m_weakClassifiers)
413  {
414  weights += pWeakClassifier->GetWeight();
415 
416  if (pWeakClassifier->Predict(features))
417  {
418  score += pWeakClassifier->GetWeight();
419  }
420  else
421  {
422  score -= pWeakClassifier->GetWeight();
423  }
424  }
425 
426  if (weights > std::numeric_limits<double>::epsilon())
427  {
428  score /= weights;
429  }
430  else
431  {
432  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
433  }
434 
435  return score;
436 }
WeakClassifiers m_weakClassifiers
Vector of weak classifers.
const char features[]
Definition: feature_tests.c:2
StatusCode lar_content::AdaBoostDecisionTree::StrongClassifier::ReadComponent ( pandora::TiXmlElement *  pCurrentXmlElement)
private

Read xml element and if weak classifier add to member variables.

Definition at line 440 of file LArAdaBoostDecisionTree.cc.

441 {
442  const std::string componentName(pCurrentXmlElement->ValueStr());
443  TiXmlHandle currentHandle(pCurrentXmlElement);
444 
445  if ((std::string("Name") == componentName) || (std::string("Timestamp") == componentName))
446  return STATUS_CODE_SUCCESS;
447 
448  if (std::string("DecisionTree") == componentName)
449  {
450  m_weakClassifiers.emplace_back(new WeakClassifier(&currentHandle));
451  return STATUS_CODE_SUCCESS;
452  }
453 
454  return STATUS_CODE_INVALID_PARAMETER;
455 }
WeakClassifiers m_weakClassifiers
Vector of weak classifers.
std::string string
Definition: nybbler.cc:12

Member Data Documentation

WeakClassifiers lar_content::AdaBoostDecisionTree::StrongClassifier::m_weakClassifiers
private

Vector of weak classifers.

Definition at line 313 of file LArAdaBoostDecisionTree.h.


The documentation for this class was generated from the following files: