-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
BaggingMachine.h
113 lines (92 loc) · 2.39 KB
/
BaggingMachine.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 2013 Viktor Gal
* Copyright (C) 2013 Viktor Gal
*/
#ifndef BAGGINGMACHINE_H
#define BAGGINGMACHINE_H
#include <shogun/machine/Machine.h>
namespace shogun
{
/**
* @brief: Bagging algorithm
* i.e. bootstrap aggregating
*/
class CBaggingMachine : public CMachine
{
public:
/** default ctor */
CBaggingMachine();
/**
* constructor
*
* @param features training features
* @param labals training labels
*/
CBaggingMachine(CFeatures* features, CLabels* labels);
virtual ~CBaggingMachine();
virtual CLabels* apply(CFeatures* data=NULL);
virtual CRegressionLabels* apply_regression(CFeatures* data=NULL);
/**
* Set number of bags/machine to create
*
* @param num_bags number of bags
*/
void set_num_bags(int32_t num_bags);
/**
* Get number of bags/machines
*
* @return number of bags
*/
int32_t get_num_bags() const;
/**
* Set number of feature vectors to use
* for each bag/machine
*
* @param bag_size number of vectors to use for a bag
*/
void set_bag_size(int32_t bag_size);
/**
* Get number of feature vectors that are use
* for training each bag/machine
*
* @return number of vectors used for training for each bag.
*/
int32_t get_bag_size() const;
/**
* Get machine for bagging
*
* @return machine that is being used in bagging
*/
CMachine* get_machine() const;
/**
* Set machine to use in bagging
*
* @param machine the machine to use for bagging
*/
void set_machine(CMachine* machine);
/** name **/
virtual const char* get_name() const { return "BaggingMachine"; }
protected:
virtual bool train_machine(CFeatures* data=NULL);
private:
void register_parameters();
void init();
private:
/** bags array */
CDynamicObjectArray m_bags;
/** features to train on */
CFeatures* m_features;
/** machine to use for bagging */
CMachine* m_machine;
/** number of bags to create */
int32_t m_num_bags;
/** number of vectors to use from the training features */
int32_t m_bag_size;
};
}
#endif /* BAGGINGMACHINE_H */