SHOGUN  v3.2.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义 
BaggingMachine.h
浏览该文件的文档.
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 */
EMachineType
Definition: Machine.h:33
virtual CRegressionLabels * apply_regression(CFeatures *data=NULL)
void set_combination_rule(CCombinationRule *rule)
Real Labels are real-valued labels.
CCombinationRule * get_combination_rule() const
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:35
virtual bool train_machine(CFeatures *data=NULL)
int32_t get_bag_size() const
virtual EMachineType get_classifier_type()
int32_t get_num_bags() const
SGVector< float64_t > apply_get_outputs(CFeatures *data)
Template Dynamic array class that creates an array that can be used like a list or an array...
Definition: DynArray.h:20
virtual CMulticlassLabels * apply_multiclass(CFeatures *data=NULL)
A generic learning machine interface.
Definition: Machine.h:138
CMachine * get_machine() const
Multiclass Labels for multi-class classification.
virtual const char * get_name() const
void set_machine(CMachine *machine)
double float64_t
Definition: common.h:48
Dynamic array class for CSGObject pointers that creates an array that can be used like a list or an a...
void set_num_bags(int32_t num_bags)
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:16
The class Features is the base class of all feature objects.
Definition: Features.h:62
CombinationRule abstract class The CombinationRule defines an interface to how to combine the classif...
Binary Labels for binary classification.
Definition: BinaryLabels.h:36
: Bagging algorithm i.e. bootstrap aggregating
virtual CBinaryLabels * apply_binary(CFeatures *data=NULL)
float64_t get_oob_error(CEvaluation *eval) const
Class Evaluation, a base class for other classes used to evaluate labels, e.g. accuracy of classifica...
Definition: Evaluation.h:35
void set_bag_size(int32_t bag_size)

SHOGUN Machine Learning Toolbox - Documentation