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 #include "yat/utility/deprecate.h"
00028 #include "yat/utility/Exception.h"
00029
00030 #include <iosfwd>
00031 #include <map>
00032 #include <stdexcept>
00033 #include <string>
00034 #include <vector>
00035
00036 namespace theplu {
00037 namespace yat {
00038 namespace utility {
00039 class Index;
00040 }
00041 namespace classifier {
00042
00046 class Target
00047 {
00048
00049 public:
00053 Target(void);
00054
00058 explicit Target(const std::vector<std::string>& labels);
00059
00063 Target(const std::vector<std::string>& labels, const Target&);
00064
00068 Target(std::istream&, char sep='\0')
00069 throw (utility::IO_error,std::exception);
00070
00078 Target(const Target& org, const utility::Index& vec);
00079
00083 ~Target();
00084
00088 const std::map<std::string,size_t>& classes(void) const;
00089
00100 size_t nof_classes(void) const;
00101
00110 bool binary(size_t i) const;
00111
00119 const std::vector<std::string>& labels(void);
00120
00126 void set_binary(size_t i, bool b);
00127
00134 void random_shuffle(void);
00135
00139 size_t size(void) const;
00140
00144 size_t size(const std::string& label) const;
00145
00149 size_t size(size_t cl) const;
00150
00151
00155 size_t operator()(size_t sample) const;
00156
00163 size_t operator[](size_t sample) const YAT_DEPRECATE;
00164
00168 const Target& operator=(const Target&);
00169
00170 private:
00172
00173
00174
00175
00176 std::vector<char> binary_;
00177 std::vector<size_t> classes_;
00178
00179 std::map<std::string,size_t> class_map_;
00180 std::vector<std::string> labels_;
00181
00182 void init(const std::vector<std::string>&);
00183
00184 };
00185
00189 std::ostream& operator<<(std::ostream&, const Target& );
00190
00191 }}}
00192
00193 #endif