Skip to content

Commit f8016c4

Browse files
authored
Merge pull request #373 from StochasticTree/kernel-docs-0.4.3
Update Python kernel function documentation to render bullet lists
2 parents 9145840 + 1ab1a83 commit f8016c4

1 file changed

Lines changed: 30 additions & 24 deletions

File tree

stochtree/kernel.py

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,7 @@ def compute_forest_leaf_indices(
3434
covariates : np.array or pd.DataFrame
3535
Covariates to use for prediction. Must have the same dimensions / column types as the data used to train a forest.
3636
forest_type : str
37-
Which forest to use from `model_object`. Valid inputs depend on the model type, and whether or not a given forest was sampled in that model.
38-
39-
* **BART**
40-
* `'mean'`: `'mean'`: Extracts leaf indices for the mean forest
41-
* `'variance'`: Extracts leaf indices for the variance forest
42-
* **BCF**
43-
* `'prognostic'`: Extracts leaf indices for the prognostic forest
44-
* `'treatment'`: Extracts leaf indices for the treatment effect forest
45-
* `'variance'`: Extracts leaf indices for the variance forest
46-
* **ForestContainer**
47-
* `NULL`: It is not necessary to disambiguate when this function is called directly on a `ForestSamples` object. This is the default value of this
48-
37+
Which forest to use from `model_object`. Valid inputs depend on the model type, and whether or not a given forest was sampled in that model. See Notes for a mapping from model type to valid forest types.
4938
propensity : `np.array`, optional
5039
Optional test set propensities. Must be provided if propensities were provided when the model was sampled.
5140
forest_inds : int or np.ndarray
@@ -55,6 +44,20 @@ def compute_forest_leaf_indices(
5544
Returns
5645
-------
5746
Numpy array with dimensions `num_obs` by `num_trees`, where `num_obs` is the number of rows in `covariates` and `num_trees` is the number of trees in the relevant forest of `model_object`.
47+
48+
Notes
49+
-----
50+
Mapping from model type to forest types:
51+
52+
- **BART**
53+
- `'mean'`: `'mean'`: Extracts leaf indices for the mean forest
54+
- `'variance'`: Extracts leaf indices for the variance forest
55+
- **BCF**
56+
- `'prognostic'`: Extracts leaf indices for the prognostic forest
57+
- `'treatment'`: Extracts leaf indices for the treatment effect forest
58+
- `'variance'`: Extracts leaf indices for the variance forest
59+
- **ForestContainer**
60+
- `NULL`: It is not necessary to disambiguate when this function is called directly on a `ForestSamples` object. This is the default value of this
5861
"""
5962
# Extract relevant forest container
6063
if (
@@ -175,25 +178,28 @@ def compute_forest_max_leaf_index(
175178
model_object : BARTModel, BCFModel, or ForestContainer
176179
Object corresponding to a BART / BCF model with at least one forest sample, or a low-level `ForestContainer` object.
177180
forest_type : str
178-
Which forest to use from `model_object`. Valid inputs depend on the model type, and whether or not a given forest was sampled in that model.
179-
180-
* **BART**
181-
* `'mean'`: `'mean'`: Extracts leaf indices for the mean forest
182-
* `'variance'`: Extracts leaf indices for the variance forest
183-
* **BCF**
184-
* `'prognostic'`: Extracts leaf indices for the prognostic forest
185-
* `'treatment'`: Extracts leaf indices for the treatment effect forest
186-
* `'variance'`: Extracts leaf indices for the variance forest
187-
* **ForestContainer**
188-
* `NULL`: It is not necessary to disambiguate when this function is called directly on a `ForestSamples` object. This is the default value of this
189-
181+
Which forest to use from `model_object`. Valid inputs depend on the model type, and whether or not a given forest was sampled in that model. See Notes for a mapping from model type to valid forest types.
190182
forest_inds : int or np.ndarray
191183
Indices of the forest sample(s) for which to compute max leaf indices. If not provided, this function will return max leaf indices for every sample of a forest.
192184
This function uses 0-indexing, so the first forest sample corresponds to `forest_num = 0`, and so on.
193185
194186
Returns
195187
-------
196188
Numpy array containing the largest possible leaf index computable by `compute_forest_leaf_indices` for the forests in a designated forest sample container.
189+
190+
Notes
191+
-----
192+
Mapping from model type to forest types:
193+
194+
- **BART**
195+
- `'mean'`: `'mean'`: Extracts leaf indices for the mean forest
196+
- `'variance'`: Extracts leaf indices for the variance forest
197+
- **BCF**
198+
- `'prognostic'`: Extracts leaf indices for the prognostic forest
199+
- `'treatment'`: Extracts leaf indices for the treatment effect forest
200+
- `'variance'`: Extracts leaf indices for the variance forest
201+
- **ForestContainer**
202+
- `NULL`: It is not necessary to disambiguate when this function is called directly on a `ForestSamples` object. This is the default value of this
197203
"""
198204
# Extract relevant forest container
199205
if (

0 commit comments

Comments
 (0)