random_forest
RandomForestRegressorLearner(n_estimators=100, *, criterion='squared_error', max_depth=None, min_samples_split=2, min_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features=1.0, max_leaf_nodes=None, min_impurity_decrease=0.0, bootstrap=True, oob_score=False, n_jobs=None, random_state=None, verbose=0, warm_start=False, ccp_alpha=0.0, max_samples=None, monotonic_cst=None, callbacks=None)
Bases: SupervisedLearner
Wrapper class for sklearn's RandomForestRegressor.
Reference: https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestRegressor.html
Initialize the random forest learner.
Reference: https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.RandomForestRegressor.html
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_estimators
|
int
|
Number of trees in the forest. |
100
|
criterion
|
str
|
Function to measure the quality of a split. |
'squared_error'
|
max_depth
|
int | None
|
Maximum depth of the tree. |
None
|
min_samples_split
|
int
|
Minimum number of samples required to split an internal node. |
2
|
min_samples_leaf
|
int
|
Minimum number of samples required to be at a leaf node. |
1
|
min_weight_fraction_leaf
|
float
|
Minimum weighted fraction of the sum total of weights required to be at a leaf node. |
0.0
|
max_features
|
float
|
Number of features to consider when looking for the best split. |
1.0
|
max_leaf_nodes
|
int | None
|
Grow trees with max_leaf_nodes in best-first fashion. |
None
|
min_impurity_decrease
|
float
|
A node will be split if this split induces a decrease of the impurity greater than or equal to this value. |
0.0
|
bootstrap
|
bool
|
Whether bootstrap samples are used when building trees. |
True
|
oob_score
|
bool
|
Whether to use out-of-bag samples to estimate the R^2 on unseen data. |
False
|
n_jobs
|
int | None
|
Number of jobs to run in parallel. |
None
|
random_state
|
int | None
|
Controls the randomness of the estimator. |
None
|
verbose
|
int
|
Controls the verbosity when fitting and predicting. |
0
|
warm_start
|
bool
|
When set to True, reuse the solution of the previous call to fit. |
False
|
ccp_alpha
|
float
|
Complexity parameter used for Minimal Cost-Complexity Pruning. |
0.0
|
max_samples
|
int | float | None
|
If bootstrap is True, the number of samples to draw from X to train each base estimator. |
None
|
monotonic_cst
|
NDArray | None
|
Monotonicity constraints. |
None
|
callbacks
|
list[LearnerCallback] | LearnerCallback | None
|
Optional callbacks for progress feedback. Use |
None
|
Source code in src/flowcean/sklearn/random_forest.py
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 | |
learn(inputs, outputs)
Fit the random forest regressor on the given inputs and outputs.
Source code in src/flowcean/sklearn/random_forest.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |