SupportVectorMachine class. More...
#include <LArSupportVectorMachine.h>
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. More... | |
| pandora::StatusCode | Initialize (const std::string ¶meterLocation, const std::string &svmName) |
| Initialize the svm using a serialized model. More... | |
| bool | Classify (const LArMvaHelper::MvaFeatureVector &features) const |
| Make a classification for a set of input features, based on the trained model. More... | |
| double | CalculateClassificationScore (const LArMvaHelper::MvaFeatureVector &features) const |
| Calculate the classification score for a set of input features, based on the trained model. More... | |
| double | CalculateProbability (const LArMvaHelper::MvaFeatureVector &features) const |
| Calculate the classification probability for a set of input features, based on the trained model. More... | |
| bool | IsInitialized () const |
| Query whether this svm is initialized. More... | |
| unsigned int | GetNFeatures () const |
| Get the number of features. More... | |
| void | SetKernelFunction (KernelFunction kernelFunction) |
| Set the kernel function to use. More... | |
Public Member Functions inherited from lar_content::MvaInterface | |
| virtual | ~MvaInterface ()=default |
| Destructor. More... | |
Private Types | |
| typedef std::vector< SupportVectorInfo > | SVInfoList |
| typedef std::vector< FeatureInfo > | FeatureInfoVector |
| typedef std::map< KernelType, KernelFunction > | KernelMap |
Private Member Functions | |
| void | ReadXmlFile (const std::string &svmFileName, const std::string &svmName) |
| Read the svm parameters from an xml file. More... | |
| pandora::StatusCode | ReadComponent (pandora::TiXmlElement *pCurrentXmlElement) |
| Read the component at the current xml element. More... | |
| pandora::StatusCode | ReadMachine (const pandora::TiXmlHandle ¤tHandle) |
| Read the machine component at the current xml handle. More... | |
| pandora::StatusCode | ReadFeatures (const pandora::TiXmlHandle ¤tHandle) |
| Read the feature component at the current xml handle. More... | |
| pandora::StatusCode | ReadSupportVector (const pandora::TiXmlHandle ¤tHandle) |
| Read the support vector component at the current xml handle. More... | |
| double | CalculateClassificationScoreImpl (const LArMvaHelper::MvaFeatureVector &features) const |
| Implementation method for calculating the classification score using the trained model. More... | |
Static Private Member Functions | |
| static double | QuadraticKernel (const LArMvaHelper::MvaFeatureVector &supportVector, const LArMvaHelper::MvaFeatureVector &features, const double scaleFactor=1.) |
| An inhomogeneous quadratic kernel. More... | |
| static double | CubicKernel (const LArMvaHelper::MvaFeatureVector &supportVector, const LArMvaHelper::MvaFeatureVector &features, const double scaleFactor=1.) |
| An inhomogeneous cubic kernel. More... | |
| static double | LinearKernel (const LArMvaHelper::MvaFeatureVector &supportVector, const LArMvaHelper::MvaFeatureVector &features, const double scaleFactor=1.) |
| A linear kernel. More... | |
| static double | GaussianRbfKernel (const LArMvaHelper::MvaFeatureVector &supportVector, const LArMvaHelper::MvaFeatureVector &features, const double scaleFactor=1.) |
| A gaussian RBF kernel. More... | |
Private Attributes | |
| bool | m_isInitialized |
| Whether this svm has been initialized. More... | |
| bool | m_enableProbability |
| Whether to enable probability calculations. More... | |
| double | m_probAParameter |
| The first-order score coefficient for mapping to a probability using the logistic function. More... | |
| double | m_probBParameter |
| The score offset parameter for mapping to a probability using the logistic function. More... | |
| bool | m_standardizeFeatures |
| Whether to standardize the features. More... | |
| unsigned int | m_nFeatures |
| The number of features. More... | |
| double | m_bias |
| The bias term. More... | |
| double | m_scaleFactor |
| The kernel scale factor. More... | |
| SVInfoList | m_svInfoList |
| The list of SupportVectorInfo objects. More... | |
| FeatureInfoVector | m_featureInfoList |
| The list of FeatureInfo objects. More... | |
| KernelType | m_kernelType |
| The kernel type. More... | |
| KernelFunction | m_kernelFunction |
| The kernel function. More... | |
| KernelMap | m_kernelMap |
| Map from the kernel types to the kernel functions. More... | |
SupportVectorMachine class.
Definition at line 30 of file LArSupportVectorMachine.h.
|
private |
Definition at line 162 of file LArSupportVectorMachine.h.
| typedef std::function<double(const LArMvaHelper::MvaFeatureVector &, const LArMvaHelper::MvaFeatureVector &, const double)> lar_content::SupportVectorMachine::KernelFunction |
Definition at line 33 of file LArSupportVectorMachine.h.
|
private |
Definition at line 164 of file LArSupportVectorMachine.h.
|
private |
Definition at line 161 of file LArSupportVectorMachine.h.
KernelType enum.
| Enumerator | |
|---|---|
| USER_DEFINED | |
| LINEAR | |
| QUADRATIC | |
| CUBIC | |
| GAUSSIAN_RBF | |
Definition at line 38 of file LArSupportVectorMachine.h.
| lar_content::SupportVectorMachine::SupportVectorMachine | ( | ) |
Default constructor.
Definition at line 18 of file LArSupportVectorMachine.cc.
|
inlinevirtual |
Calculate the classification score for a set of input features, based on the trained model.
| features | the input features |
Implements lar_content::MvaInterface.
Definition at line 295 of file LArSupportVectorMachine.h.
|
private |
Implementation method for calculating the classification score using the trained model.
| features | the vector of features |
Definition at line 250 of file LArSupportVectorMachine.cc.
|
inlinevirtual |
Calculate the classification probability for a set of input features, based on the trained model.
| features | the input features |
Implements lar_content::MvaInterface.
Definition at line 302 of file LArSupportVectorMachine.h.
|
inlinevirtual |
Make a classification for a set of input features, based on the trained model.
| features | the input features |
Implements lar_content::MvaInterface.
Definition at line 288 of file LArSupportVectorMachine.h.
|
inlinestaticprivate |
An inhomogeneous cubic kernel.
| supportVector | the support vector |
| features | the features |
| scale | factor the scale factor |
Definition at line 373 of file LArSupportVectorMachine.h.
|
inlinestaticprivate |
A gaussian RBF kernel.
| supportVector | the support vector |
| features | the features |
| scale | factor the scale factor |
Definition at line 390 of file LArSupportVectorMachine.h.
|
inline |
Get the number of features.
Definition at line 326 of file LArSupportVectorMachine.h.
| StatusCode lar_content::SupportVectorMachine::Initialize | ( | const std::string & | parameterLocation, |
| const std::string & | svmName | ||
| ) |
Initialize the svm using a serialized model.
| parameterLocation | the location of the model |
| svmName | the name of the model |
Definition at line 35 of file LArSupportVectorMachine.cc.
|
inline |
Query whether this svm is initialized.
Definition at line 319 of file LArSupportVectorMachine.h.
|
inlinestaticprivate |
A linear kernel.
| supportVector | the support vector |
| features | the features |
| scale | factor the scale factor |
Definition at line 340 of file LArSupportVectorMachine.h.
|
inlinestaticprivate |
An inhomogeneous quadratic kernel.
| supportVector | the support vector |
| features | the features |
| scale | factor the scale factor |
Definition at line 356 of file LArSupportVectorMachine.h.
|
private |
Read the component at the current xml element.
| pCurrentXmlElement | address of the current xml element |
Definition at line 143 of file LArSupportVectorMachine.cc.
|
private |
Read the feature component at the current xml handle.
| currentHandle | the current xml handle |
Definition at line 204 of file LArSupportVectorMachine.cc.
|
private |
Read the machine component at the current xml handle.
| currentHandle | the current xml handle |
Definition at line 165 of file LArSupportVectorMachine.cc.
|
private |
Read the support vector component at the current xml handle.
| currentHandle | the current xml handle |
Definition at line 232 of file LArSupportVectorMachine.cc.
|
private |
Read the svm parameters from an xml file.
| svmFileName | the sml file name |
| svmName | the name of the svm |
Definition at line 83 of file LArSupportVectorMachine.cc.
|
inline |
Set the kernel function to use.
| kernelFunction | the kernel function |
Definition at line 333 of file LArSupportVectorMachine.h.
|
private |
The bias term.
Definition at line 174 of file LArSupportVectorMachine.h.
|
private |
Whether to enable probability calculations.
Definition at line 168 of file LArSupportVectorMachine.h.
|
private |
The list of FeatureInfo objects.
Definition at line 178 of file LArSupportVectorMachine.h.
|
private |
Whether this svm has been initialized.
Definition at line 166 of file LArSupportVectorMachine.h.
|
private |
The kernel function.
Definition at line 181 of file LArSupportVectorMachine.h.
|
private |
Map from the kernel types to the kernel functions.
Definition at line 182 of file LArSupportVectorMachine.h.
|
private |
The kernel type.
Definition at line 180 of file LArSupportVectorMachine.h.
|
private |
The number of features.
Definition at line 173 of file LArSupportVectorMachine.h.
|
private |
The first-order score coefficient for mapping to a probability using the logistic function.
Definition at line 169 of file LArSupportVectorMachine.h.
|
private |
The score offset parameter for mapping to a probability using the logistic function.
Definition at line 170 of file LArSupportVectorMachine.h.
|
private |
The kernel scale factor.
Definition at line 175 of file LArSupportVectorMachine.h.
|
private |
Whether to standardize the features.
Definition at line 172 of file LArSupportVectorMachine.h.
|
private |
The list of SupportVectorInfo objects.
Definition at line 177 of file LArSupportVectorMachine.h.
1.8.11