MeLOn
melon::SupportVectorMachine< T > Class Template Referenceabstract

Class defining support vector machine to be used in the MAiNGO solver. More...

#include <svm.h>

Inheritance diagram for melon::SupportVectorMachine< T >:
melon::MelonModel< T > melon::SupportVectorMachineOneClass< T > melon::SupportVectorRegression< T >

Public Member Functions

 SupportVectorMachine ()
 Default Constructor. More...
 
 SupportVectorMachine (std::string modelName)
 Constructor. More...
 
 SupportVectorMachine (std::string modelPath, std::string modelName)
 Constructor. More...
 
 SupportVectorMachine (std::shared_ptr< const SvmData > modelData)
 Constructor. More...
 
void get_fullspace_variables (size_t &variableNumber, std::vector< std::string > &variableNames, std::vector< std::pair< double, double >> &variableBounds)
 Creates variables for the full space formulation in MAiNGO. More...
 
calculate_prediction_full_space (std::vector< T > input, std::vector< T > internalVariables, std::vector< T > &constraints)
 Calculates prediction based on inputs and set constraints for fullspace formulation. More...
 
calculate_prediction_reduced_space (std::vector< T > input)
 Calculates prediction based on inputs in reduced space. More...
 
size_t get_number_of_full_space_variables ()
 Calculates the number of full space variables. More...
 
- Public Member Functions inherited from melon::MelonModel< T >
virtual ~MelonModel ()=default
 Default destructor. More...
 
void load_model (std::string modelName, MODEL_FILE_TYPE fileType)
 Loads new model from file. More...
 
void load_model (std::string modelPath, std::string modelName, MODEL_FILE_TYPE fileType)
 Loads new model from file. More...
 
void load_model (std::shared_ptr< const ModelData > modelData)
 Loads new model from file. More...
 

Protected Member Functions

void _set_data_object (std::shared_ptr< const ModelData > modelData) override
 Sets data object containing model parameters. More...
 
_calculate_prediction (std::vector< T > input, std::vector< T > internalVariables, const bool fullSpace, std::vector< T > &constraints)
 Calculates prediction. More...
 
void _update_kernel ()
 Loads kernel according to loaded internal parameters. More...
 
virtual T _decision_function (std::vector< T > kernelValues)=0
 Decision function used by the different types of svms. More...
 
- Protected Member Functions inherited from melon::MelonModel< T >
 MelonModel (std::shared_ptr< ModelParserFactory > parserFactory)
 Constructor. More...
 
template<typename RandomAccessIterator >
void _set_constraints (std::vector< T > &constraints, std::vector< T > &constraintEvaluation, RandomAccessIterator &constraintValue)
 Sets constraints required for fullspace opimization. More...
 
template<typename RandomAccessIterator >
void _set_constraints (std::vector< T > &constraints, T &constraintEvaluation, RandomAccessIterator &constraintValue)
 Sets constraints required for fullspace opimization. More...
 

Protected Attributes

std::shared_ptr< const SvmData_data
 
std::unique_ptr< kernel::StationaryKernel< double, T > > _kernel
 
std::unique_ptr< Scaler< T > > _inputScaler
 
std::unique_ptr< Scaler< T > > _outputScaler
 
- Protected Attributes inherited from melon::MelonModel< T >
bool _modelLoaded { false }
 
std::shared_ptr< ModelParserFactory_parserFactory
 

Detailed Description

template<typename T>
class melon::SupportVectorMachine< T >

Class defining support vector machine to be used in the MAiNGO solver.

Constructor & Destructor Documentation

◆ SupportVectorMachine() [1/4]

template<typename T >
melon::SupportVectorMachine< T >::SupportVectorMachine ( )
inline

Default Constructor.

◆ SupportVectorMachine() [2/4]

template<typename T >
melon::SupportVectorMachine< T >::SupportVectorMachine ( std::string  modelName)
inline

Constructor.

Parameters
[in]modelNameis the name of the svm

◆ SupportVectorMachine() [3/4]

template<typename T >
melon::SupportVectorMachine< T >::SupportVectorMachine ( std::string  modelPath,
std::string  modelName 
)
inline

Constructor.

Parameters
[in]modelPathis the path to the directory in which the svm file is located
[in]modelNameis the name of the svm

◆ SupportVectorMachine() [4/4]

template<typename T >
melon::SupportVectorMachine< T >::SupportVectorMachine ( std::shared_ptr< const SvmData modelData)
inline

Constructor.

Parameters
[in]modelDatais a SvmData object containing the data which defines the svm

Member Function Documentation

◆ _calculate_prediction()

template<typename T >
T melon::SupportVectorMachine< T >::_calculate_prediction ( std::vector< T >  input,
std::vector< T >  internalVariables,
const bool  fullSpace,
std::vector< T > &  constraints 
)
protected

Calculates prediction.

Parameters
[in]inputis a vector of inputs for which the prediction will be evaluated
[in]internalVariablesholds variables that are used in full space formulation and not in reduced space
[in]fullSpacedecides if evaluation shall be done in full or reduced space
[out]constraintswill be filled in case of fullSpace formulation
Returns
returns the result of the evaluation

◆ _decision_function()

template<typename T >
virtual T melon::SupportVectorMachine< T >::_decision_function ( std::vector< T >  kernelValues)
protectedpure virtual

Decision function used by the different types of svms.

Parameters
[in]kernelValuesis a vector containing the kernel evaluations for the the support vectors with the input.
Returns
returns the result of the decision function

Implemented in melon::SupportVectorMachineOneClass< T >, and melon::SupportVectorRegression< T >.

◆ _set_data_object()

template<typename T >
void melon::SupportVectorMachine< T >::_set_data_object ( std::shared_ptr< const ModelData modelData)
overrideprotectedvirtual

Sets data object containing model parameters.

Parameters
[in]modelDatais a ModelData object containing the data which defines the model

Implements melon::MelonModel< T >.

◆ _update_kernel()

template<typename T >
void melon::SupportVectorMachine< T >::_update_kernel
protected

Loads kernel according to loaded internal parameters.

◆ calculate_prediction_full_space()

template<typename T >
T melon::SupportVectorMachine< T >::calculate_prediction_full_space ( std::vector< T >  input,
std::vector< T >  internalVariables,
std::vector< T > &  constraints 
)

Calculates prediction based on inputs and set constraints for fullspace formulation.

Parameters
[in]inputis a vector of inputs for which the constraint will be evaluated
[in]internalVariablesholds variables that are used in full space formulation and not in reduced space
[out]constraintswill be filled in case of fullSpace formulation (such that internal Variables are equal to internal evaluation)
Returns
returns the result of the calculation

◆ calculate_prediction_reduced_space()

template<typename T >
T melon::SupportVectorMachine< T >::calculate_prediction_reduced_space ( std::vector< T >  input)

Calculates prediction based on inputs in reduced space.

Parameters
[in]inputis a vector of inputs for which the constraint will be evaluated
Returns
returns the result of the calculation

◆ get_fullspace_variables()

template<typename T >
void melon::SupportVectorMachine< T >::get_fullspace_variables ( size_t &  variableNumber,
std::vector< std::string > &  variableNames,
std::vector< std::pair< double, double >> &  variableBounds 
)

Creates variables for the full space formulation in MAiNGO.

Parameters
[out]variableNumberis the number of variables created
[out]variableNamesis a vetor of the corresponding variable names
[out]variableBoundsis a pair vector of bounds for each variable

◆ get_number_of_full_space_variables()

template<typename T >
size_t melon::SupportVectorMachine< T >::get_number_of_full_space_variables

Calculates the number of full space variables.

Returns
returns the number of full space variables

Member Data Documentation

◆ _data

template<typename T >
std::shared_ptr<const SvmData> melon::SupportVectorMachine< T >::_data
protected

object containing the data and parameters of the svm

◆ _inputScaler

template<typename T >
std::unique_ptr<Scaler<T> > melon::SupportVectorMachine< T >::_inputScaler
protected

Object for scaling input data

◆ _kernel

template<typename T >
std::unique_ptr<kernel::StationaryKernel<double, T> > melon::SupportVectorMachine< T >::_kernel
protected

kernel object

◆ _outputScaler

template<typename T >
std::unique_ptr<Scaler<T> > melon::SupportVectorMachine< T >::_outputScaler
protected

Object for scaling output data


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