-
Notifications
You must be signed in to change notification settings - Fork 251
/
SplittingRule.h
61 lines (49 loc) · 2.3 KB
/
SplittingRule.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
/*-------------------------------------------------------------------------------
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_SPLITTINGRULE_H
#define GRF_SPLITTINGRULE_H
#include <vector>
#include "Eigen/Dense"
#include "commons/Data.h"
namespace grf {
class SplittingRule {
public:
virtual ~SplittingRule() {}
/**
* Finds the best split at a given node in the tree.
*
* Is called repeatedly to build a tree in a breadth-first fashion.
*
* @param data: the data matrix containing all test samples.
* @param node: the node id in the tree.
* @param possible_split_vars: a vector of valid covariate IDs.
* @param responses_by_sample: the response for each sample.
* @param samples: a vector of samples at the given node.
* @param split_vars: the output of the method, the best split variable, stored at node.
* @param split_values: the output of the method, the best split value, stored at node.
* @return a boolean that will be true if no best split was found.
*
*/
virtual bool find_best_split(const Data& data,
size_t node,
const std::vector<size_t>& possible_split_vars,
const Eigen::ArrayXXd& responses_by_sample,
const std::vector<std::vector<size_t>>& samples,
std::vector<size_t>& split_vars,
std::vector<double>& split_values,
std::vector<bool>& send_missing_left) = 0;
};
} // namespace grf
#endif //GRF_SPLITTINGRULE_H