Regression
Helper classes for regression problems
AbstractRegressionPrediction
predict
abstractmethod
predict()
Make a regression prediction
Source code in pyrenew/regression.py
18 19 20 21 22 23 |
|
sample
abstractmethod
sample(obs=None)
Observe or sample from the regression problem according to the specified distributions
Source code in pyrenew/regression.py
25 26 27 28 29 30 31 32 |
|
GLMPrediction
GLMPrediction(
name: str,
intercept_prior: Distribution,
coefficient_priors: Distribution,
transform: Transform = None,
intercept_suffix="_intercept",
coefficient_suffix="_coefficients",
)
Bases: AbstractRegressionPrediction
Generalized linear model regression predictions
Default class constructor for GLMPrediction
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the prediction process,
which will be used to name the constituent
sampled parameters in calls to |
required |
intercept_prior
|
Distribution
|
Prior distribution for the regression intercept value |
required |
coefficient_priors
|
Distribution
|
Vectorized prior distribution for the regression coefficient values |
required |
transform
|
Transform
|
Transform linking the scale of the
regression to the scale of the observation.
If |
None
|
intercept_suffix
|
Suffix for naming the intercept random variable in
class to numpyro.sample(). Default |
'_intercept'
|
|
coefficient_suffix
|
Suffix for naming the regression coefficient
random variables in calls to numpyro.sample().
Default |
'_coefficients'
|
Source code in pyrenew/regression.py
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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
__call__
__call__(*args, **kwargs)
Alias for sample()
.
Source code in pyrenew/regression.py
190 191 192 193 194 |
|
predict
Generates a transformed prediction w/ intercept, coefficients, and predictor values
Parameters:
Name | Type | Description | Default |
---|---|---|---|
intercept
|
ArrayLike
|
Sampled numpyro distribution generated from intercept priors. |
required |
coefficients
|
ArrayLike
|
Sampled prediction coefficients distribution generated from coefficients priors. |
required |
predictor_values
|
ArrayLike
|
Matrix of predictor variables (covariates) for the regression problem. Each row should represent the predictor values corresponding to an observation; each column should represent a predictor variable. You do not include values of 1 for the intercept; these will be added automatically. |
required |
Returns:
Type | Description |
---|---|
ArrayLike
|
Array of transformed predictions. |
Source code in pyrenew/regression.py
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 148 149 150 151 152 153 |
|
sample
sample(predictor_values: ArrayLike) -> GLMPredictionSample
Sample generalized linear model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
predictor_values
|
ArrayLike
|
Matrix of predictor variables (covariates) for the
regression problem. Each row should represent the
predictor values corresponding to an observation;
each column should represent a predictor variable.
Do not include values of 1 for the intercept;
these will be added automatically. Passed as the
|
required |
Returns:
Type | Description |
---|---|
GLMPredictionSample
|
|
Source code in pyrenew/regression.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
GLMPredictionSample
Bases: NamedTuple
A container for holding the output from GLMPrediction.sample()
.
Attributes:
Name | Type | Description |
---|---|---|
prediction |
(ArrayLike | None, optional)
|
Transformed predictions. Defaults to None. |
intercept |
(ArrayLike | None, optional)
|
Sampled intercept from intercept priors. Defaults to None. |
coefficients |
(ArrayLike | None, optional)
|
Prediction coefficients generated from coefficients priors. Defaults to None. |