LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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

Referenced by lar_content::AdaBoostDecisionTree::WeakClassifier::EvaluateNode().

lar_content::AdaBoostDecisionTree::StrongClassifier::StrongClassifier ( const StrongClassifier rhs)

Copy constructor.

Parameters
rhsthe strong classifier to copy

Definition at line 384 of file LArAdaBoostDecisionTree.cc.

References m_weakClassifiers, and lar_content::AdaBoostDecisionTree::WeakClassifier::WeakClassifier().

385 {
386  for (const WeakClassifier *const pWeakClassifier : rhs.m_weakClassifiers)
387  m_weakClassifiers.emplace_back(new WeakClassifier(*pWeakClassifier));
388 }
WeakClassifiers m_weakClassifiers
Vector of weak classifers.
lar_content::AdaBoostDecisionTree::StrongClassifier::~StrongClassifier ( )

Destructor.

Definition at line 405 of file LArAdaBoostDecisionTree.cc.

406 {
407  for (const WeakClassifier *const pWeakClassifier : m_weakClassifiers)
408  delete pWeakClassifier;
409 }
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 392 of file LArAdaBoostDecisionTree.cc.

References m_weakClassifiers, and lar_content::AdaBoostDecisionTree::WeakClassifier::WeakClassifier().

393 {
394  if (this != &rhs)
395  {
396  for (const WeakClassifier *const pWeakClassifier : rhs.m_weakClassifiers)
397  m_weakClassifiers.emplace_back(new WeakClassifier(*pWeakClassifier));
398  }
399 
400  return *this;
401 }
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 413 of file LArAdaBoostDecisionTree.cc.

Referenced by lar_content::AdaBoostDecisionTree::CalculateScore().

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

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

Definition at line 445 of file LArAdaBoostDecisionTree.cc.

References lar_content::AdaBoostDecisionTree::WeakClassifier::WeakClassifier().

446 {
447  const std::string componentName(pCurrentXmlElement->ValueStr());
448  TiXmlHandle currentHandle(pCurrentXmlElement);
449 
450  if ((std::string("Name") == componentName) || (std::string("Timestamp") == componentName))
451  return STATUS_CODE_SUCCESS;
452 
453  if (std::string("DecisionTree") == componentName)
454  {
455  m_weakClassifiers.emplace_back(new WeakClassifier(&currentHandle));
456  return STATUS_CODE_SUCCESS;
457  }
458 
459  return STATUS_CODE_INVALID_PARAMETER;
460 }
WeakClassifiers m_weakClassifiers
Vector of weak classifers.

Member Data Documentation

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

Vector of weak classifers.

Definition at line 313 of file LArAdaBoostDecisionTree.h.

Referenced by operator=(), and StrongClassifier().


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