Skip to content

← bayesian package

TemplateModel

Classify data instances using Bayesian Logistic Regression with numpyro.

This method uses Bayesian inference to estimate both the parameters and their uncertainty, providing more robust predictions than traditional point-estimate methods. The model assumes Gaussian priors on the regression weights and bias, and uses either Laplace approximation or maximum a posteriori (MAP) estimation for inference. The Laplace approximation provides a Gaussian approximation to the posterior distribution around the mode, allowing for uncertainty quantification in predictions. This is particularly useful when you need to know how confident the model is about its predictions. The model can optionally extract additional variables from the instance data (such as group membership indices) which can be used to extend the model for hierarchical or more complex Bayesian structures. Like all machine learning methods, this method needs to be calibrated ("trained") before it can make any predictions on data. The training process involves Bayesian inference to estimate the posterior distribution over model parameters given the training data and prior beliefs. More Info... Version 1.0.0

Ports/Properties

data

Data to process.

verbose name
Data
default value
None
port type
DataPort
value type
Packet (can be None)
data direction
INOUT

cond_field

The name of the instance data field that contains the conditions to be discriminated. This parameter will be ignored if the packet has previously been processed by a DescribeStatisticalDesign node.

verbose name
Cond Field
default value
TargetValue
port type
StringPort
value type
str (can be None)

group_field

The name of the instance data field that contains group membership indices for hierarchical modeling. If empty, no group structure is used. This field can be used to extract additional variables for more complex Bayesian models.

verbose name
Group Membership Field
default value
port type
StringPort
value type
str (can be None)

weight_prior_scale

Standard deviation of the Gaussian prior on the regression weights. Smaller values lead to stronger regularization (shrinkage towards zero).

verbose name
Weight Prior Scale
default value
1.0
port type
FloatPort
value type
float (can be None)

bias_prior_scale

Standard deviation of the Gaussian prior on the bias term. Typically set larger than the weight prior to allow more flexibility in the intercept.

verbose name
Bias Prior Scale
default value
10.0
port type
FloatPort
value type
float (can be None)

include_bias

Include a bias term (intercept). If false, your features need to be centered, or include a dummy feature set to 1.

verbose name
Include Bias Term
default value
True
port type
BoolPort
value type
bool (can be None)

inference_method

Inference method to use. 'laplace' uses Laplace approximation around the posterior mode, providing uncertainty estimates. 'map' finds only the maximum a posteriori point estimate.

verbose name
Inference Method
default value
laplace
port type
EnumPort
value type
str (can be None)

num_optimization_steps

Maximum number of optimization steps for finding the posterior mode. More steps may lead to better convergence but increase computation time.

verbose name
Optimization Steps
default value
1000
port type
IntPort
value type
int (can be None)

learning_rate

Learning rate for the optimizer used to find the posterior mode.

verbose name
Learning Rate
default value
0.01
port type
FloatPort
value type
float (can be None)

prediction_type

Type of predictions to output. 'mean' outputs the posterior predictive mean. 'samples' would output samples from the posterior predictive distribution (not yet implemented).

verbose name
Prediction Type
default value
mean
port type
EnumPort
value type
str (can be None)

num_prediction_samples

Number of samples to draw from the posterior for prediction when prediction_type='samples'.

verbose name
Prediction Samples
default value
100
port type
IntPort
value type
int (can be None)

initialize_once

Calibrate the model only once. If set to False, then this node will recalibrate itself whenever a non-streaming data chunk is received that has both training labels and associated training instances.

verbose name
Calibrate Only Once
default value
True
port type
BoolPort
value type
bool (can be None)

dont_reset_model

Do not reset the model when the preceding graph is changed. Normally, when certain parameters of preceding nodes are being changed, the model will be reset. If this is enabled, the model will persist, but there is a chance that the model is incompatible when input data format to this node has changed.

verbose name
Do Not Reset Model
default value
False
port type
BoolPort
value type
bool (can be None)

verbosity

Verbosity level. Higher numbers will produce more extensive diagnostic output.

verbose name
Verbosity Level
default value
0
port type
IntPort
value type
int (can be None)

random_seed

Random seed for reproducible results.

verbose name
Random Seed
default value
42
port type
IntPort
value type
int (can be None)

num_posterior_samples

Number of samples to draw from the posterior distribution for making predictions. Higher values give more accurate posterior predictive estimates but increase computation time.

verbose name
Posterior Samples
default value
50
port type
IntPort
value type
int (can be None)

set_breakpoint

Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.

verbose name
Set Breakpoint (Debug Only)
default value
False
port type
BoolPort
value type
bool (can be None)

metadata

User-definable meta-data associated with the node. Usually reserved for technical purposes.

verbose name
Metadata
default value
{}
port type
DictPort
value type
dict (can be None)