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 (const kernel::Kernel &=_svm_ker, UINT n_in=0)
 SVM (const SVM &)
 SVM (std::istream &is)
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)
UINT n_support_vectors () const
Input support_vector (UINT) const
REAL support_vector_coef (UINT) const
REAL bias () const
REAL kernel (const Input &, const Input &) const
virtual bool support_weighted_data () const
 Whether the learning model/algorithm supports unequally weighted data.
virtual void initialize ()
 Initialize the model for training.
virtual REAL 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)
virtual bool serialize (std::ostream &, ver_list &) const
virtual bool unserialize (std::istream &, ver_list &, const id_t &=empty_id)

Detailed Description

Definition at line 21 of file svm.h.


Constructor & Destructor Documentation

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

Definition at line 187 of file svm.cpp.

References Kernel::set_params().

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

SVM const SVM  ) 
 

Definition at line 192 of file svm.cpp.

References SVM::detail.

SVM std::istream &  is  )  [inline, explicit]
 

Definition at line 29 of file svm.h.

~SVM  )  [virtual]
 

Definition at line 196 of file svm.cpp.


Member Function Documentation

REAL bias  )  const
 

Definition at line 337 of file svm.cpp.

Referenced by SVM::signed_margin().

REAL C  )  const
 

Definition at line 211 of file svm.cpp.

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 35 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 34 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]
 

Initialize the model for training.

Todo:
whether or when to initialize is a big problem. If we allow "continue_on_learning", then sometimes the initialization is not needed
Note:
this was a virtual function, I changed it to be empty

Reimplemented from LearnModel.

Definition at line 236 of file svm.cpp.

REAL kernel const Input ,
const Input
const
 

Definition at line 224 of file svm.cpp.

References EPSILON, and lemga::fill_svm_node().

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 51 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 247 of file svm.cpp.

References INFINITESIMAL, and SVM::signed_margin().

UINT n_support_vectors  )  const
 

Definition at line 219 of file svm.cpp.

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

Output operator() const Input  )  const [virtual]
 

Implements LearnModel.

Definition at line 299 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 200 of file svm.cpp.

References SVM::detail, and OBJ_FUNC_UNDEFINED.

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

Reimplemented from LearnModel.

Definition at line 179 of file svm.cpp.

References OBJ_FUNC_UNDEFINED.

void set_C REAL   ) 
 

Definition at line 215 of file svm.cpp.

REAL signed_margin const Input  )  const [protected]
 

(positive belief means the larger label)

Definition at line 252 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()().

Input support_vector UINT   )  const
 

Definition at line 314 of file svm.cpp.

References LearnModel::_n_in, and SVM::n_support_vectors().

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

REAL support_vector_coef UINT   )  const
 

Returns:
$y_i\alpha_i$

Definition at line 328 of file svm.cpp.

References SVM::n_support_vectors().

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 46 of file svm.h.

REAL train  )  [virtual]
 

Train with preset data set and sample weight.

Returns:
Probably the training error.
Todo:
Make the return type void

Implements LearnModel.

Definition at line 240 of file svm.cpp.

References LearnModel::n_input(), and LearnModel::n_output().

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

Reimplemented from LearnModel.

Definition at line 183 of file svm.cpp.

References OBJ_FUNC_UNDEFINED.

REAL w_norm  )  const
 

Definition at line 275 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 Mon Jan 9 23:45:14 2006 for LEMGA by  doxygen 1.4.6