SupportVectorMachine class.
More...
#include <LArSupportVectorMachine.h>
|
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...
|
|
lar_content::SupportVectorMachine::SupportVectorMachine |
( |
| ) |
|
Default constructor.
Definition at line 18 of file LArSupportVectorMachine.cc.
static double CubicKernel(const LArMvaHelper::MvaFeatureVector &supportVector, const LArMvaHelper::MvaFeatureVector &features, const double scaleFactor=1.)
An inhomogeneous cubic kernel.
bool m_enableProbability
Whether to enable probability calculations.
double m_scaleFactor
The kernel scale factor.
static double QuadraticKernel(const LArMvaHelper::MvaFeatureVector &supportVector, const LArMvaHelper::MvaFeatureVector &features, const double scaleFactor=1.)
An inhomogeneous quadratic kernel.
static double LinearKernel(const LArMvaHelper::MvaFeatureVector &supportVector, const LArMvaHelper::MvaFeatureVector &features, const double scaleFactor=1.)
A linear kernel.
bool m_standardizeFeatures
Whether to standardize the features.
double m_bias
The bias term.
KernelMap m_kernelMap
Map from the kernel types to the kernel functions.
KernelFunction m_kernelFunction
The kernel function.
KernelType m_kernelType
The kernel type.
double m_probAParameter
The first-order score coefficient for mapping to a probability using the logistic function...
unsigned int m_nFeatures
The number of features.
static double GaussianRbfKernel(const LArMvaHelper::MvaFeatureVector &supportVector, const LArMvaHelper::MvaFeatureVector &features, const double scaleFactor=1.)
A gaussian RBF kernel.
bool m_isInitialized
Whether this svm has been initialized.
double m_probBParameter
The score offset parameter for mapping to a probability using the logistic function.
Calculate the classification score for a set of input features, based on the trained model.
- Parameters
-
features | the input features |
- Returns
- the classification score
Implements lar_content::MvaInterface.
Definition at line 295 of file LArSupportVectorMachine.h.
double CalculateClassificationScoreImpl(const LArMvaHelper::MvaFeatureVector &features) const
Implementation method for calculating the classification score using the trained model.
Implementation method for calculating the classification score using the trained model.
- Parameters
-
features | the vector of features |
- Returns
- the classification score
Calculate the classification probability for a set of input features, based on the trained model.
- Parameters
-
features | the input features |
- Returns
- the classification probability
Implements lar_content::MvaInterface.
Definition at line 302 of file LArSupportVectorMachine.h.
306 std::cout <<
"LArSupportVectorMachine: cannot calculate probabilities for this SVM" << std::endl;
307 throw pandora::STATUS_CODE_NOT_INITIALIZED;
314 return 1. / (1. +
std::exp(scaledScore));
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 CalculateClassificationScoreImpl(const LArMvaHelper::MvaFeatureVector &features) const
Implementation method for calculating the classification score using the trained model.
double m_probBParameter
The score offset parameter for mapping to a probability using the logistic function.
BEGIN_PROLOG could also be cout
Make a classification for a set of input features, based on the trained model.
- Parameters
-
features | the input features |
- Returns
- the predicted boolean class
Implements lar_content::MvaInterface.
Definition at line 288 of file LArSupportVectorMachine.h.
double CalculateClassificationScoreImpl(const LArMvaHelper::MvaFeatureVector &features) const
Implementation method for calculating the classification score using the trained model.
An inhomogeneous cubic kernel.
- Parameters
-
supportVector | the support vector |
features | the features |
scale | factor the scale factor |
- Returns
- result of the kernel operation
Definition at line 373 of file LArSupportVectorMachine.h.
376 const double denominator(scaleFactor * scaleFactor);
377 if (denominator < std::numeric_limits<double>::epsilon())
378 throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
381 for (
unsigned int i = 0; i < features.size(); ++i)
382 total += supportVector.at(i).Get() * features.at(i).Get();
384 total = total / denominator + 1.;
385 return total * total * total;
A gaussian RBF kernel.
- Parameters
-
supportVector | the support vector |
features | the features |
scale | factor the scale factor |
- Returns
- result of the kernel operation
Definition at line 390 of file LArSupportVectorMachine.h.
394 for (
unsigned int i = 0; i < features.size(); ++i)
395 total += (supportVector.at(i).Get() - features.at(i).Get()) * (supportVector.at(i).Get() - features.at(i).Get());
397 return std::exp(-scaleFactor * total);
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.
unsigned int m_nFeatures
The number of features.
pandora::StatusCode lar_content::SupportVectorMachine::Initialize |
( |
const std::string & |
parameterLocation, |
|
|
const std::string & |
svmName |
|
) |
| |
Initialize the svm using a serialized model.
- Parameters
-
parameterLocation | the location of the model |
svmName | the name of the model |
- Returns
- success
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.
bool m_isInitialized
Whether this svm has been initialized.
A linear kernel.
- Parameters
-
supportVector | the support vector |
features | the features |
scale | factor the scale factor |
- Returns
- result of the kernel operation
Definition at line 340 of file LArSupportVectorMachine.h.
343 const double denominator(scaleFactor * scaleFactor);
344 if (denominator < std::numeric_limits<double>::epsilon())
345 throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
348 for (
unsigned int i = 0; i < features.size(); ++i)
349 total += supportVector.at(i).Get() * features.at(i).Get();
351 return total / denominator;
An inhomogeneous quadratic kernel.
- Parameters
-
supportVector | the support vector |
features | the features |
scale | factor the scale factor |
- Returns
- result of the kernel operation
Definition at line 356 of file LArSupportVectorMachine.h.
359 const double denominator(scaleFactor * scaleFactor);
360 if (denominator < std::numeric_limits<double>::epsilon())
361 throw pandora::StatusCodeException(pandora::STATUS_CODE_INVALID_PARAMETER);
364 for (
unsigned int i = 0; i < features.size(); ++i)
365 total += supportVector.at(i).Get() * features.at(i).Get();
367 total = total / denominator + 1.;
368 return total * total;
pandora::StatusCode lar_content::SupportVectorMachine::ReadComponent |
( |
pandora::TiXmlElement * |
pCurrentXmlElement | ) |
|
|
private |
Read the component at the current xml element.
- Parameters
-
pCurrentXmlElement | address of the current xml element |
- Returns
- success
pandora::StatusCode lar_content::SupportVectorMachine::ReadFeatures |
( |
const pandora::TiXmlHandle & |
currentHandle | ) |
|
|
private |
Read the feature component at the current xml handle.
- Parameters
-
currentHandle | the current xml handle |
- Returns
- success
pandora::StatusCode lar_content::SupportVectorMachine::ReadMachine |
( |
const pandora::TiXmlHandle & |
currentHandle | ) |
|
|
private |
Read the machine component at the current xml handle.
- Parameters
-
currentHandle | the current xml handle |
- Returns
- success
pandora::StatusCode lar_content::SupportVectorMachine::ReadSupportVector |
( |
const pandora::TiXmlHandle & |
currentHandle | ) |
|
|
private |
Read the support vector component at the current xml handle.
- Parameters
-
currentHandle | the current xml handle |
- Returns
- success
void lar_content::SupportVectorMachine::ReadXmlFile |
( |
const std::string & |
svmFileName, |
|
|
const std::string & |
svmName |
|
) |
| |
|
private |
Read the svm parameters from an xml file.
- Parameters
-
svmFileName | the sml file name |
svmName | the name of the svm |
void lar_content::SupportVectorMachine::SetKernelFunction |
( |
KernelFunction |
kernelFunction | ) |
|
|
inline |
Set the kernel function to use.
- Parameters
-
kernelFunction | the kernel function |
Definition at line 333 of file LArSupportVectorMachine.h.
KernelFunction m_kernelFunction
The kernel function.
double lar_content::SupportVectorMachine::m_bias |
|
private |
bool lar_content::SupportVectorMachine::m_enableProbability |
|
private |
bool lar_content::SupportVectorMachine::m_isInitialized |
|
private |
KernelMap lar_content::SupportVectorMachine::m_kernelMap |
|
private |
KernelType lar_content::SupportVectorMachine::m_kernelType |
|
private |
unsigned int lar_content::SupportVectorMachine::m_nFeatures |
|
private |
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.
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.
double lar_content::SupportVectorMachine::m_scaleFactor |
|
private |
bool lar_content::SupportVectorMachine::m_standardizeFeatures |
|
private |
SVInfoList lar_content::SupportVectorMachine::m_svInfoList |
|
private |
The documentation for this class was generated from the following files: