Linear classifier builder using a logit loss function. More...
#include <clsfy_binary_hyperplane_logit_builder.h>
Public Member Functions | |
clsfy_binary_hyperplane_logit_builder () | |
void | set_alpha (double a) |
Weighting on regularisation term. | |
void | set_min_p (double p) |
Min prob to be returned by classifier. | |
double | build (clsfy_classifier_base &classifier, mbl_data_wrapper< vnl_vector< double > > &inputs, const vcl_vector< unsigned > &outputs) const |
Build a linear classifier, with the given data. | |
virtual double | build (clsfy_classifier_base &model, mbl_data_wrapper< vnl_vector< double > > &inputs, unsigned nClasses, const vcl_vector< unsigned > &outputs) const |
Build model from data. | |
short | version_no () const |
Version number for I/O. | |
vcl_string | is_a () const |
Name of the class. | |
virtual bool | is_class (vcl_string const &s) const |
Name of the class. | |
void | print_summary (vcl_ostream &os) const |
Print class to os. | |
virtual clsfy_builder_base * | clone () const |
Create a deep copy. | |
virtual void | b_write (vsl_b_ostream &) const |
Save class to binary file stream. | |
virtual void | b_read (vsl_b_istream &) |
Load class from binary file stream. | |
virtual clsfy_classifier_base * | new_classifier () const |
Create a new untrained linear classifier with binary output. | |
virtual void | config (vcl_istream &as) |
Initialise the parameters from a text stream. | |
Static Public Member Functions | |
static vcl_auto_ptr < clsfy_builder_base > | new_builder (vcl_istream &as) |
Load description from a text stream. | |
Private Attributes | |
double | alpha_ |
Weighting on regularisation term. | |
double | min_p_ |
Min prob to be returned by classifier. |
Linear classifier builder using a logit loss function.
Finds hyperplane and bias to minimise a cost function which minimises the sum of log(pr(error)), ie
alpha*|w|^2 - sum log[(1-minp)logit(c_i * (b+w.x_i)) + minp]
Where c_i is +/-1, x_i is the training vector and minp is a lower bound on output probability. This focuses attention on points near boundary.
Definition at line 27 of file clsfy_binary_hyperplane_logit_builder.h.
clsfy_binary_hyperplane_logit_builder::clsfy_binary_hyperplane_logit_builder | ( | ) |
Definition at line 22 of file clsfy_binary_hyperplane_logit_builder.cxx.
void clsfy_binary_hyperplane_logit_builder::b_read | ( | vsl_b_istream & | bfs | ) | [virtual] |
Load class from binary file stream.
Reimplemented from clsfy_binary_hyperplane_ls_builder.
Definition at line 117 of file clsfy_binary_hyperplane_logit_builder.cxx.
void clsfy_binary_hyperplane_logit_builder::b_write | ( | vsl_b_ostream & | bfs | ) | const [virtual] |
Save class to binary file stream.
Reimplemented from clsfy_binary_hyperplane_ls_builder.
Definition at line 106 of file clsfy_binary_hyperplane_logit_builder.cxx.
double clsfy_binary_hyperplane_logit_builder::build | ( | clsfy_classifier_base & | classifier, |
mbl_data_wrapper< vnl_vector< double > > & | inputs, | ||
const vcl_vector< unsigned > & | outputs | ||
) | const |
Build a linear classifier, with the given data.
Build a linear hyperplane classifier with the given data.
Return the mean error over the training set. Builds by minimising clsfy_logit_loss_function() with given inputs, and a regularisation term using clsfy_quad_regulariser
Reimplemented from clsfy_binary_hyperplane_ls_builder.
Definition at line 55 of file clsfy_binary_hyperplane_logit_builder.cxx.
double clsfy_binary_hyperplane_logit_builder::build | ( | clsfy_classifier_base & | classifier, |
mbl_data_wrapper< vnl_vector< double > > & | inputs, | ||
unsigned | n_classes, | ||
const vcl_vector< unsigned > & | outputs | ||
) | const [virtual] |
Build model from data.
Build a linear classifier, with the given data.
Return the mean error over the training set. For this classifiers, you must nClasses==1 to indicate a binary classifier
Return the mean error over the training set. n_classes must be 1.
Reimplemented from clsfy_binary_hyperplane_ls_builder.
Definition at line 45 of file clsfy_binary_hyperplane_logit_builder.cxx.
clsfy_builder_base * clsfy_binary_hyperplane_logit_builder::clone | ( | ) | const [virtual] |
Create a deep copy.
client is responsible for deleting returned object.
Reimplemented from clsfy_binary_hyperplane_ls_builder.
Definition at line 166 of file clsfy_binary_hyperplane_logit_builder.cxx.
void clsfy_builder_base::config | ( | vcl_istream & | as | ) | [virtual, inherited] |
Initialise the parameters from a text stream.
Default case accepts no parameters.
Reimplemented in clsfy_rbf_svm_smo_1_builder, clsfy_parzen_builder, clsfy_knn_builder, clsfy_null_builder, and clsfy_binary_1d_wrapper_builder.
Definition at line 26 of file clsfy_builder_base.cxx.
vcl_string clsfy_binary_hyperplane_logit_builder::is_a | ( | ) | const [virtual] |
Name of the class.
Reimplemented from clsfy_binary_hyperplane_ls_builder.
Definition at line 139 of file clsfy_binary_hyperplane_logit_builder.cxx.
bool clsfy_binary_hyperplane_logit_builder::is_class | ( | vcl_string const & | s | ) | const [virtual] |
Name of the class.
Reimplemented from clsfy_binary_hyperplane_ls_builder.
Definition at line 146 of file clsfy_binary_hyperplane_logit_builder.cxx.
vcl_auto_ptr< clsfy_builder_base > clsfy_builder_base::new_builder | ( | vcl_istream & | as | ) | [static, inherited] |
Load description from a text stream.
The stream should contain the name of the feature extractor class that will be used, followed by a brace-enclosed list of parameters for the builder. This function will construct the appropriate clsfy_builder_base derivative and return that.
if | the parse fails. |
Definition at line 42 of file clsfy_builder_base.cxx.
virtual clsfy_classifier_base* clsfy_binary_hyperplane_ls_builder::new_classifier | ( | ) | const [inline, virtual, inherited] |
Create a new untrained linear classifier with binary output.
Implements clsfy_builder_base.
Definition at line 23 of file clsfy_binary_hyperplane_ls_builder.h.
void clsfy_binary_hyperplane_logit_builder::print_summary | ( | vcl_ostream & | os | ) | const [virtual] |
Print class to os.
Reimplemented from clsfy_binary_hyperplane_ls_builder.
Definition at line 160 of file clsfy_binary_hyperplane_logit_builder.cxx.
void clsfy_binary_hyperplane_logit_builder::set_alpha | ( | double | a | ) |
Weighting on regularisation term.
Definition at line 27 of file clsfy_binary_hyperplane_logit_builder.cxx.
void clsfy_binary_hyperplane_logit_builder::set_min_p | ( | double | p | ) |
Min prob to be returned by classifier.
Definition at line 33 of file clsfy_binary_hyperplane_logit_builder.cxx.
short clsfy_binary_hyperplane_logit_builder::version_no | ( | ) | const |
Version number for I/O.
Definition at line 153 of file clsfy_binary_hyperplane_logit_builder.cxx.
double clsfy_binary_hyperplane_logit_builder::alpha_ [private] |
Weighting on regularisation term.
Definition at line 31 of file clsfy_binary_hyperplane_logit_builder.h.
double clsfy_binary_hyperplane_logit_builder::min_p_ [private] |
Min prob to be returned by classifier.
Definition at line 34 of file clsfy_binary_hyperplane_logit_builder.h.