All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
lar_content::AdaBoostDecisionTree::WeakClassifier Class Reference

WeakClassifier class containing a decision tree and a weight. More...

Public Member Functions

 WeakClassifier (const pandora::TiXmlHandle *const pXmlHandle)
 Constructor using xml handle to set member variables. More...
 
 WeakClassifier (const WeakClassifier &rhs)
 Copy constructor. More...
 
WeakClassifieroperator= (const WeakClassifier &rhs)
 Assignment operator. More...
 
 ~WeakClassifier ()
 Destructor. More...
 
bool Predict (const LArMvaHelper::MvaFeatureVector &features) const
 Predict signal or background based on trained data. More...
 
bool EvaluateNode (const int nodeId, const LArMvaHelper::MvaFeatureVector &features) const
 Evalute node and return outcome. More...
 
double GetWeight () const
 Get boost weight for weak classifier. More...
 
int GetTreeId () const
 Get tree id for weak classifier. More...
 

Private Attributes

IdToNodeMap m_idToNodeMap
 Decision tree nodes. More...
 
double m_weight
 Boost weight. More...
 
int m_treeId
 Decision tree id. More...
 

Detailed Description

WeakClassifier class containing a decision tree and a weight.

Definition at line 196 of file LArAdaBoostDecisionTree.h.

Constructor & Destructor Documentation

lar_content::AdaBoostDecisionTree::WeakClassifier::WeakClassifier ( 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::WeakClassifier::WeakClassifier ( const WeakClassifier rhs)

Copy constructor.

Parameters
rhsthe weak classifier to copy

Definition at line 287 of file LArAdaBoostDecisionTree.cc.

287  : m_weight(rhs.m_weight), m_treeId(rhs.m_treeId)
288 {
289  for (const auto &mapEntry : rhs.m_idToNodeMap)
290  {
291  const Node *pNode = new Node(*(mapEntry.second));
292  m_idToNodeMap.insert(IdToNodeMap::value_type(pNode->GetNodeId(), pNode));
293  }
294 }
lar_content::AdaBoostDecisionTree::WeakClassifier::~WeakClassifier ( )

Destructor.

Definition at line 317 of file LArAdaBoostDecisionTree.cc.

318 {
319  for (const auto &mapEntry : m_idToNodeMap)
320  delete mapEntry.second;
321 }

Member Function Documentation

bool lar_content::AdaBoostDecisionTree::WeakClassifier::EvaluateNode ( const int  nodeId,
const LArMvaHelper::MvaFeatureVector features 
) const

Evalute node and return outcome.

Parameters
nodeIdcurrent node id
featuresthe input features
Returns
is signal or background node

Definition at line 332 of file LArAdaBoostDecisionTree.cc.

333 {
334  const Node *pActiveNode(nullptr);
335 
336  if (m_idToNodeMap.find(nodeId) != m_idToNodeMap.end())
337  {
338  pActiveNode = m_idToNodeMap.at(nodeId);
339  }
340  else
341  {
342  throw StatusCodeException(STATUS_CODE_OUT_OF_RANGE);
343  }
344 
345  if (pActiveNode->IsLeaf())
346  return pActiveNode->GetOutcome();
347 
348  if (static_cast<int>(features.size()) <= pActiveNode->GetVariableId())
349  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
350 
351  if (features.at(pActiveNode->GetVariableId()).Get() <= pActiveNode->GetThreshold())
352  {
353  return this->EvaluateNode(pActiveNode->GetLeftChildNodeId(), features);
354  }
355  else
356  {
357  return this->EvaluateNode(pActiveNode->GetRightChildNodeId(), features);
358  }
359 }
bool EvaluateNode(const int nodeId, const LArMvaHelper::MvaFeatureVector &features) const
Evalute node and return outcome.
int lar_content::AdaBoostDecisionTree::WeakClassifier::GetTreeId ( ) const
inline

Get tree id for weak classifier.

Returns
tree id

Definition at line 393 of file LArAdaBoostDecisionTree.h.

394 {
395  return m_treeId;
396 }
double lar_content::AdaBoostDecisionTree::WeakClassifier::GetWeight ( ) const
inline

Get boost weight for weak classifier.

Returns
weight for decision tree

Definition at line 386 of file LArAdaBoostDecisionTree.h.

387 {
388  return m_weight;
389 }
AdaBoostDecisionTree::WeakClassifier & lar_content::AdaBoostDecisionTree::WeakClassifier::operator= ( const WeakClassifier rhs)

Assignment operator.

Parameters
rhsthe weak classifier to assign

Definition at line 298 of file LArAdaBoostDecisionTree.cc.

299 {
300  if (this != &rhs)
301  {
302  for (const auto &mapEntry : rhs.m_idToNodeMap)
303  {
304  const Node *pNode = new Node(*(mapEntry.second));
305  m_idToNodeMap.insert(IdToNodeMap::value_type(pNode->GetNodeId(), pNode));
306  }
307 
308  m_weight = rhs.m_weight;
309  m_treeId = rhs.m_treeId;
310  }
311 
312  return *this;
313 }
bool lar_content::AdaBoostDecisionTree::WeakClassifier::Predict ( const LArMvaHelper::MvaFeatureVector features) const

Predict signal or background based on trained data.

Parameters
featuresthe input features
Returns
is signal or background

Definition at line 325 of file LArAdaBoostDecisionTree.cc.

326 {
327  return this->EvaluateNode(0, features);
328 }
bool EvaluateNode(const int nodeId, const LArMvaHelper::MvaFeatureVector &features) const
Evalute node and return outcome.

Member Data Documentation

IdToNodeMap lar_content::AdaBoostDecisionTree::WeakClassifier::m_idToNodeMap
private

Decision tree nodes.

Definition at line 259 of file LArAdaBoostDecisionTree.h.

int lar_content::AdaBoostDecisionTree::WeakClassifier::m_treeId
private

Decision tree id.

Definition at line 261 of file LArAdaBoostDecisionTree.h.

double lar_content::AdaBoostDecisionTree::WeakClassifier::m_weight
private

Boost weight.

Definition at line 260 of file LArAdaBoostDecisionTree.h.


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