-
Notifications
You must be signed in to change notification settings - Fork 255
/
Copy pathForest.h
68 lines (52 loc) · 2 KB
/
Forest.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
/*-------------------------------------------------------------------------------
Copyright (c) 2024 GRF Contributors.
This file is part of generalized random forest (grf).
grf 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.
grf is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with grf. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------*/
#ifndef GRF_FOREST_H_
#define GRF_FOREST_H_
#include "commons/Data.h"
#include "commons/globals.h"
#include "forest/ForestOptions.h"
#include "tree/TreeTrainer.h"
#include "tree/Tree.h"
namespace grf {
class Forest {
public:
Forest(std::vector<std::unique_ptr<Tree>>& trees,
size_t num_variables,
size_t ci_group_size);
Forest(Forest&& forest);
const std::vector<std::unique_ptr<Tree>>& get_trees() const;
/**
* A method intended for internal use that allows the list of
* trees to be modified.
*/
std::vector<std::unique_ptr<Tree>>& get_trees_();
const size_t get_num_variables() const;
const size_t get_ci_group_size() const;
/**
* Merges the given forests into a single forest. The new forest
* will contain all the trees from the smaller forests.
*
* NOTE: this is a destructive operation -- the original forests cannot
* be used after they are merged together.
*/
static Forest merge(std::vector<Forest>& forests);
private:
std::vector<std::unique_ptr<Tree>> trees;
size_t num_variables;
size_t ci_group_size;
DISALLOW_COPY_AND_ASSIGN(Forest);
};
} // namespace grf
#endif /* GRF_FOREST_H_ */