LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 382 of file LArAdaBoostDecisionTree.cc.

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

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

Destructor.

Definition at line 403 of file LArAdaBoostDecisionTree.cc.

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

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

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

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

412 {
413  double score(0.), weights(0.);
414 
415  for (const WeakClassifier *const pWeakClassifier : m_weakClassifiers)
416  {
417  weights += pWeakClassifier->GetWeight();
418 
419  if (pWeakClassifier->Predict(features))
420  {
421  score += pWeakClassifier->GetWeight();
422  }
423  else
424  {
425  score -= pWeakClassifier->GetWeight();
426  }
427  }
428 
429  if (weights > std::numeric_limits<double>::epsilon())
430  {
431  score /= weights;
432  }
433  else
434  {
435  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
436  }
437 
438  return score;
439 }
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 443 of file LArAdaBoostDecisionTree.cc.

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

444 {
445  const std::string componentName(pCurrentXmlElement->ValueStr());
446  TiXmlHandle currentHandle(pCurrentXmlElement);
447 
448  if ((std::string("Name") == componentName) || (std::string("Timestamp") == componentName))
449  return STATUS_CODE_SUCCESS;
450 
451  if (std::string("DecisionTree") == componentName)
452  {
453  m_weakClassifiers.emplace_back(new WeakClassifier(&currentHandle));
454  return STATUS_CODE_SUCCESS;
455  }
456 
457  return STATUS_CODE_INVALID_PARAMETER;
458 }
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: