SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ECOCRandomSparseEncoder.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 ECOCRANDOMSPARSEENCODER_H__
12 #define ECOCRANDOMSPARSEENCODER_H__
13 
14 #include <shogun/lib/config.h>
15 
18 
19 namespace shogun
20 {
21 
39 {
40 public:
50  CECOCRandomSparseEncoder(int32_t maxiter=10000, int32_t codelen=0,
51  float64_t pzero=0.5, float64_t pposone=0.25, float64_t pnegone=0.25);
52 
55 
61  void set_probability(float64_t pzero, float64_t pposone, float64_t pnegone);
62 
64  virtual const char* get_name() const { return "ECOCRandomSparseEncoder"; }
65 
75  int32_t get_default_code_length(int32_t num_classes) const
76  {
77  return static_cast<int32_t>(CMath::round(15 * CMath::log(num_classes)));
78  }
79 
83  virtual SGMatrix<int32_t> create_codebook(int32_t num_classes);
84 
85 protected:
87  int32_t m_maxiter;
89  int32_t m_codelen;
96 
97 private:
103  bool check_probability(float64_t pzero, float64_t pposone, float64_t pnegone)
104  {
105  if (CMath::abs(pzero + pposone + pnegone - 1) > 1e-5)
106  return false;
107  return true;
108  }
109 
111  void init();
112 };
113 
114 } /* shogun */
115 
116 #endif /* end of include guard: ECOCRANDOMSPARSEENCODER_H__ */
117 

SHOGUN Machine Learning Toolbox - Documentation