SHOGUN  v2.0.0
 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 
19 #include <shogun/labels/Labels.h>
20 
21 namespace shogun
22 {
23 
34 {
35 public:
38 
40  virtual ~CECOCDiscriminantEncoder();
41 
44 
46  void set_labels(CLabels *labels);
47 
51  void set_sffs_iterations(int32_t iterations) { m_iterations = iterations; }
52 
55  int32_t get_sffs_iterations() const { return m_iterations; }
56 
58  virtual const char* get_name() const { return "ECOCDiscriminantEncoder"; }
59 
63  virtual SGMatrix<int32_t> create_codebook(int32_t num_classes);
64 
65 protected:
67  void init();
68 
69 #ifndef DOXYGEN_SHOULD_SKIP_THIS
70  void binary_partition(const std::vector<int32_t>& classes);
71  void run_sffs(std::vector<int32_t>& part1, std::vector<int32_t>& part2);
72  float64_t sffs_iteration(float64_t MI, std::vector<int32_t>& part1, std::set<int32_t>& idata1,
73  std::vector<int32_t>& part2, std::set<int32_t>& idata2);
74  float64_t compute_MI(const std::set<int32_t>& idata1, const std::set<int32_t>& idata2);
75  void compute_hist(int32_t i, float64_t max_val, float64_t min_val,
76  const std::set<int32_t>& idata, int32_t *hist);
77 
78  int32_t m_iterations;
79  int32_t m_num_trees;
80 
81  SGMatrix<int32_t> m_codebook;
82  int32_t m_code_idx;
83  CLabels *m_labels;
84  CDenseFeatures<float64_t> *m_features;
85  SGMatrix<float64_t> m_feats;
86 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
87 };
88 
89 } /* shogun */
90 
91 #endif /* end of include guard: ECOCDISCRIMINANTENCODER_H__ */
92 

SHOGUN Machine Learning Toolbox - Documentation