Classifier using adaboost on combinations of simple 1D classifiers. More...
#include <clsfy_simple_adaboost.h>
Public Member Functions | |
clsfy_simple_adaboost () | |
Default constructor. | |
clsfy_simple_adaboost (const clsfy_simple_adaboost &) | |
Copy constructor. | |
clsfy_simple_adaboost & | operator= (const clsfy_simple_adaboost &) |
Copy operator. | |
~clsfy_simple_adaboost () | |
Destructor. | |
bool | operator== (const clsfy_simple_adaboost &x) const |
Comparison. | |
void | clear () |
Clear all alphas and classifiers. | |
void | add_classifier (clsfy_classifier_1d *c1d, double alpha, int index) |
Add classifier and alpha value. | |
void | set_n_clfrs_used (unsigned int x) |
Set number of classifiers used (when applying strong classifier). | |
int | n_clfrs_used () const |
Access. | |
virtual void | class_probabilities (vcl_vector< double > &outputs, const vnl_vector< double > &input) const |
Find the posterior probability of the input being in the positive class. | |
virtual unsigned | classify (const vnl_vector< double > &input) const |
Classify the input vector. | |
virtual double | log_l (const vnl_vector< double > &input) const |
Log likelihood of being in the positive class. | |
virtual unsigned | n_dims () const |
The dimensionality of input vectors. | |
void | set_n_dims (unsigned x) |
Set number of classifiers used (when applying strong classifier). | |
virtual unsigned | n_classes () const |
The number of possible output classes. | |
void | set_parameters (const vcl_vector< clsfy_classifier_1d * > &classifier, const vcl_vector< double > &alphas, const vcl_vector< int > &index) |
Set parameters. Clones taken of *classifier[i]. | |
const vcl_vector < clsfy_classifier_1d * > & | classifiers () const |
Access functions. | |
const vcl_vector< double > & | alphas () const |
const vcl_vector< int > & | index () const |
short | version_no () const |
Version number for I/O. | |
virtual vcl_string | is_a () const |
Name of the class. | |
virtual bool | is_class (vcl_string const &s) const |
Name of the class. | |
virtual void | print_summary (vcl_ostream &os) const |
Print class to os. | |
virtual void | b_write (vsl_b_ostream &bfs) const |
Save class to a binary File Stream. | |
virtual clsfy_classifier_base * | clone () const |
Create a deep copy. | |
virtual void | b_read (vsl_b_istream &bfs) |
Load the class from a Binary File Stream. | |
virtual void | classify_many (vcl_vector< unsigned > &outputs, mbl_data_wrapper< vnl_vector< double > > &inputs) const |
Classify many input vectors. | |
Protected Member Functions | |
void | delete_stuff () |
Delete objects on heap. | |
Protected Attributes | |
vcl_vector< clsfy_classifier_1d * > | classifier_1d_ |
The classifiers in order. | |
vcl_vector< double > | alphas_ |
Coefficients applied to each classifier. | |
vcl_vector< int > | index_ |
Index of input vector appropriate for each classifier. | |
int | n_clfrs_used_ |
number of classifiers used. | |
int | n_dims_ |
dimensionality of data. |
Classifier using adaboost on combinations of simple 1D classifiers.
Uses a weighted combination of 1D classifiers applied to the elements of the input vector.
Definition at line 17 of file clsfy_simple_adaboost.h.
clsfy_simple_adaboost::clsfy_simple_adaboost | ( | ) |
Default constructor.
Definition at line 22 of file clsfy_simple_adaboost.cxx.
clsfy_simple_adaboost::clsfy_simple_adaboost | ( | const clsfy_simple_adaboost & | c | ) |
Copy constructor.
Definition at line 27 of file clsfy_simple_adaboost.cxx.
clsfy_simple_adaboost::~clsfy_simple_adaboost | ( | ) |
Destructor.
Definition at line 62 of file clsfy_simple_adaboost.cxx.
void clsfy_simple_adaboost::add_classifier | ( | clsfy_classifier_1d * | c1d, |
double | alpha, | ||
int | index | ||
) |
Add classifier and alpha value.
Add weak classifier and alpha value.
nb also changes n_clfrs_used to use all current weak classifiers
Definition at line 108 of file clsfy_simple_adaboost.cxx.
const vcl_vector<double>& clsfy_simple_adaboost::alphas | ( | ) | const [inline] |
Definition at line 102 of file clsfy_simple_adaboost.h.
void clsfy_simple_adaboost::b_read | ( | vsl_b_istream & | bfs | ) | [virtual] |
Load the class from a Binary File Stream.
Implements clsfy_classifier_base.
Definition at line 222 of file clsfy_simple_adaboost.cxx.
void clsfy_simple_adaboost::b_write | ( | vsl_b_ostream & | bfs | ) | const [virtual] |
Save class to a binary File Stream.
Implements clsfy_classifier_base.
Definition at line 212 of file clsfy_simple_adaboost.cxx.
void clsfy_simple_adaboost::class_probabilities | ( | vcl_vector< double > & | outputs, |
const vnl_vector< double > & | input | ||
) | const [virtual] |
Find the posterior probability of the input being in the positive class.
The result is outputs(0)
Implements clsfy_classifier_base.
Definition at line 147 of file clsfy_simple_adaboost.cxx.
const vcl_vector<clsfy_classifier_1d*>& clsfy_simple_adaboost::classifiers | ( | ) | const [inline] |
Access functions.
Definition at line 99 of file clsfy_simple_adaboost.h.
unsigned clsfy_simple_adaboost::classify | ( | const vnl_vector< double > & | v | ) | const [virtual] |
Classify the input vector.
Returns a number between 0 and nClasses-1 inclusive to represent the most likely class
Returns either 1 (for positive class) or 0 (for negative class)
Reimplemented from clsfy_classifier_base.
Definition at line 121 of file clsfy_simple_adaboost.cxx.
void clsfy_classifier_base::classify_many | ( | vcl_vector< unsigned > & | outputs, |
mbl_data_wrapper< vnl_vector< double > > & | inputs | ||
) | const [virtual, inherited] |
Classify many input vectors.
Definition at line 55 of file clsfy_classifier_base.cxx.
void clsfy_simple_adaboost::clear | ( | ) |
Clear all alphas and classifiers.
Definition at line 100 of file clsfy_simple_adaboost.cxx.
virtual clsfy_classifier_base* clsfy_simple_adaboost::clone | ( | ) | const [inline, virtual] |
Create a deep copy.
Client is responsible for deleting returned object.
Implements clsfy_classifier_base.
Definition at line 125 of file clsfy_simple_adaboost.h.
void clsfy_simple_adaboost::delete_stuff | ( | ) | [protected] |
Delete objects on heap.
Definition at line 49 of file clsfy_simple_adaboost.cxx.
const vcl_vector<int>& clsfy_simple_adaboost::index | ( | ) | const [inline] |
Definition at line 105 of file clsfy_simple_adaboost.h.
vcl_string clsfy_simple_adaboost::is_a | ( | ) | const [virtual] |
Name of the class.
Reimplemented from clsfy_classifier_base.
Definition at line 176 of file clsfy_simple_adaboost.cxx.
bool clsfy_simple_adaboost::is_class | ( | vcl_string const & | s | ) | const [virtual] |
Name of the class.
Reimplemented from clsfy_classifier_base.
Definition at line 183 of file clsfy_simple_adaboost.cxx.
double clsfy_simple_adaboost::log_l | ( | const vnl_vector< double > & | v | ) | const [virtual] |
Log likelihood of being in the positive class.
Class probability = 1 / (1+exp(-log_l))
Implements clsfy_classifier_base.
Definition at line 158 of file clsfy_simple_adaboost.cxx.
virtual unsigned clsfy_simple_adaboost::n_classes | ( | ) | const [inline, virtual] |
The number of possible output classes.
1 indicates a binary classifier
Implements clsfy_classifier_base.
Definition at line 91 of file clsfy_simple_adaboost.h.
int clsfy_simple_adaboost::n_clfrs_used | ( | ) | const [inline] |
Access.
Definition at line 69 of file clsfy_simple_adaboost.h.
virtual unsigned clsfy_simple_adaboost::n_dims | ( | ) | const [inline, virtual] |
The dimensionality of input vectors.
Implements clsfy_classifier_base.
Definition at line 84 of file clsfy_simple_adaboost.h.
clsfy_simple_adaboost & clsfy_simple_adaboost::operator= | ( | const clsfy_simple_adaboost & | c | ) |
Copy operator.
Definition at line 34 of file clsfy_simple_adaboost.cxx.
bool clsfy_simple_adaboost::operator== | ( | const clsfy_simple_adaboost & | x | ) | const |
Comparison.
Definition at line 69 of file clsfy_simple_adaboost.cxx.
void clsfy_simple_adaboost::print_summary | ( | vcl_ostream & | os | ) | const [virtual] |
Print class to os.
Implements clsfy_classifier_base.
Definition at line 191 of file clsfy_simple_adaboost.cxx.
void clsfy_simple_adaboost::set_n_clfrs_used | ( | unsigned int | x | ) | [inline] |
Set number of classifiers used (when applying strong classifier).
Definition at line 66 of file clsfy_simple_adaboost.h.
void clsfy_simple_adaboost::set_n_dims | ( | unsigned | x | ) | [inline] |
Set number of classifiers used (when applying strong classifier).
Definition at line 87 of file clsfy_simple_adaboost.h.
void clsfy_simple_adaboost::set_parameters | ( | const vcl_vector< clsfy_classifier_1d * > & | classifier, |
const vcl_vector< double > & | alphas, | ||
const vcl_vector< int > & | index | ||
) |
Set parameters. Clones taken of *classifier[i].
Definition at line 82 of file clsfy_simple_adaboost.cxx.
short clsfy_simple_adaboost::version_no | ( | ) | const |
Version number for I/O.
Definition at line 205 of file clsfy_simple_adaboost.cxx.
vcl_vector<double> clsfy_simple_adaboost::alphas_ [protected] |
Coefficients applied to each classifier.
Definition at line 25 of file clsfy_simple_adaboost.h.
vcl_vector<clsfy_classifier_1d*> clsfy_simple_adaboost::classifier_1d_ [protected] |
The classifiers in order.
Definition at line 22 of file clsfy_simple_adaboost.h.
vcl_vector<int> clsfy_simple_adaboost::index_ [protected] |
Index of input vector appropriate for each classifier.
Definition at line 28 of file clsfy_simple_adaboost.h.
int clsfy_simple_adaboost::n_clfrs_used_ [protected] |
number of classifiers used.
Definition at line 31 of file clsfy_simple_adaboost.h.
int clsfy_simple_adaboost::n_dims_ [protected] |
dimensionality of data.
(i.e. size of input vectors v, ie the total number of different features)
Definition at line 35 of file clsfy_simple_adaboost.h.