Builtin Exogenous Effects
AbstractEffect
Bases: ABC
Abstract class for effects.
Effects should inherit from this class and implement the compute_effect
method.
The id is used to create unique names for the samples in the model.
Source code in src/prophetverse/effects.py
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
compute_effect(trend, data)
abstractmethod
Compute the effect based on the trend and data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trend |
ndarray
|
The trend. |
required |
data |
ndarray
|
The data concerning this effect. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
jnp.ndarray: The effect. |
Source code in src/prophetverse/effects.py
68 69 70 71 72 73 74 75 76 77 78 79 |
|
match_columns(columns)
Match the columns of the DataFrame with the regex pattern.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
The DataFrame to match. |
required |
Returns:
Type | Description |
---|---|
Index
|
pd.Index: The columns that match the regex pattern. |
Source code in src/prophetverse/effects.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
sample(name, *args, **kwargs)
Sample a random variable with a unique name.
Source code in src/prophetverse/effects.py
62 63 64 65 66 |
|
split_data_into_effects(X, effects)
staticmethod
Split the data into effects.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
DataFrame
|
The DataFrame to split. |
required |
effects |
List[AbstractEffect]
|
The effects to split the data into. |
required |
Returns:
Type | Description |
---|---|
Dict[str, DataFrame]
|
Dict[str, pd.DataFrame]: A dictionary mapping effect names to DataFrames. |
Source code in src/prophetverse/effects.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
HillEffect
Bases: AbstractEffect
Represents a Hill effect in a time series model.
Attributes:
Name | Type | Description |
---|---|---|
half_max_prior |
Prior distribution for the half-maximum parameter. |
|
slope_prior |
Prior distribution for the slope parameter. |
|
max_effect_prior |
Prior distribution for the maximum effect parameter. |
|
effect_mode |
Mode of the effect (either "additive" or "multiplicative"). |
Source code in src/prophetverse/effects.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
|
compute_effect(trend, data)
Computes the effect using the log transformation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trend |
The trend component. |
required | |
data |
The input data. |
required |
Returns:
Type | Description |
---|---|
The computed effect. |
Source code in src/prophetverse/effects.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
|
LinearEffect
Bases: AbstractEffect
Represents a linear effect in a hierarchical prophet model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id |
str
|
The identifier for the effect. |
required |
prior |
Distribution
|
A numpyro distribution to use as prior. Defaults to dist.Normal(0, 1) |
None
|
effect_mode |
str
|
The mode of the effect, either "multiplicative" or "additive". |
'multiplicative'
|
Attributes:
Name | Type | Description |
---|---|---|
dist |
type
|
The distribution class used for sampling coefficients. |
dist_args |
tuple
|
The arguments passed to the distribution class. |
effect_mode |
str
|
The mode of the effect, either "multiplicative" or "additive". |
Methods:
Name | Description |
---|---|
compute_effect |
Computes the effect based on the given trend and data. |
Source code in src/prophetverse/effects.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 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 189 190 191 192 193 |
|
compute_effect(trend, data)
Computes the effect based on the given trend and data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trend |
The trend component of the hierarchical prophet model. |
required | |
data |
The data used to compute the effect. |
required |
Returns:
Type | Description |
---|---|
The computed effect based on the given trend and data. |
Source code in src/prophetverse/effects.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
|
LogEffect
Bases: AbstractEffect
Log effect for a variable.
Computes the effect using the formula:
effect = scale * log(rate * data + 1)
A gamma prior is used for the scale and rate parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id |
str
|
The identifier for the effect. |
required |
scale_prior |
Distribution
|
The prior distribution for the scale parameter. |
None
|
rate_prior |
Distribution
|
The prior distribution for the rate parameter. |
None
|
Source code in src/prophetverse/effects.py
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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
|
compute_effect(trend, data)
Computes the effect using the log transformation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trend |
The trend component. |
required | |
data |
The input data. |
required |
Returns:
Type | Description |
---|---|
The computed effect. |
Source code in src/prophetverse/effects.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
|