SVM Class Reference

#include <svm.h>

Inheritance diagram for SVM:

Inheritance graph
[legend]
Collaboration diagram for SVM:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SVM (UINT n_in=0)
 SVM (const kernel::Kernel &, UINT n_in=0)
 SVM (const SVM &)
 SVM (std::istream &)
virtual ~SVM ()
const SVMoperator= (const SVM &)
virtual const id_tid () const
virtual SVMcreate () const
 Create a new object using the default constructor.
virtual SVMclone () const
 Create a new object by replicating itself.
REAL C () const
void set_C (REAL c)
UINT n_support_vectors () const
const Inputsupport_vector (UINT i) const
REAL support_vector_coef (UINT i) const
REAL bias () const
const kernel::Kernelkernel () const
REAL kernel (const Input &, const Input &) const
void set_kernel (const kernel::Kernel &)
virtual bool support_weighted_data () const
 Whether the learning model/algorithm supports unequally weighted data.
virtual void initialize ()
virtual void train ()
 Train with preset data set and sample weight.
virtual Output operator() (const Input &) const
virtual REAL margin_norm () const
 The normalization term for margins.
virtual REAL margin_of (const Input &, const Output &) const
 Report the (unnormalized) margin of an example (x, y).
REAL w_norm () const

Protected Member Functions

REAL signed_margin (const Input &) const
 (positive belief means the larger label)
void reset_model ()
virtual bool serialize (std::ostream &, ver_list &) const
virtual bool unserialize (std::istream &, ver_list &, const id_t &=NIL_ID)

Detailed Description

Definition at line 19 of file svm.h.


Constructor & Destructor Documentation

SVM UINT  n_in = 0  )  [explicit]
 

Definition at line 232 of file svm.cpp.

Referenced by SVM::clone(), and SVM::create().

SVM const kernel::Kernel ,
UINT  n_in = 0
[explicit]
 

Definition at line 236 of file svm.cpp.

References SVM::set_kernel().

SVM const SVM  ) 
 

Definition at line 242 of file svm.cpp.

References SVM::detail, SVM::ker, and SVM::set_kernel().

SVM std::istream &   )  [explicit]
 

Definition at line 249 of file svm.cpp.

~SVM  )  [virtual]
 

Definition at line 254 of file svm.cpp.


Member Function Documentation

REAL bias  )  const [inline]
 

Definition at line 47 of file svm.h.

Referenced by SVM::signed_margin().

REAL C  )  const [inline]
 

Definition at line 41 of file svm.h.

virtual SVM* clone  )  const [inline, virtual]
 

Create a new object by replicating itself.

Returns:
A pointer to the new copy.
The code for a derived class Derived is always
 return new Derived(*this); 
Though seemingly redundant, it helps to copy an object without knowing the real type of the object.
See also:
C++ FAQ Lite 20.6

Implements LearnModel.

Definition at line 39 of file svm.h.

References SVM::SVM().

virtual SVM* create  )  const [inline, virtual]
 

Create a new object using the default constructor.

The code for a derived class Derived is always

 return new Derived(); 

Implements LearnModel.

Definition at line 38 of file svm.h.

References SVM::SVM().

virtual const id_t& id  )  const [virtual]
 

Returns:
Class ID string (class name)

Implements Object.

void initialize  )  [virtual]
 

Reimplemented from LearnModel.

Definition at line 300 of file svm.cpp.

References SVM::reset_model().

REAL kernel const Input ,
const Input
const
 

Definition at line 275 of file svm.cpp.

References EPSILON, and lemga::fill_svm_node().

const kernel::Kernel& kernel  )  const [inline]
 

Definition at line 48 of file svm.h.

Referenced by Perceptron::Perceptron().

virtual REAL margin_norm  )  const [inline, virtual]
 

The normalization term for margins.

The margin concept can be normalized or unnormalized. For example, for a perceptron model, the unnormalized margin would be the wegithed sum of the input features, and the normalized margin would be the distance to the hyperplane, and the normalization term is the norm of the hyperplane weight.

Since the normalization term is usually a constant, it would be more efficient if it is precomputed instead of being calculated every time when a margin is asked for. The best way is to use a cache. Here I use a easier way: let the users decide when to compute the normalization term.

Reimplemented from LearnModel.

Definition at line 57 of file svm.h.

References SVM::w_norm().

REAL margin_of const Input ,
const Output
const [virtual]
 

Report the (unnormalized) margin of an example (x, y).

Reimplemented from LearnModel.

Definition at line 351 of file svm.cpp.

References INFINITESIMAL, and SVM::signed_margin().

UINT n_support_vectors  )  const [inline]
 

Definition at line 43 of file svm.h.

Referenced by Perceptron::Perceptron(), SVM::signed_margin(), and SVM::w_norm().

Output operator() const Input  )  const [virtual]
 

Implements LearnModel.

Definition at line 410 of file svm.cpp.

References lemga::fill_svm_node(), INFINITESIMAL, LearnModel::n_input(), and SVM::signed_margin().

const SVM & operator= const SVM  ) 
 

Definition at line 259 of file svm.cpp.

References SVM::coef, SVM::coef0, SVM::detail, SVM::ker, SVM::regC, SVM::set_kernel(), and SVM::sv.

void reset_model  )  [protected]
 

Definition at line 304 of file svm.cpp.

Referenced by SVM::initialize(), SVM::set_kernel(), SVM::train(), and SVM::unserialize().

bool serialize std::ostream &  ,
ver_list
const [protected, virtual]
 

Reimplemented from LearnModel.

Definition at line 179 of file svm.cpp.

References LearnModel::_n_in, and SERIALIZE_PARENT.

void set_C REAL  c  )  [inline]
 

Definition at line 42 of file svm.h.

void set_kernel const kernel::Kernel  ) 
 

Definition at line 289 of file svm.cpp.

References Kernel::clone(), SVM::reset_model(), and Kernel::set_params().

Referenced by SVM::operator=(), SVM::SVM(), and SVM::unserialize().

REAL signed_margin const Input  )  const [protected]
 

(positive belief means the larger label)

Definition at line 356 of file svm.cpp.

References SVM::bias(), EPSILON, lemga::fill_svm_node(), LearnModel::n_input(), SVM::n_support_vectors(), SVM::support_vector(), and SVM::support_vector_coef().

Referenced by SVM::margin_of(), and SVM::operator()().

const Input& support_vector UINT  i  )  const [inline]
 

Definition at line 44 of file svm.h.

Referenced by Perceptron::Perceptron(), SVM::signed_margin(), and SVM::w_norm().

REAL support_vector_coef UINT  i  )  const [inline]
 

Returns:
$y_i\alpha_i$

Definition at line 46 of file svm.h.

Referenced by Perceptron::Perceptron(), SVM::signed_margin(), and SVM::w_norm().

virtual bool support_weighted_data  )  const [inline, virtual]
 

Whether the learning model/algorithm supports unequally weighted data.

Returns:
true if supporting; false otherwise. The default is false, just for safety.
See also:
set_train_data()

Reimplemented from LearnModel.

Definition at line 52 of file svm.h.

void train  )  [virtual]
 

Train with preset data set and sample weight.

Implements LearnModel.

Definition at line 309 of file svm.cpp.

References LearnModel::_n_in, SVM::reset_model(), and LearnModel::set_dimensions().

bool unserialize std::istream &  ,
ver_list ,
const id_t = NIL_ID
[protected, virtual]
 

Reimplemented from LearnModel.

Definition at line 201 of file svm.cpp.

References LearnModel::_n_in, Object::create(), Object::NIL_ID, SVM::reset_model(), SVM::set_kernel(), and UNSERIALIZE_PARENT.

REAL w_norm  )  const
 

Definition at line 383 of file svm.cpp.

References EPSILON, SVM::n_support_vectors(), SVM::support_vector(), and SVM::support_vector_coef().

Referenced by SVM::margin_norm().


The documentation for this class was generated from the following files:
Generated on Wed Nov 8 08:17:25 2006 for LEMGA by  doxygen 1.4.6