SHOGUN  v3.0.0
 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 
124 
125  private:
126  void register_parameters();
127  void init();
128 
136  CDynamicArray<index_t>* get_oob_indices(const SGVector<index_t>& in_bag);
137 
138  void clear_oob_indicies();
139 
140  private:
142  CDynamicObjectArray* m_bags;
143 
145  CFeatures* m_features;
146 
148  CMachine* m_machine;
149 
151  int32_t m_num_bags;
152 
154  int32_t m_bag_size;
155 
157  CCombinationRule* m_combination_rule;
158 
160  SGVector<bool> m_all_oob_idx;
161 
163  CDynamicObjectArray* m_oob_indices;
164  };
165 }
166 
167 #endif /* BAGGINGMACHINE_H */

SHOGUN Machine Learning Toolbox - Documentation