RapidLib  v2.1.0
A simple library for interactive machine learning
svmClassification< T > Class Template Reference

#include <svmClassification.h>

Inheritance diagram for svmClassification< T >:
Inheritance graph
Collaboration diagram for svmClassification< T >:
Collaboration graph

Public Types

enum  SVMType {
  C_SVC = 0, NU_SVC, ONE_CLASS, EPSILON_SVR,
  NU_SVR
}
 
enum  KernelType {
  LINEAR_KERNEL = 0, POLY_KERNEL, RBF_KERNEL, SIGMOID_KERNEL,
  PRECOMPUTED_KERNEL
}
 

Public Member Functions

 svmClassification (KernelType kernelType=LINEAR_KERNEL, SVMType svmType=C_SVC, bool useScaling=true, bool useNullRejection=false, bool useAutoGamma=true, float gamma=0.1, unsigned int degree=3, float coef0=0, float nu=0.5, float C=1, bool useCrossValidation=false, unsigned int kFoldValue=10)
 
 svmClassification (int numInputs)
 
 ~svmClassification ()
 
void train (const std::vector< trainingExampleTemplate< T > > &trainingSet)
 
run (const std::vector< T > &inputVector)
 
void reset ()
 
bool init (KernelType kernelType, SVMType svmType, bool useScaling, bool useNullRejection, bool useAutoGamma, float gamma, unsigned int degree, float coef0, float nu, float C, bool useCrossValidation, unsigned int kFoldValue)
 
int getNumInputs () const
 
std::vector< int > getWhichInputs () const
 
void getJSONDescription (Json::Value &currentModel)
 
- Public Member Functions inherited from baseModel< T >
virtual ~baseModel ()
 

Additional Inherited Members

- Protected Member Functions inherited from baseModel< T >
template<typename TT >
Json::Value vector2json (TT vec)
 

Member Enumeration Documentation

§ KernelType

template<typename T >
enum svmClassification::KernelType
Enumerator
LINEAR_KERNEL 
POLY_KERNEL 
RBF_KERNEL 
SIGMOID_KERNEL 
PRECOMPUTED_KERNEL 

§ SVMType

template<typename T >
enum svmClassification::SVMType
Enumerator
C_SVC 
NU_SVC 
ONE_CLASS 
EPSILON_SVR 
NU_SVR 

Constructor & Destructor Documentation

§ svmClassification() [1/2]

template<typename T >
svmClassification< T >::svmClassification ( KernelType  kernelType = LINEAR_KERNEL,
SVMType  svmType = C_SVC,
bool  useScaling = true,
bool  useNullRejection = false,
bool  useAutoGamma = true,
float  gamma = 0.1,
unsigned int  degree = 3,
float  coef0 = 0,
float  nu = 0.5,
float  C = 1,
bool  useCrossValidation = false,
unsigned int  kFoldValue = 10 
)

Default constructor.

Set the initial SVM settings, although these can be changed at any time using either init(...) function of the set... functions.

Parameters
kernelTypethis sets the SVM kernelType. Options are LINEAR_KERNEL, POLY_KERNEL, RBF_KERNEL, SIGMOID_KERNEL, PRECOMPUTED_KERNEL. The default kernelType is kernelType=LINEAR_KERNEL
svmTypethis sets the SVM type. Options are C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR. The default svmType is svmType=C_SVC
useScalingsets if the training/prediction data will be scaled to the default range of [-1. 1.]. The SVM algorithm commonly achieves a better classification result if scaling is turned on. The default useScaling value is useScaling=true
useNullRejectionsets if a predicted class will be rejected if the classes' probability is below the classificationThreshold. The default value is useNullRejection=false
useAutoGammasets if the SVM gamma parameter will automatically be computed, if set to true then gamma will be set to (1.0/numFeatures), where numFeatures is the number of features in the training data. The default value is useAutoGamma=true
gammasets the SVM gamma parameter. The default value is gamma=0.1
degreesets the SVM degree parameter. The default value is degree=3
coef0sets the SVM coef0 parameter. The default value is coef0=0
nusets the SVM nu parameter. The default value is nu=0.5
Csets the SVM C parameter. The default value is C=1
useCrossValidationsets if the SVM model will be trained using cross validation. The default value is useCrossValidation=false
kFoldValuesets the number of folds that will be used for cross validation. The default value is kFoldValue=10

§ svmClassification() [2/2]

template<typename T >
svmClassification< T >::svmClassification ( int  numInputs)

§ ~svmClassification()

template<typename T >
svmClassification< T >::~svmClassification ( )

Destructor

Member Function Documentation

§ getJSONDescription()

template<typename T >
void svmClassification< T >::getJSONDescription ( Json::Value &  currentModel)
virtual

Implements baseModel< T >.

§ getNumInputs()

template<typename T >
int svmClassification< T >::getNumInputs ( ) const
virtual

Implements baseModel< T >.

§ getWhichInputs()

template<typename T >
std::vector< int > svmClassification< T >::getWhichInputs ( ) const
virtual

Implements baseModel< T >.

§ init()

template<typename T >
bool svmClassification< T >::init ( KernelType  kernelType,
SVMType  svmType,
bool  useScaling,
bool  useNullRejection,
bool  useAutoGamma,
float  gamma,
unsigned int  degree,
float  coef0,
float  nu,
float  C,
bool  useCrossValidation,
unsigned int  kFoldValue 
)

This initializes the SVM settings and parameters. Any previous model, settings, or problems will be cleared.

Parameters
kernelTypethis sets the SVM kernelType. Options are LINEAR_KERNEL, POLY_KERNEL, RBF_KERNEL, SIGMOID_KERNEL, PRECOMPUTED_KERNEL
UINTsvmType: this sets the SVM type. Options are C_SVC, NU_SVC, ONE_CLASS, EPSILON_SVR, NU_SVR
useScalingsets if the training/prediction data will be scaled to the default range of [-1. 1.]. The SVM algorithm commonly achieves a better classification result if scaling is turned on
useNullRejectionsets if a predicted class will be rejected if the classes' probability is below the classificationThreshold
useAutoGammasets if the SVM gamma parameter will automatically be computed, if set to true then gamma will be set to (1.0/numFeatures), where numFeatures is the number of features in the training data
gammasets the SVM gamma parameter
degreesets the SVM degree parameter
coef0sets the SVM coef0 parameter
nusets the SVM nu parameter
Csets the SVM C parameter
useCrossValidationsets if the SVM model will be trained using cross validation
kFoldValuesets the number of folds that will be used for cross validation
Returns
returns true if the SVM was initialized, false otherwise

§ reset()

template<typename T >
void svmClassification< T >::reset ( )
virtual

Implements baseModel< T >.

§ run()

template<typename T >
T svmClassification< T >::run ( const std::vector< T > &  inputVector)
virtual

Generate an output value from a single input vector.

Parameters
Astandard vector of doubles to be evaluated.
Returns
A single double: the nearest class as determined by k-nearest neighbor.

Implements baseModel< T >.

§ train()

template<typename T >
void svmClassification< T >::train ( const std::vector< trainingExampleTemplate< T > > &  trainingSet)
virtual

Fill the model with a vector of examples.

Parameters
Thetraining set is a vector of training examples that contain both a vector of input values and a double specifying desired output class.

Implements baseModel< T >.


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