00001 #ifndef _theplu_yat_classifier_target_
00002 #define _theplu_yat_classifier_target_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "yat/utility/deprecate.h"
00029 #include "yat/utility/Exception.h"
00030
00031 #include <iosfwd>
00032 #include <map>
00033 #include <stdexcept>
00034 #include <string>
00035 #include <vector>
00036
00037 namespace theplu {
00038 namespace yat {
00039 namespace utility {
00040 class Index;
00041 }
00042 namespace classifier {
00043
00047 class Target
00048 {
00049
00050 public:
00054 Target(void);
00055
00059 explicit Target(const std::vector<std::string>& labels);
00060
00064 Target(const std::vector<std::string>& labels, const Target&);
00065
00069 Target(std::istream&, char sep='\0')
00070 throw (utility::IO_error,std::exception);
00071
00079 Target(const Target& org, const utility::Index& vec);
00080
00084 ~Target();
00085
00089 const std::map<std::string,size_t>& classes(void) const;
00090
00101 size_t nof_classes(void) const;
00102
00111 bool binary(size_t i) const;
00112
00120 const std::vector<std::string>& labels(void);
00121
00127 void set_binary(size_t i, bool b);
00128
00135 void random_shuffle(void);
00136
00140 size_t size(void) const;
00141
00145 size_t size(const std::string& label) const;
00146
00150 size_t size(size_t cl) const;
00151
00152
00156 size_t operator()(size_t sample) const;
00157
00164 size_t operator[](size_t sample) const YAT_DEPRECATE;
00165
00169 const Target& operator=(const Target&);
00170
00171 private:
00173
00174
00175
00176
00177 std::vector<char> binary_;
00178 std::vector<size_t> classes_;
00179
00180 std::map<std::string,size_t> class_map_;
00181 std::vector<std::string> labels_;
00182
00183 void init(const std::vector<std::string>&);
00184
00185 };
00186
00192 std::ostream& operator<<(std::ostream&, const Target& );
00193
00194 }}}
00195
00196 #endif