SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ECOCDiscriminantEncoder.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2012 Chiyuan Zhang
8  * Copyright (C) 2012 Chiyuan Zhang
9  */
10 
11 #ifndef ECOCDISCRIMINANTENCODER_H__
12 #define ECOCDISCRIMINANTENCODER_H__
13 
14 #include <vector>
15 #include <set>
16 
17 #include <shogun/lib/config.h>
18 
21 #include <shogun/labels/Labels.h>
22 
23 namespace shogun
24 {
25 
36 {
37 public:
40 
42  virtual ~CECOCDiscriminantEncoder();
43 
46 
48  void set_labels(CLabels *labels);
49 
53  void set_sffs_iterations(int32_t iterations) { m_iterations = iterations; }
54 
57  int32_t get_sffs_iterations() const { return m_iterations; }
58 
60  virtual const char* get_name() const { return "ECOCDiscriminantEncoder"; }
61 
65  virtual SGMatrix<int32_t> create_codebook(int32_t num_classes);
66 
67 protected:
69  void init();
70 
71 #ifndef DOXYGEN_SHOULD_SKIP_THIS
72  void binary_partition(const std::vector<int32_t>& classes);
73  void run_sffs(std::vector<int32_t>& part1, std::vector<int32_t>& part2);
74  float64_t sffs_iteration(float64_t MI, std::vector<int32_t>& part1, std::set<int32_t>& idata1,
75  std::vector<int32_t>& part2, std::set<int32_t>& idata2);
76  float64_t compute_MI(const std::set<int32_t>& idata1, const std::set<int32_t>& idata2);
77  void compute_hist(int32_t i, float64_t max_val, float64_t min_val,
78  const std::set<int32_t>& idata, int32_t *hist);
79 
80  int32_t m_iterations;
81  int32_t m_num_trees;
82 
83  SGMatrix<int32_t> m_codebook;
84  int32_t m_code_idx;
85  CLabels *m_labels;
86  CDenseFeatures<float64_t> *m_features;
87  SGMatrix<float64_t> m_feats;
88 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
89 };
90 
91 } /* shogun */
92 
93 #endif /* end of include guard: ECOCDISCRIMINANTENCODER_H__ */
94 

SHOGUN Machine Learning Toolbox - Documentation