00001 // This is mul/clsfy/clsfy_null_classifier.h 00002 #ifndef clsfy_null_classifier_h_ 00003 #define clsfy_null_classifier_h_ 00004 // Copyright: (C) 2001 British Telecommunications plc 00005 #ifdef VCL_NEEDS_PRAGMA_INTERFACE 00006 #pragma interface 00007 #endif 00008 //: 00009 // \file 00010 // \brief Describe a null classifier 00011 // \author Ian Scott 00012 // \date 2009-08-25 00013 00014 #include "clsfy_classifier_base.h" 00015 #include <vsl/vsl_fwd.h> 00016 #include <vnl/vnl_fwd.h> 00017 #include <vcl_iosfwd.h> 00018 00019 //: A classifier that always returns the same answer. 00020 class clsfy_null_classifier : public clsfy_classifier_base 00021 { 00022 public: 00023 // Dflt constructor 00024 clsfy_null_classifier(): n_dims_(0u), default_class_(0u) {} 00025 00026 //: Constructor for when you need a different default 00027 clsfy_null_classifier(unsigned dc): n_dims_(0u), default_class_(dc) {} 00028 00029 //: Return the probability the input being in each class. 00030 virtual void class_probabilities(vcl_vector<double> &outputs, const vnl_vector<double> &input) const; 00031 00032 //: Log likelihood of being in class 00033 virtual double log_l(const vnl_vector<double> &input) const; 00034 00035 //: The number of possible output classes. 00036 virtual unsigned n_classes() const; 00037 00038 //: The dimensionality of input vectors. 00039 virtual unsigned n_dims() const 00040 { return n_dims_; } 00041 00042 //: Set the number of dimensions the classifier reports that it uses. 00043 // The classifier itself pays no attention to this value, but it 00044 // may be useful for other error checking code which calls n_dims() 00045 void set_n_dims(unsigned n) 00046 { n_dims_ = n; } 00047 00048 //: The classification result that is always returned. 00049 unsigned default_class() const 00050 { return default_class_; } 00051 00052 //: Set the number of dimensions the classifier reports that it uses. 00053 // The classifier itself pays no attention to this value, but it 00054 // may be useful for other error checking code which calls n_dims() 00055 void set_default_class(unsigned dc) 00056 { default_class_ = dc; } 00057 00058 //: Name of the class 00059 virtual vcl_string is_a() const; 00060 00061 //: Name of the class 00062 virtual bool is_class(vcl_string const& s) const; 00063 00064 //: Create a copy on the heap and return base class pointer 00065 virtual clsfy_classifier_base* clone() const; 00066 00067 //: Print class to os 00068 virtual void print_summary(vcl_ostream& os) const; 00069 00070 //: Save class to binary file stream 00071 virtual void b_write(vsl_b_ostream& bfs) const; 00072 00073 //: Load class from binary file stream 00074 virtual void b_read(vsl_b_istream& bfs); 00075 00076 //: The probabilities of returning a value in each class. 00077 const vcl_vector<double> & probs() const; 00078 00079 //: Set the prior probabilities of each class 00080 // The values are normalised to sum to 1. 00081 void set_probs(const vcl_vector<double> &); 00082 00083 00084 private: 00085 00086 //: The classifier may get asked this 00087 unsigned n_dims_; 00088 00089 //: The class value that is always returned, whatever the input vector. 00090 unsigned default_class_; 00091 }; 00092 00093 #endif // clsfy_null_classifier_h_