A base class for sequential minimal optimisation. More...
#include <clsfy_smo_base.h>
Public Member Functions | |
const vnl_vector< double > & | lagrange_mults () const |
Get the optimised parameters. | |
void | set_lagrange_mults (const vnl_vector< double > &lagrange_mults) |
Set the initial values of the parameters to be optimised. | |
double | bias () |
Bias term in function evaluation. | |
virtual void | reseed (unsigned long seed) |
Reseeds the internal random number generator. | |
const double & | tolerance () const |
amount by which a sample can violate the KKT conditions. | |
void | set_tolerance (double tolerance) |
Set the amount by which a sample can violate the KKT conditions. | |
double | eps () const |
tolerance on several equalities. | |
void | set_eps (double eps) |
Set the tolerance on several equalities. | |
clsfy_smo_base () | |
virtual | ~clsfy_smo_base () |
virtual double | error_rate () |
virtual int | calc ()=0 |
Run the optimisation. | |
double | error () |
error rate on the training data. | |
Protected Member Functions | |
virtual int | take_step (int i1, int i2, double E1)=0 |
Attempt to jointly optimise Lagrange multipliers i1, and i2. | |
virtual int | examine_example (int i1)=0 |
Attempt to optimise sample i1. | |
const vnl_vector< double > & | data_point (unsigned long l) |
Access the data points. | |
virtual double | kernel (int i1, int i2)=0 |
Calculate the kernel for data items i1 and i2;. | |
virtual double | learned_func (int k) |
Calculate the classifier function learnt so far for data item k. | |
Protected Attributes | |
double | error_ |
Error rate on the training data. | |
mbl_data_wrapper< vnl_vector < double > > * | data_ |
An iterator on the data;. | |
vnl_vector< double > | alph_ |
The parameters to be optimised. | |
double | tolerance_ |
Amount by which a sample can violate the KKT conditions. | |
double | eps_ |
Tolerance on several equalities. | |
double | b_ |
Bias. | |
vcl_vector< double > | error_cache_ |
Cache KKT error values for unbound multipliers. | |
vcl_vector< int > | target_ |
Target values y_i. | |
vcl_vector< double > | precomputed_self_dot_product_ |
The norm of each training vector is useful to know quickly. | |
vnl_random | rng_ |
A base class for sequential minimal optimisation.
This finds the optimal point on a quadratic function constrained by inequality bounds on each parameter, and a single equality constraint. The is the class of problems associated with Support Vector Machines
Definition at line 24 of file clsfy_smo_base.h.
clsfy_smo_base::clsfy_smo_base | ( | ) |
Definition at line 127 of file clsfy_smo_base.cxx.
clsfy_smo_base::~clsfy_smo_base | ( | ) | [virtual] |
Definition at line 134 of file clsfy_smo_base.cxx.
double clsfy_smo_base::bias | ( | ) |
Bias term in function evaluation.
For SVMs this would be the value to be subtracted from sum of kernel functions to get 0 as class boundary.
Definition at line 68 of file clsfy_smo_base.cxx.
virtual int clsfy_smo_base::calc | ( | ) | [pure virtual] |
Run the optimisation.
Implemented in clsfy_smo_1_rbf, and clsfy_smo_1_lin.
const vnl_vector< double > & clsfy_smo_base::data_point | ( | unsigned long | l | ) | [protected] |
Access the data points.
Definition at line 29 of file clsfy_smo_base.cxx.
double clsfy_smo_base::eps | ( | ) | const |
tolerance on several equalities.
Tolerance on several equalities.
Including testing if a Lagrange multiplier is at one of the bounds.
Definition at line 109 of file clsfy_smo_base.cxx.
double clsfy_smo_base::error | ( | ) |
error rate on the training data.
Definition at line 21 of file clsfy_smo_base.cxx.
double clsfy_smo_base::error_rate | ( | ) | [virtual] |
Definition at line 141 of file clsfy_smo_base.cxx.
virtual int clsfy_smo_base::examine_example | ( | int | i1 | ) | [protected, pure virtual] |
Attempt to optimise sample i1.
This attempts to find another value i2, in order to jointly optimise both.
Implemented in clsfy_smo_1_lin.
virtual double clsfy_smo_base::kernel | ( | int | i1, |
int | i2 | ||
) | [protected, pure virtual] |
Calculate the kernel for data items i1 and i2;.
Implemented in clsfy_smo_1_rbf, and clsfy_smo_1_lin.
const vnl_vector< double > & clsfy_smo_base::lagrange_mults | ( | ) | const |
Get the optimised parameters.
Definition at line 51 of file clsfy_smo_base.cxx.
double clsfy_smo_base::learned_func | ( | int | k | ) | [protected, virtual] |
Calculate the classifier function learnt so far for data item k.
Definition at line 37 of file clsfy_smo_base.cxx.
void clsfy_smo_base::reseed | ( | unsigned long | seed | ) | [virtual] |
Reseeds the internal random number generator.
To achieve quasi-random initialisation use;
#include <vcl_ctime.h>
..
sampler.reseed(vcl_time(0));
Definition at line 82 of file clsfy_smo_base.cxx.
void clsfy_smo_base::set_eps | ( | double | eps | ) |
Set the tolerance on several equalities.
Including testing if a Lagrange multiplier is at one of the bounds. Default value is 0.001
Including testing if a Lagrange multiplier is at one of the bounds. Default value is 0.001;
Definition at line 119 of file clsfy_smo_base.cxx.
void clsfy_smo_base::set_lagrange_mults | ( | const vnl_vector< double > & | lagrange_mults | ) |
Set the initial values of the parameters to be optimised.
The caller is responsible for ensuring that the initial values fulfill the constraints;
Definition at line 61 of file clsfy_smo_base.cxx.
void clsfy_smo_base::set_tolerance | ( | double | tolerance | ) |
Set the amount by which a sample can violate the KKT conditions.
Default value is 0.001
Definition at line 99 of file clsfy_smo_base.cxx.
virtual int clsfy_smo_base::take_step | ( | int | i1, |
int | i2, | ||
double | E1 | ||
) | [protected, pure virtual] |
Attempt to jointly optimise Lagrange multipliers i1, and i2.
i1 | first Lagrange multiplier. |
i2 | second Lagrange multiplier. |
E1 | The amount by which i1 violates KKT conditions. |
Implemented in clsfy_smo_1_lin.
const double & clsfy_smo_base::tolerance | ( | ) | const |
amount by which a sample can violate the KKT conditions.
Amount by which a sample can violate the KKT conditions.
Definition at line 90 of file clsfy_smo_base.cxx.
vnl_vector<double> clsfy_smo_base::alph_ [protected] |
The parameters to be optimised.
Definition at line 35 of file clsfy_smo_base.h.
double clsfy_smo_base::b_ [protected] |
Bias.
Definition at line 46 of file clsfy_smo_base.h.
mbl_data_wrapper<vnl_vector<double> >* clsfy_smo_base::data_ [protected] |
An iterator on the data;.
Definition at line 32 of file clsfy_smo_base.h.
double clsfy_smo_base::eps_ [protected] |
Tolerance on several equalities.
Including testing if a Lagrange multiplier is at one of the bounds.
Definition at line 42 of file clsfy_smo_base.h.
double clsfy_smo_base::error_ [protected] |
Error rate on the training data.
Definition at line 29 of file clsfy_smo_base.h.
vcl_vector<double> clsfy_smo_base::error_cache_ [protected] |
Cache KKT error values for unbound multipliers.
Definition at line 50 of file clsfy_smo_base.h.
vcl_vector<double> clsfy_smo_base::precomputed_self_dot_product_ [protected] |
The norm of each training vector is useful to know quickly.
Definition at line 56 of file clsfy_smo_base.h.
vnl_random clsfy_smo_base::rng_ [protected] |
Definition at line 58 of file clsfy_smo_base.h.
vcl_vector<int> clsfy_smo_base::target_ [protected] |
Target values y_i.
Definition at line 53 of file clsfy_smo_base.h.
double clsfy_smo_base::tolerance_ [protected] |
Amount by which a sample can violate the KKT conditions.
Definition at line 38 of file clsfy_smo_base.h.