data.Residual
data.Residual(residual)Wrapper around a C++ class that stores residual data used in stochtree. This object becomes part of the real-time model “state” in that its contents always contain a full or partial residual, depending on the state of the sampler.
Typically this object is initialized with the original outcome and then “residualized” by subtracting out the initial prediction value of every tree in every forest term (as well as the predictions of any other model term).
Methods
| Name | Description |
|---|---|
| get_residual | Extract the current values of the residual as a numpy array |
| update_data | Update the current state of the outcome (i.e. partial residual) data by replacing each element with the elements of new_vector |
| add_vector | Update the current state of the outcome (i.e. partial residual) data by adding each element of update_vector |
| subtract_vector | Update the current state of the outcome (i.e. partial residual) data by subtracting each element of update_vector |
get_residual
data.Residual.get_residual()Extract the current values of the residual as a numpy array
Returns
| Name | Type | Description |
|---|---|---|
| np.array | Current values of the residual (which may be net of any forest / other model terms) |
update_data
data.Residual.update_data(new_vector)Update the current state of the outcome (i.e. partial residual) data by replacing each element with the elements of new_vector
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| new_vector | np.array | Univariate numpy array of new residual values. | required |
add_vector
data.Residual.add_vector(update_vector)Update the current state of the outcome (i.e. partial residual) data by adding each element of update_vector
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| update_vector | np.array | Univariate numpy array of values to add to the current residual. | required |
subtract_vector
data.Residual.subtract_vector(update_vector)Update the current state of the outcome (i.e. partial residual) data by subtracting each element of update_vector
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| update_vector | np.array | Univariate numpy array of values to subtracted from the current residual. | required |