Go to the documentation of this file.00001 
00002 #ifndef clsfy_classifier_1d_h_
00003 #define clsfy_classifier_1d_h_
00004 
00005 
00006 
00007 
00008 
00009 #include <vcl_vector.h>
00010 #include <vnl/vnl_vector.h>
00011 #include <mbl/mbl_data_wrapper.h>
00012 #include <vsl/vsl_binary_io.h>
00013 #include <vcl_iostream.h>
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 class clsfy_classifier_1d
00022 {
00023  public:
00024 
00025   
00026   clsfy_classifier_1d();
00027 
00028   
00029   virtual ~clsfy_classifier_1d();
00030   
00031 
00032   
00033   
00034   virtual unsigned classify(double input) const;
00035 
00036   
00037   virtual vnl_vector<double> params() const = 0;
00038 
00039   
00040   virtual void set_params(const vnl_vector<double>& p)=0;
00041 
00042   
00043   
00044   virtual void class_probabilities(vcl_vector<double> &outputs, double input) const = 0;
00045 
00046   
00047   virtual void classify_many(vcl_vector<unsigned> &outputs, mbl_data_wrapper<double> &inputs) const;
00048 
00049   
00050   
00051   
00052   virtual double log_l(double input) const = 0;
00053 
00054   
00055   virtual unsigned  n_classes() const = 0;
00056 
00057   
00058   virtual bool operator==(const clsfy_classifier_1d& x) const = 0;
00059 
00060   
00061   virtual vcl_string is_a() const;
00062 
00063   
00064   virtual bool is_class(vcl_string const& s) const;
00065 
00066   
00067   virtual clsfy_classifier_1d* clone() const = 0;
00068 
00069   
00070   virtual void print_summary(vcl_ostream& os) const = 0;
00071 
00072   
00073   virtual void b_write(vsl_b_ostream& bfs) const = 0;
00074 
00075   
00076   virtual void b_read(vsl_b_istream& bfs) = 0;
00077 };
00078 
00079 
00080 void vsl_add_to_binary_loader(const clsfy_classifier_1d& b);
00081 
00082 
00083 void vsl_b_write(vsl_b_ostream& bfs, const clsfy_classifier_1d& b);
00084 
00085 
00086 void vsl_b_read(vsl_b_istream& bfs, clsfy_classifier_1d& b);
00087 
00088 
00089 vcl_ostream& operator<<(vcl_ostream& os, const clsfy_classifier_1d& b);
00090 
00091 
00092 vcl_ostream& operator<<(vcl_ostream& os, const clsfy_classifier_1d* b);
00093 
00094 
00095 inline void vsl_print_summary(vcl_ostream& os, const clsfy_classifier_1d& b)
00096 { os << b;}
00097 
00098 
00099 inline void vsl_print_summary(vcl_ostream& os, const clsfy_classifier_1d* b)
00100 { os << b;}
00101 
00102 
00103 
00104 
00105 
00106 double clsfy_test_error(const clsfy_classifier_1d &classifier,
00107                         mbl_data_wrapper<double> & test_inputs,
00108                         const vcl_vector<unsigned> & test_outputs);
00109 
00110 #endif // clsfy_classifier_1d_h_