shark::SvmLogisticInterpretation< InputType > Class Template Reference

Maximum-likelihood model selection score for binary support vector machines. More...

#include <shark/ObjectiveFunctions/SvmLogisticInterpretation.h>

+ Inheritance diagram for shark::SvmLogisticInterpretation< InputType >:

Public Types

typedef CVFolds< LabeledData< InputType, unsigned int > > FoldsType
 
typedef AbstractKernelFunction< InputTypeKernelType
 
- Public Types inherited from shark::AbstractObjectiveFunction< PointType, ResultT >
enum  Feature {
  HAS_VALUE = 1, HAS_FIRST_DERIVATIVE = 2, HAS_SECOND_DERIVATIVE = 4, CAN_PROPOSE_STARTING_POINT = 8,
  IS_CONSTRAINED_FEATURE = 16, HAS_CONSTRAINT_HANDLER = 32, CAN_PROVIDE_CLOSEST_FEASIBLE = 64, IS_THREAD_SAFE = 128,
  IS_NOISY = 256
}
 List of features that are supported by an implementation. More...
 
typedef PointType SearchPointType
 
typedef ResultT ResultType
 
typedef boost::mpl::if_< std::is_arithmetic< ResultT >, SearchPointType, RealMatrix >::type FirstOrderDerivative
 
typedef TypedFlags< FeatureFeatures
 This statement declares the member m_features. See Core/Flags.h for details. More...
 
typedef TypedFeatureNotAvailableException< FeatureFeatureNotAvailableException
 

Public Member Functions

 SvmLogisticInterpretation (FoldsType const &folds, KernelType *kernel, bool unconstrained=true, QpStoppingCondition *stop_cond=NULL)
 
std::string name () const
 From INameable: return the class name. More...
 
bool isFeasible (const SearchPointType &input) const
 
std::size_t numberOfVariables () const
 Accesses the number of variables. More...
 
double eval (SearchPointType const &parameters) const
 
double evalDerivative (SearchPointType const &parameters, FirstOrderDerivative &derivative) const
 
- Public Member Functions inherited from shark::AbstractObjectiveFunction< PointType, ResultT >
const Featuresfeatures () const
 
virtual void updateFeatures ()
 
bool hasValue () const
 returns whether this function can calculate it's function value More...
 
bool hasFirstDerivative () const
 returns whether this function can calculate the first derivative More...
 
bool hasSecondDerivative () const
 returns whether this function can calculate the second derivative More...
 
bool canProposeStartingPoint () const
 returns whether this function can propose a starting point. More...
 
bool isConstrained () const
 returns whether this function can return More...
 
bool hasConstraintHandler () const
 returns whether this function can return More...
 
bool canProvideClosestFeasible () const
 Returns whether this function can calculate thee closest feasible to an infeasible point. More...
 
bool isThreadSafe () const
 Returns true, when the function can be usd in parallel threads. More...
 
bool isNoisy () const
 Returns true, when the function can be usd in parallel threads. More...
 
 AbstractObjectiveFunction ()
 Default ctor. More...
 
virtual ~AbstractObjectiveFunction ()
 Virtual destructor. More...
 
virtual void init ()
 
void setRng (random::rng_type *rng)
 Sets the Rng used by the objective function. More...
 
virtual bool hasScalableDimensionality () const
 
virtual void setNumberOfVariables (std::size_t numberOfVariables)
 Adjusts the number of variables if the function is scalable. More...
 
virtual std::size_t numberOfObjectives () const
 
virtual bool hasScalableObjectives () const
 
virtual void setNumberOfObjectives (std::size_t numberOfObjectives)
 Adjusts the number of objectives if the function is scalable. More...
 
std::size_t evaluationCounter () const
 Accesses the evaluation counter of the function. More...
 
AbstractConstraintHandler< SearchPointType > const & getConstraintHandler () const
 Returns the constraint handler of the function if it has one. More...
 
virtual void closestFeasible (SearchPointType &input) const
 If supported, the supplied point is repaired such that it satisfies all of the function's constraints. More...
 
virtual SearchPointType proposeStartingPoint () const
 Proposes a starting point in the feasible search space of the function. More...
 
ResultType operator() (SearchPointType const &input) const
 Evaluates the function. Useful together with STL-Algorithms like std::transform. More...
 
virtual ResultType evalDerivative (SearchPointType const &input, SecondOrderDerivative &derivative) const
 Evaluates the objective function and calculates its gradient. More...
 
- Public Member Functions inherited from shark::INameable
virtual ~INameable ()
 

Protected Attributes

FoldsType m_folds
 the underlying partitioned dataset. More...
 
KernelTypemep_kernel
 the kernel with which to run the SVM More...
 
std::size_t m_nhp
 for convenience, the Number of Hyper Parameters More...
 
std::size_t m_nkp
 for convenience, the Number of Kernel Parameters More...
 
std::size_t m_numFolds
 the number of folds to be used in cross-validation More...
 
std::size_t m_numSamples
 overall number of samples in the dataset More...
 
std::size_t m_inputDims
 input dimensionality More...
 
bool m_svmCIsUnconstrained
 the SVM regularization parameter C is passed for unconstrained optimization, and the derivative should compensate for that More...
 
QpStoppingConditionmep_svmStoppingCondition
 the stopping criterion that is to be passed to the SVM trainer. More...
 
- Protected Attributes inherited from shark::AbstractObjectiveFunction< PointType, ResultT >
Features m_features
 
std::size_t m_evaluationCounter
 Evaluation counter, default value: 0. More...
 
AbstractConstraintHandler< SearchPointType > const * m_constraintHandler
 
random::rng_type * mep_rng
 

Additional Inherited Members

- Protected Member Functions inherited from shark::AbstractObjectiveFunction< PointType, ResultT >
void announceConstraintHandler (AbstractConstraintHandler< SearchPointType > const *handler)
 helper function which is called to announce the presence of an constraint handler. More...
 

Detailed Description

template<class InputType = RealVector>
class shark::SvmLogisticInterpretation< InputType >

Maximum-likelihood model selection score for binary support vector machines.

This class implements the maximum-likelihood based SVM model selection procedure presented in the article "Glasmachers and C. Igel. Maximum Likelihood Model Selection for 1-Norm Soft Margin SVMs with Multiple Parameters. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2010." At this point, only binary C-SVMs are supported.
This class implements an AbstactObjectiveFunction. In detail, it provides a differentiable measure of how well a C-SVM with given hyperparameters fulfills the maximum-likelihood score presented in the paper. This error measure can then be optimized for externally via gradient-based optimizers. In other words, this class provides a score, not an optimization method or a training algorithm. The C-SVM parameters have to be optimized with regard to this measure

Definition at line 63 of file SvmLogisticInterpretation.h.

Member Typedef Documentation

◆ FoldsType

template<class InputType = RealVector>
typedef CVFolds< LabeledData<InputType, unsigned int> > shark::SvmLogisticInterpretation< InputType >::FoldsType

Definition at line 65 of file SvmLogisticInterpretation.h.

◆ KernelType

template<class InputType = RealVector>
typedef AbstractKernelFunction<InputType> shark::SvmLogisticInterpretation< InputType >::KernelType

Definition at line 66 of file SvmLogisticInterpretation.h.

Constructor & Destructor Documentation

◆ SvmLogisticInterpretation()

template<class InputType = RealVector>
shark::SvmLogisticInterpretation< InputType >::SvmLogisticInterpretation ( FoldsType const &  folds,
KernelType kernel,
bool  unconstrained = true,
QpStoppingCondition stop_cond = NULL 
)
inline

constructor.

Parameters
foldsan already partitioned dataset (i.e., a CVFolds object)
kernelpointer to the kernel to be used within the SVMs.
unconstrainedwhether or not the C-parameter of/for the C-SVM is passed for unconstrained optimization mode.
stop_condthe stopping conditions which are to be passed to the

Definition at line 84 of file SvmLogisticInterpretation.h.

References shark::AbstractObjectiveFunction< PointType, ResultT >::HAS_FIRST_DERIVATIVE, shark::AbstractObjectiveFunction< PointType, ResultT >::HAS_VALUE, shark::AbstractKernelFunction< InputTypeT >::hasFirstParameterDerivative(), shark::AbstractObjectiveFunction< PointType, ResultT >::IS_CONSTRAINED_FEATURE, shark::AbstractObjectiveFunction< PointType, ResultT >::m_features, and SHARK_RUNTIME_CHECK.

Member Function Documentation

◆ eval()

template<class InputType = RealVector>
double shark::SvmLogisticInterpretation< InputType >::eval ( SearchPointType const &  parameters) const
inlinevirtual

train a number of SVMs in a cross-validation setting using the hyperparameters passed to this method. the output scores from all validations sets are then concatenated. together with the true labels, these scores can then be used to fit a sigmoid such that it becomes as good as possible a model for the class membership probabilities given the SVM output scores. This method returns the negative likelihood of the best fitting sigmoid, given a set of SVM hyperparameters.

Parameters
parametersthe SVM hyperparameters to use for all C-SVMs

Reimplemented from shark::AbstractObjectiveFunction< PointType, ResultT >.

Definition at line 131 of file SvmLogisticInterpretation.h.

References shark::IParameterizable< VectorType >::setParameterVector(), and SHARK_RUNTIME_CHECK.

Referenced by run_one_trial().

◆ evalDerivative()

template<class InputType = RealVector>
double shark::SvmLogisticInterpretation< InputType >::evalDerivative ( SearchPointType const &  parameters,
FirstOrderDerivative derivative 
) const
inlinevirtual

the derivative of the error() function above w.r.t. the parameters.

Parameters
parametersthe SVM hyperparameters to use for all C-SVMs
derivativewill store the computed derivative w.r.t. the current hyperparameters

Reimplemented from shark::AbstractObjectiveFunction< PointType, ResultT >.

Definition at line 167 of file SvmLogisticInterpretation.h.

References shark::IParameterizable< VectorType >::setParameterVector(), and SHARK_RUNTIME_CHECK.

◆ isFeasible()

template<class InputType = RealVector>
bool shark::SvmLogisticInterpretation< InputType >::isFeasible ( const SearchPointType input) const
inlinevirtual

checks whether the search point provided is feasible

Parameters
inputthe point to test for feasibility

Reimplemented from shark::AbstractObjectiveFunction< PointType, ResultT >.

Definition at line 113 of file SvmLogisticInterpretation.h.

References shark::SvmLogisticInterpretation< InputType >::m_nhp, shark::SvmLogisticInterpretation< InputType >::m_svmCIsUnconstrained, and SHARK_ASSERT.

◆ name()

template<class InputType = RealVector>
std::string shark::SvmLogisticInterpretation< InputType >::name ( ) const
inlinevirtual

From INameable: return the class name.

Reimplemented from shark::INameable.

Definition at line 108 of file SvmLogisticInterpretation.h.

◆ numberOfVariables()

template<class InputType = RealVector>
std::size_t shark::SvmLogisticInterpretation< InputType >::numberOfVariables ( ) const
inlinevirtual

Accesses the number of variables.

Implements shark::AbstractObjectiveFunction< PointType, ResultT >.

Definition at line 121 of file SvmLogisticInterpretation.h.

References shark::SvmLogisticInterpretation< InputType >::m_nhp.

Member Data Documentation

◆ m_folds

template<class InputType = RealVector>
FoldsType shark::SvmLogisticInterpretation< InputType >::m_folds
protected

the underlying partitioned dataset.

Definition at line 68 of file SvmLogisticInterpretation.h.

◆ m_inputDims

template<class InputType = RealVector>
std::size_t shark::SvmLogisticInterpretation< InputType >::m_inputDims
protected

input dimensionality

Definition at line 74 of file SvmLogisticInterpretation.h.

◆ m_nhp

template<class InputType = RealVector>
std::size_t shark::SvmLogisticInterpretation< InputType >::m_nhp
protected

◆ m_nkp

template<class InputType = RealVector>
std::size_t shark::SvmLogisticInterpretation< InputType >::m_nkp
protected

for convenience, the Number of Kernel Parameters

Definition at line 71 of file SvmLogisticInterpretation.h.

◆ m_numFolds

template<class InputType = RealVector>
std::size_t shark::SvmLogisticInterpretation< InputType >::m_numFolds
protected

the number of folds to be used in cross-validation

Definition at line 72 of file SvmLogisticInterpretation.h.

◆ m_numSamples

template<class InputType = RealVector>
std::size_t shark::SvmLogisticInterpretation< InputType >::m_numSamples
protected

overall number of samples in the dataset

Definition at line 73 of file SvmLogisticInterpretation.h.

◆ m_svmCIsUnconstrained

template<class InputType = RealVector>
bool shark::SvmLogisticInterpretation< InputType >::m_svmCIsUnconstrained
protected

the SVM regularization parameter C is passed for unconstrained optimization, and the derivative should compensate for that

Definition at line 75 of file SvmLogisticInterpretation.h.

Referenced by shark::SvmLogisticInterpretation< InputType >::isFeasible().

◆ mep_kernel

template<class InputType = RealVector>
KernelType* shark::SvmLogisticInterpretation< InputType >::mep_kernel
protected

the kernel with which to run the SVM

Definition at line 69 of file SvmLogisticInterpretation.h.

◆ mep_svmStoppingCondition

template<class InputType = RealVector>
QpStoppingCondition* shark::SvmLogisticInterpretation< InputType >::mep_svmStoppingCondition
protected

the stopping criterion that is to be passed to the SVM trainer.

Definition at line 76 of file SvmLogisticInterpretation.h.


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