SHOGUN  5.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
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/lib/config.h>
15 
16 #include <shogun/machine/Machine.h>
17 
18 namespace shogun
19 {
20  class CCombinationRule;
21  class CEvaluation;
22 
27  class CBaggingMachine : public CMachine
28  {
29  public:
32 
39  CBaggingMachine(CFeatures* features, CLabels* labels);
40 
41  virtual ~CBaggingMachine();
42 
43  virtual CBinaryLabels* apply_binary(CFeatures* data=NULL);
44  virtual CMulticlassLabels* apply_multiclass(CFeatures* data=NULL);
45  virtual CRegressionLabels* apply_regression(CFeatures* data=NULL);
46 
52  void set_num_bags(int32_t num_bags);
53 
59  int32_t get_num_bags() const;
60 
67  virtual void set_bag_size(int32_t bag_size);
68 
75  virtual int32_t get_bag_size() const;
76 
82  CMachine* get_machine() const;
83 
89  virtual void set_machine(CMachine* machine);
90 
98 
105 
111 
118  float64_t get_oob_error(CEvaluation* eval) const;
119 
121  virtual const char* get_name() const { return "BaggingMachine"; }
122 
123  protected:
124  virtual bool train_machine(CFeatures* data=NULL);
125 
132  virtual void set_machine_parameters(CMachine* m, SGVector<index_t> idx);
133 
141 
143  void register_parameters();
144 
146  void init();
147 
156 
157  protected:
160 
163 
166 
168  int32_t m_num_bags;
169 
171  int32_t m_bag_size;
172 
175 
178 
181  };
182 }
183 
184 #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 * m_combination_rule
CCombinationRule * get_combination_rule() const
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:43
virtual bool train_machine(CFeatures *data=NULL)
virtual void set_machine_parameters(CMachine *m, SGVector< index_t > idx)
virtual int32_t get_bag_size() const
virtual EMachineType get_classifier_type()
int32_t get_num_bags() const
CDynamicArray< index_t > * get_oob_indices(const SGVector< index_t > &in_bag)
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:22
virtual CMulticlassLabels * apply_multiclass(CFeatures *data=NULL)
A generic learning machine interface.
Definition: Machine.h:143
SGVector< bool > m_all_oob_idx
CMachine * get_machine() const
Multiclass Labels for multi-class classification.
virtual const char * get_name() const
virtual void set_machine(CMachine *machine)
double float64_t
Definition: common.h:50
CDynamicObjectArray * m_bags
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)
CDynamicObjectArray * m_oob_indices
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
The class Features is the base class of all feature objects.
Definition: Features.h:68
CombinationRule abstract class The CombinationRule defines an interface to how to combine the classif...
Binary Labels for binary classification.
Definition: BinaryLabels.h:37
: 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:40
virtual void set_bag_size(int32_t bag_size)

SHOGUN Machine Learning Toolbox - Documentation