SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BaggingMachine.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) 2013 Viktor Gal
8  * Copyright (C) 2013 Viktor Gal
9  */
10 
11 #ifndef BAGGINGMACHINE_H
12 #define BAGGINGMACHINE_H
13 
14 #include <shogun/machine/Machine.h>
17 
18 namespace shogun
19 {
24  class CBaggingMachine : public CMachine
25  {
26  public:
29 
36  CBaggingMachine(CFeatures* features, CLabels* labels);
37 
38  virtual ~CBaggingMachine();
39 
40  virtual CBinaryLabels* apply_binary(CFeatures* data=NULL);
41  virtual CMulticlassLabels* apply_multiclass(CFeatures* data=NULL);
42  virtual CRegressionLabels* apply_regression(CFeatures* data=NULL);
43 
49  void set_num_bags(int32_t num_bags);
50 
56  int32_t get_num_bags() const;
57 
64  void set_bag_size(int32_t bag_size);
65 
72  int32_t get_bag_size() const;
73 
79  CMachine* get_machine() const;
80 
86  void set_machine(CMachine* machine);
87 
95 
102 
108 
115  float64_t get_oob_error(CEvaluation* eval) const;
116 
118  virtual const char* get_name() const { return "BaggingMachine"; }
119 
120  protected:
121  virtual bool train_machine(CFeatures* data=NULL);
122 
130 
131  private:
132  void register_parameters();
133  void init();
134 
142  CDynamicArray<index_t>* get_oob_indices(const SGVector<index_t>& in_bag);
143 
144  void clear_oob_indicies();
145 
146  private:
148  CDynamicObjectArray* m_bags;
149 
151  CFeatures* m_features;
152 
154  CMachine* m_machine;
155 
157  int32_t m_num_bags;
158 
160  int32_t m_bag_size;
161 
163  CCombinationRule* m_combination_rule;
164 
166  SGVector<bool> m_all_oob_idx;
167 
169  CDynamicObjectArray* m_oob_indices;
170  };
171 }
172 
173 #endif /* BAGGINGMACHINE_H */

SHOGUN Machine Learning Toolbox - Documentation