BayesianNeuralFieldEstimator¤
Base class for BayesNF estimators.
This class should not be initialized directly, but rather one of the three subclasses that implement different model learning procedures:
-
BayesianNeuralFieldVI, for ensembles of surrogate posteriors from variational inference.
-
BayesianNeuralFieldMAP, for stochastic ensembles of maximum-a-posteriori estimates.
-
BayesianNeuralFieldMLE, for stochastic ensembles of maximum likelihood estimates.
All three classes share the same __init__
method described below.
Source code in bayesnf/spatiotemporal.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 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 |
|
__init__
¤
__init__(*, feature_cols, target_col, seasonality_periods=None, num_seasonal_harmonics=None, fourier_degrees=None, interactions=None, freq=None, timetype='index', depth=2, width=512, observation_model='NORMAL', standardize=None)
Shared initialization for subclasses of BayesianNeuralFieldEstimator.
PARAMETER | DESCRIPTION |
---|---|
feature_cols |
Names of columns to use as features in the training data frame. The first entry denotes the name of the time variable, the remaining entries (if any) denote names of the spatial features.
TYPE:
|
target_col |
Name of the target column representing the spatial field.
TYPE:
|
seasonality_periods |
A list of numbers representing the seasonal frequencies of the data in the time domain. If timetype == 'index', then it is possible to specify numeric frequencies by using string short hands such as 'W', 'D', etc., which correspond to a valid Pandas frequency. See Pandas Offset Aliases for valid string values.
TYPE:
|
num_seasonal_harmonics |
A list of seasonal harmonics, one for each entry
in
TYPE:
|
fourier_degrees |
A list of integer degrees for the Fourier features of the
inputs. If given, must have the same length as
TYPE:
|
interactions |
A list of tuples of column indexes for the first-order
interactions. For example
TYPE:
|
freq |
A frequency string for the sampling rate at which the data is
collected. See the Pandas Offset
Aliases
for valid values. Should be used if and only if
TYPE:
|
timetype |
Either
TYPE:
|
depth |
The number of hidden layers in the BayesNF architecture.
TYPE:
|
width |
The number of hidden units in each layer.
TYPE:
|
observation_model |
The aleatoric noise model for the observed data. The
options are
TYPE:
|
standardize |
List of columns that should be standardized. It is highly
recommended to standardize
TYPE:
|
Source code in bayesnf/spatiotemporal.py
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 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
|
predict
¤
predict(table, quantiles=(0.5), approximate_quantiles=False)
Make predictions of the target column at new times.
PARAMETER | DESCRIPTION |
---|---|
table |
Field locations at which to make new predictions. Same as
TYPE:
|
quantiles |
The list of quantiles to compute.
TYPE:
|
approximate_quantiles |
If
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
means
|
The predicted means from each particle in the learned ensemble.
The shape is
TYPE:
|
quantiles
|
A list of numpy arrays, one per requested quantile.
The length of each array in the list is
TYPE:
|
Source code in bayesnf/spatiotemporal.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
|
fit
¤
fit(table, seed)
Run inference given a training data table
and seed
.
Cannot be directly called on BayesianNeuralFieldEstimator
.
PARAMETER | DESCRIPTION |
---|---|
table |
A pandas DataFrame representing the training data. It has the following requirements:
TYPE:
|
seed |
The jax random key.
TYPE:
|
Source code in bayesnf/spatiotemporal.py
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
|
likelihood_model
¤
likelihood_model(table)
Access the predictive distribution over new field values in table
.
NOTE: Must be called after fit
.
PARAMETER | DESCRIPTION |
---|---|
table |
Field locations at which to make new predictions. Same as
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Distribution
|
A probability distribution representing the predictive distribution
over |
Source code in bayesnf/spatiotemporal.py
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 |
|