contrib/mul/clsfy/clsfy_binary_hyperplane_ls_builder.h
Go to the documentation of this file.
00001 // This is mul/clsfy/clsfy_binary_hyperplane_ls_builder.h
00002 // Copyright: (C) 2000 British Telecommunications PLC
00003 #ifndef clsfy_binary_hyperplane_ls_builder_h_
00004 #define clsfy_binary_hyperplane_ls_builder_h_
00005 //:
00006 // \file
00007 // \brief Describe a binary linear classifier builder
00008 // \author Ian Scott
00009 // \date 2000-05-26
00010 
00011 #include <clsfy/clsfy_binary_hyperplane.h>
00012 #include <clsfy/clsfy_builder_base.h>
00013 #include <vcl_iosfwd.h>
00014 
00015 //: Build a binary linear classifier using least squares
00016 class clsfy_binary_hyperplane_ls_builder : public clsfy_builder_base
00017 {
00018  public:
00019   // Dflt ctor
00020   clsfy_binary_hyperplane_ls_builder() {}
00021 
00022   //: Create a new untrained linear classifier with binary output
00023   virtual clsfy_classifier_base* new_classifier() const
00024   { return new clsfy_binary_hyperplane; }
00025 
00026   //: Build a linear classifier, with the given data.
00027   // Return the mean error over the training set.
00028   double build(clsfy_classifier_base &classifier,
00029                mbl_data_wrapper<vnl_vector<double> > &inputs,
00030                const vcl_vector<unsigned> &outputs) const;
00031 
00032   //: Build a linear classifier, with the given data.
00033   // Return the mean error over the training set.
00034   // n_classes must be 1
00035   double build(clsfy_classifier_base &classifier,
00036                mbl_data_wrapper<vnl_vector<double> > &inputs,
00037                unsigned n_classes, const vcl_vector<unsigned> &outputs) const;
00038 
00039   //: Name of the class
00040   vcl_string is_a() const;
00041 
00042   //: Name of the class
00043   virtual bool is_class(vcl_string const& s) const;
00044 
00045   //: Print class to os
00046   void print_summary(vcl_ostream& os) const;
00047 
00048   //: Create a deep copy.
00049   // client is responsible for deleting returned object.
00050   virtual clsfy_builder_base* clone() const
00051   { return new clsfy_binary_hyperplane_ls_builder(*this); }
00052 
00053   virtual void b_write(vsl_b_ostream &) const;
00054   virtual void b_read(vsl_b_istream &);
00055 };
00056 
00057 #endif // clsfy_binary_hyperplane_ls_builder_h_