Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
lar_content::SupportVectorMachine Class Reference

SupportVectorMachine class. More...

#include "LArSupportVectorMachine.h"

Inheritance diagram for lar_content::SupportVectorMachine:
Collaboration diagram for lar_content::SupportVectorMachine:

Classes

class  FeatureInfo
 FeatureInfo class. More...
 
class  SupportVectorInfo
 SupportVectorInfo class. More...
 

Public Types

enum  KernelType {
  USER_DEFINED = 0 , LINEAR = 1 , QUADRATIC = 2 , CUBIC = 3 ,
  GAUSSIAN_RBF = 4
}
 KernelType enum. More...
 
typedef std::function< double(const LArMvaHelper::MvaFeatureVector &, const LArMvaHelper::MvaFeatureVector &, const double)> KernelFunction
 

Public Member Functions

 SupportVectorMachine ()
 Default constructor.
 
pandora::StatusCode Initialize (const std::string &parameterLocation, const std::string &svmName)
 Initialize the svm using a serialized model.
 
bool Classify (const LArMvaHelper::MvaFeatureVector &features) const
 Make a classification for a set of input features, based on the trained model.
 
double CalculateClassificationScore (const LArMvaHelper::MvaFeatureVector &features) const
 Calculate the classification score for a set of input features, based on the trained model.
 
double CalculateProbability (const LArMvaHelper::MvaFeatureVector &features) const
 Calculate the classification probability for a set of input features, based on the trained model.
 
bool IsInitialized () const
 Query whether this svm is initialized.
 
unsigned int GetNFeatures () const
 Get the number of features.
 
void SetKernelFunction (KernelFunction kernelFunction)
 Set the kernel function to use.
 

Private Types

typedef std::vector< SupportVectorInfoSVInfoList
 
typedef std::vector< FeatureInfoFeatureInfoVector
 
typedef std::map< KernelType, KernelFunctionKernelMap
 

Private Member Functions

void ReadXmlFile (const std::string &svmFileName, const std::string &svmName)
 Read the svm parameters from an xml file.
 
pandora::StatusCode ReadComponent (pandora::TiXmlElement *pCurrentXmlElement)
 Read the component at the current xml element.
 
pandora::StatusCode ReadMachine (const pandora::TiXmlHandle &currentHandle)
 Read the machine component at the current xml handle.
 
pandora::StatusCode ReadFeatures (const pandora::TiXmlHandle &currentHandle)
 Read the feature component at the current xml handle.
 
pandora::StatusCode ReadSupportVector (const pandora::TiXmlHandle &currentHandle)
 Read the support vector component at the current xml handle.
 
double CalculateClassificationScoreImpl (const LArMvaHelper::MvaFeatureVector &features) const
 Implementation method for calculating the classification score using the trained model.
 

Static Private Member Functions

static double QuadraticKernel (const LArMvaHelper::MvaFeatureVector &supportVector, const LArMvaHelper::MvaFeatureVector &features, const double scaleFactor=1.)
 An inhomogeneous quadratic kernel.
 
static double CubicKernel (const LArMvaHelper::MvaFeatureVector &supportVector, const LArMvaHelper::MvaFeatureVector &features, const double scaleFactor=1.)
 An inhomogeneous cubic kernel.
 
static double LinearKernel (const LArMvaHelper::MvaFeatureVector &supportVector, const LArMvaHelper::MvaFeatureVector &features, const double scaleFactor=1.)
 A linear kernel.
 
static double GaussianRbfKernel (const LArMvaHelper::MvaFeatureVector &supportVector, const LArMvaHelper::MvaFeatureVector &features, const double scaleFactor=1.)
 A gaussian RBF kernel.
 

Private Attributes

bool m_isInitialized
 Whether this svm has been initialized.
 
bool m_enableProbability
 Whether to enable probability calculations.
 
double m_probAParameter
 The first-order score coefficient for mapping to a probability using the logistic function.
 
double m_probBParameter
 The score offset parameter for mapping to a probability using the logistic function.
 
bool m_standardizeFeatures
 Whether to standardize the features.
 
unsigned int m_nFeatures
 The number of features.
 
double m_bias
 The bias term.
 
double m_scaleFactor
 The kernel scale factor.
 
SVInfoList m_svInfoList
 The list of SupportVectorInfo objects.
 
FeatureInfoVector m_featureInfoList
 The list of FeatureInfo objects.
 
KernelType m_kernelType
 The kernel type.
 
KernelFunction m_kernelFunction
 The kernel function.
 
KernelMap m_kernelMap
 Map from the kernel types to the kernel functions.
 

Detailed Description

SupportVectorMachine class.

Definition at line 30 of file LArSupportVectorMachine.h.

Member Typedef Documentation

◆ FeatureInfoVector

Definition at line 162 of file LArSupportVectorMachine.h.

◆ KernelFunction

Definition at line 33 of file LArSupportVectorMachine.h.

◆ KernelMap

◆ SVInfoList

Definition at line 161 of file LArSupportVectorMachine.h.

Member Enumeration Documentation

◆ KernelType

KernelType enum.

Enumerator
USER_DEFINED 
LINEAR 
QUADRATIC 
CUBIC 
GAUSSIAN_RBF 

Definition at line 38 of file LArSupportVectorMachine.h.

Constructor & Destructor Documentation

◆ SupportVectorMachine()

lar_content::SupportVectorMachine::SupportVectorMachine ( )

Default constructor.

Definition at line 18 of file LArSupportVectorMachine.cc.

Here is the call graph for this function:

Member Function Documentation

◆ CalculateClassificationScore()

double lar_content::SupportVectorMachine::CalculateClassificationScore ( const LArMvaHelper::MvaFeatureVector features) const
inlinevirtual

Calculate the classification score for a set of input features, based on the trained model.

Parameters
featuresthe input features
Returns
the classification score

Implements lar_content::MvaInterface.

Definition at line 295 of file LArSupportVectorMachine.h.

Here is the call graph for this function:

◆ CalculateClassificationScoreImpl()

double lar_content::SupportVectorMachine::CalculateClassificationScoreImpl ( const LArMvaHelper::MvaFeatureVector features) const
private

Implementation method for calculating the classification score using the trained model.

Parameters
featuresthe vector of features
Returns
the classification score

Definition at line 250 of file LArSupportVectorMachine.cc.

Here is the caller graph for this function:

◆ CalculateProbability()

double lar_content::SupportVectorMachine::CalculateProbability ( const LArMvaHelper::MvaFeatureVector features) const
inlinevirtual

Calculate the classification probability for a set of input features, based on the trained model.

Parameters
featuresthe input features
Returns
the classification probability

Implements lar_content::MvaInterface.

Definition at line 302 of file LArSupportVectorMachine.h.

Here is the call graph for this function:

◆ Classify()

bool lar_content::SupportVectorMachine::Classify ( const LArMvaHelper::MvaFeatureVector features) const
inlinevirtual

Make a classification for a set of input features, based on the trained model.

Parameters
featuresthe input features
Returns
the predicted boolean class

Implements lar_content::MvaInterface.

Definition at line 288 of file LArSupportVectorMachine.h.

Here is the call graph for this function:

◆ CubicKernel()

double lar_content::SupportVectorMachine::CubicKernel ( const LArMvaHelper::MvaFeatureVector supportVector,
const LArMvaHelper::MvaFeatureVector features,
const double  scaleFactor = 1. 
)
inlinestaticprivate

An inhomogeneous cubic kernel.

Parameters
supportVectorthe support vector
featuresthe features
scalefactor the scale factor
Returns
result of the kernel operation

Definition at line 373 of file LArSupportVectorMachine.h.

◆ GaussianRbfKernel()

double lar_content::SupportVectorMachine::GaussianRbfKernel ( const LArMvaHelper::MvaFeatureVector supportVector,
const LArMvaHelper::MvaFeatureVector features,
const double  scaleFactor = 1. 
)
inlinestaticprivate

A gaussian RBF kernel.

Parameters
supportVectorthe support vector
featuresthe features
scalefactor the scale factor
Returns
result of the kernel operation

Definition at line 390 of file LArSupportVectorMachine.h.

◆ GetNFeatures()

unsigned int lar_content::SupportVectorMachine::GetNFeatures ( ) const
inline

Get the number of features.

Returns
the number of features

Definition at line 326 of file LArSupportVectorMachine.h.

◆ Initialize()

StatusCode lar_content::SupportVectorMachine::Initialize ( const std::string &  parameterLocation,
const std::string &  svmName 
)

Initialize the svm using a serialized model.

Parameters
parameterLocationthe location of the model
svmNamethe name of the model
Returns
success

Definition at line 35 of file LArSupportVectorMachine.cc.

◆ IsInitialized()

bool lar_content::SupportVectorMachine::IsInitialized ( ) const
inline

Query whether this svm is initialized.

Returns
whether the model is initialized

Definition at line 319 of file LArSupportVectorMachine.h.

◆ LinearKernel()

double lar_content::SupportVectorMachine::LinearKernel ( const LArMvaHelper::MvaFeatureVector supportVector,
const LArMvaHelper::MvaFeatureVector features,
const double  scaleFactor = 1. 
)
inlinestaticprivate

A linear kernel.

Parameters
supportVectorthe support vector
featuresthe features
scalefactor the scale factor
Returns
result of the kernel operation

Definition at line 340 of file LArSupportVectorMachine.h.

Here is the caller graph for this function:

◆ QuadraticKernel()

double lar_content::SupportVectorMachine::QuadraticKernel ( const LArMvaHelper::MvaFeatureVector supportVector,
const LArMvaHelper::MvaFeatureVector features,
const double  scaleFactor = 1. 
)
inlinestaticprivate

An inhomogeneous quadratic kernel.

Parameters
supportVectorthe support vector
featuresthe features
scalefactor the scale factor
Returns
result of the kernel operation

Definition at line 356 of file LArSupportVectorMachine.h.

◆ ReadComponent()

StatusCode lar_content::SupportVectorMachine::ReadComponent ( pandora::TiXmlElement pCurrentXmlElement)
private

Read the component at the current xml element.

Parameters
pCurrentXmlElementaddress of the current xml element
Returns
success

Definition at line 143 of file LArSupportVectorMachine.cc.

Here is the call graph for this function:

◆ ReadFeatures()

StatusCode lar_content::SupportVectorMachine::ReadFeatures ( const pandora::TiXmlHandle currentHandle)
private

Read the feature component at the current xml handle.

Parameters
currentHandlethe current xml handle
Returns
success

Definition at line 204 of file LArSupportVectorMachine.cc.

Here is the call graph for this function:

◆ ReadMachine()

StatusCode lar_content::SupportVectorMachine::ReadMachine ( const pandora::TiXmlHandle currentHandle)
private

Read the machine component at the current xml handle.

Parameters
currentHandlethe current xml handle
Returns
success

Definition at line 165 of file LArSupportVectorMachine.cc.

Here is the call graph for this function:

◆ ReadSupportVector()

StatusCode lar_content::SupportVectorMachine::ReadSupportVector ( const pandora::TiXmlHandle currentHandle)
private

Read the support vector component at the current xml handle.

Parameters
currentHandlethe current xml handle
Returns
success

Definition at line 232 of file LArSupportVectorMachine.cc.

Here is the call graph for this function:

◆ ReadXmlFile()

void lar_content::SupportVectorMachine::ReadXmlFile ( const std::string &  svmFileName,
const std::string &  svmName 
)
private

Read the svm parameters from an xml file.

Parameters
svmFileNamethe sml file name
svmNamethe name of the svm

Definition at line 83 of file LArSupportVectorMachine.cc.

Here is the call graph for this function:

◆ SetKernelFunction()

void lar_content::SupportVectorMachine::SetKernelFunction ( KernelFunction  kernelFunction)
inline

Set the kernel function to use.

Parameters
kernelFunctionthe kernel function

Definition at line 333 of file LArSupportVectorMachine.h.

Member Data Documentation

◆ m_bias

double lar_content::SupportVectorMachine::m_bias
private

The bias term.

Definition at line 174 of file LArSupportVectorMachine.h.

◆ m_enableProbability

bool lar_content::SupportVectorMachine::m_enableProbability
private

Whether to enable probability calculations.

Definition at line 168 of file LArSupportVectorMachine.h.

◆ m_featureInfoList

FeatureInfoVector lar_content::SupportVectorMachine::m_featureInfoList
private

The list of FeatureInfo objects.

Definition at line 178 of file LArSupportVectorMachine.h.

◆ m_isInitialized

bool lar_content::SupportVectorMachine::m_isInitialized
private

Whether this svm has been initialized.

Definition at line 166 of file LArSupportVectorMachine.h.

◆ m_kernelFunction

KernelFunction lar_content::SupportVectorMachine::m_kernelFunction
private

The kernel function.

Definition at line 181 of file LArSupportVectorMachine.h.

◆ m_kernelMap

KernelMap lar_content::SupportVectorMachine::m_kernelMap
private

Map from the kernel types to the kernel functions.

Definition at line 182 of file LArSupportVectorMachine.h.

◆ m_kernelType

KernelType lar_content::SupportVectorMachine::m_kernelType
private

The kernel type.

Definition at line 180 of file LArSupportVectorMachine.h.

◆ m_nFeatures

unsigned int lar_content::SupportVectorMachine::m_nFeatures
private

The number of features.

Definition at line 173 of file LArSupportVectorMachine.h.

◆ m_probAParameter

double lar_content::SupportVectorMachine::m_probAParameter
private

The first-order score coefficient for mapping to a probability using the logistic function.

Definition at line 169 of file LArSupportVectorMachine.h.

◆ m_probBParameter

double lar_content::SupportVectorMachine::m_probBParameter
private

The score offset parameter for mapping to a probability using the logistic function.

Definition at line 170 of file LArSupportVectorMachine.h.

◆ m_scaleFactor

double lar_content::SupportVectorMachine::m_scaleFactor
private

The kernel scale factor.

Definition at line 175 of file LArSupportVectorMachine.h.

◆ m_standardizeFeatures

bool lar_content::SupportVectorMachine::m_standardizeFeatures
private

Whether to standardize the features.

Definition at line 172 of file LArSupportVectorMachine.h.

◆ m_svInfoList

SVInfoList lar_content::SupportVectorMachine::m_svInfoList
private

The list of SupportVectorInfo objects.

Definition at line 177 of file LArSupportVectorMachine.h.


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