Computes log prob based on output of a linear classifier. More...
#include <mfpf_log_lin_class_cost.h>
Public Member Functions | |
mfpf_log_lin_class_cost () | |
Dflt ctor. | |
virtual | ~mfpf_log_lin_class_cost () |
Destructor. | |
void | set (const vnl_vector< double > &wts, double bias, double min_p=1e-6) |
Define weights, bias and minp. | |
const vnl_vector< double > & | wts () const |
Weights to apply to each element in sum. | |
virtual double | evaluate (const vnl_vector< double > &x) |
Returns -log(minp + (1-minp)/(1+exp(-(x.wts-bias))). | |
virtual void | get_average (vnl_vector< double > &v) const |
Return the weights. | |
short | version_no () const |
Version number for I/O. | |
virtual vcl_string | is_a () const |
Name of the class. | |
virtual mfpf_vec_cost * | clone () const |
Create a copy on the heap and return base class pointer. | |
virtual void | print_summary (vcl_ostream &os) const |
Print class to os. | |
virtual void | b_write (vsl_b_ostream &bfs) const |
Save class to binary file stream. | |
virtual void | b_read (vsl_b_istream &bfs) |
Load class from binary file stream. | |
Private Attributes | |
vnl_vector< double > | wts_ |
Classifier weights. | |
double | bias_ |
Classifier bias. | |
double | min_p_ |
Minimum probability allowed in response. |
Computes log prob based on output of a linear classifier.
Linear classifier gives output z = w.x - bias This returns -log(minp + (1-minp)/(1+exp(-z))) minp defines the minimum prob output by classifier, which should be non-zero to avoid danger of log(0)
Definition at line 16 of file mfpf_log_lin_class_cost.h.
mfpf_log_lin_class_cost::mfpf_log_lin_class_cost | ( | ) |
Dflt ctor.
Definition at line 16 of file mfpf_log_lin_class_cost.cxx.
mfpf_log_lin_class_cost::~mfpf_log_lin_class_cost | ( | ) | [virtual] |
Destructor.
Definition at line 24 of file mfpf_log_lin_class_cost.cxx.
void mfpf_log_lin_class_cost::b_read | ( | vsl_b_istream & | bfs | ) | [virtual] |
Load class from binary file stream.
Implements mfpf_vec_cost.
Definition at line 100 of file mfpf_log_lin_class_cost.cxx.
void mfpf_log_lin_class_cost::b_write | ( | vsl_b_ostream & | bfs | ) | const [virtual] |
Save class to binary file stream.
Implements mfpf_vec_cost.
Definition at line 88 of file mfpf_log_lin_class_cost.cxx.
mfpf_vec_cost * mfpf_log_lin_class_cost::clone | ( | ) | const [virtual] |
Create a copy on the heap and return base class pointer.
Implements mfpf_vec_cost.
Definition at line 70 of file mfpf_log_lin_class_cost.cxx.
double mfpf_log_lin_class_cost::evaluate | ( | const vnl_vector< double > & | x | ) | [virtual] |
Returns -log(minp + (1-minp)/(1+exp(-(x.wts-bias))).
Returns -1*log(minp + (1-minp)/(1+exp(-(x.wts-bias))).
Implements mfpf_vec_cost.
Definition at line 38 of file mfpf_log_lin_class_cost.cxx.
void mfpf_log_lin_class_cost::get_average | ( | vnl_vector< double > & | v | ) | const [virtual] |
Return the weights.
Implements mfpf_vec_cost.
Definition at line 45 of file mfpf_log_lin_class_cost.cxx.
vcl_string mfpf_log_lin_class_cost::is_a | ( | ) | const [virtual] |
Name of the class.
Reimplemented from mfpf_vec_cost.
Definition at line 64 of file mfpf_log_lin_class_cost.cxx.
void mfpf_log_lin_class_cost::print_summary | ( | vcl_ostream & | os | ) | const [virtual] |
Print class to os.
Implements mfpf_vec_cost.
Definition at line 79 of file mfpf_log_lin_class_cost.cxx.
void mfpf_log_lin_class_cost::set | ( | const vnl_vector< double > & | wts, |
double | bias, | ||
double | min_p = 1e-6 |
||
) |
Define weights, bias and minp.
Definition at line 29 of file mfpf_log_lin_class_cost.cxx.
short mfpf_log_lin_class_cost::version_no | ( | ) | const |
Version number for I/O.
Reimplemented from mfpf_vec_cost.
Definition at line 55 of file mfpf_log_lin_class_cost.cxx.
const vnl_vector<double>& mfpf_log_lin_class_cost::wts | ( | ) | const [inline] |
Weights to apply to each element in sum.
Definition at line 39 of file mfpf_log_lin_class_cost.h.
double mfpf_log_lin_class_cost::bias_ [private] |
Classifier bias.
Definition at line 23 of file mfpf_log_lin_class_cost.h.
double mfpf_log_lin_class_cost::min_p_ [private] |
Minimum probability allowed in response.
Definition at line 26 of file mfpf_log_lin_class_cost.h.
vnl_vector<double> mfpf_log_lin_class_cost::wts_ [private] |
Classifier weights.
Definition at line 20 of file mfpf_log_lin_class_cost.h.