RelaxedSpikeSlabClassification¶
Classify data instances using binary sparse Bayesian logistic regression with a relaxed (Gaussian) spike-and-slab prior.
This node is designed for the difficult regime where the number of features is much larger than the number of observations and only a small minority of features are expected to be relevant. The model combines a global inclusion probability with per-feature soft inclusion variables and Gaussian slab/spike scales. Variational inference is used for efficient fitting in JAX, and empirical-Bayes updates learn the global inclusion probability and slab scale during optimization by default. This yields posterior inclusion probabilities for each feature together with a posterior-mean weight vector for downstream prediction and interpretation. As with other NeuroPype machine-learning nodes, this method expects a full calibration packet containing both training instances and labels before it can be used for prediction on subsequent data. Version 0.7.0
Ports/Properties¶
data¶
Data to process.
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.
feature_scaling¶
Feature scaling to use. The spike-and-slab prior acts on coefficient scale, so standardization is recommended in most cases.
sample_size_factor¶
Sample size correction factor or effective sample size. When observations are not independent (e.g., multiple trials per participant), the effective information content may be considerably lower than the nominal sample count, causing the posterior to be overconfident. This parameter tempers the likelihood by the factor n_eff/n, reducing the data's influence on the posterior to match the effective information content. Values between 0 and 1 (inclusive) are interpreted as a multiplicative factor applied to the actual number of observations; for instance, if you have 2000 trials from 30 participants, set this to 30/2000 = 0.015. Values > 1 must be integers and are interpreted as an absolute effective sample size; for instance, 30 means that the effective sample size is 30 regardless of the actual number of observations.
expected_relevant_features¶
Expected number or fraction of relevant features. Controls the prior inclusion probability for the spike-and-slab gate. Values between 0 and 1 are interpreted as a fraction of the total feature count; values >= 1 must be integers and are interpreted as an absolute count. The default of 0.1 works well for moderate-dimensional problems (p up to ~2000). For very high-dimensional datasets (p > 5000), reduce to 0.02-0.05 to avoid over-selection.
initial_slab_scale¶
Initial scale of the slab (relevant-feature) component on standardized features. This controls how large the coefficients of relevant features are expected to be before the method has seen any data. Larger values give the non-zero coefficients more room to take on large values; smaller values encourage tighter concentration near zero, which can be appropriate when the expected effect sizes are small. When slab-scale learning is enabled (the default), this serves as the starting point for optimization and the final learned value may differ.
spike_scale¶
Scale of the spike (irrelevant-feature) component. This controls how tightly the coefficients of irrelevant features are concentrated around zero. Smaller values enforce stronger suppression of inactive features, producing a cleaner separation between relevant and irrelevant features. Values around 0.01-0.1 are typical; the default of 0.05 works well in most settings. If the method has difficulty distinguishing relevant from irrelevant features, try reducing this value.
include_bias¶
Include a bias (intercept) term. If false, features need to be centered or include a constant feature set to 1.
learn_inclusion_probability¶
Learn the global prior inclusion probability from the data during variational fitting. When enabled, the method adapts how many features it expects to be relevant based on what the data supports, starting from the value implied by the expected relevant features parameter. When disabled, the inclusion probability is fixed at the initial value throughout fitting.
learn_slab_scale¶
Learn the slab scale from the data during variational fitting. When enabled, the method adapts the expected magnitude of relevant coefficients based on the data, starting from the initial slab scale value. When disabled, the slab scale is fixed at its initial value throughout fitting.
support_threshold¶
Threshold on the estimated probability that a feature is relevant. Features whose inclusion probability meets or exceeds this threshold are reported as active in the support mask. The default of 0.5 selects features that are more likely relevant than not (the median probability model).
temperature¶
Temperature parameter that controls how sharply the method distinguishes between included and excluded features during optimization. Lower values produce crisper on/off feature selection decisions, but can make the optimization landscape harder to navigate, potentially leading to poorer solutions. Higher values produce softer decisions that are easier to optimize but may result in less decisive feature selection. The default of 0.67 balances optimization quality with selection sharpness.
num_svi_steps¶
Number of variational optimization steps. For most problems 2000-3000 steps suffice. High-dimensional datasets (p >> n) may benefit from 4000-5000 steps, especially when using a lower learning rate.
learning_rate¶
Initial learning rate for the Adam optimizer. The default of 0.01 works well for most problems. For high-dimensional datasets (p >> n), reducing to 0.005 improves convergence stability; increase the number of SVI steps proportionally when doing so.
posterior_samples_for_prediction¶
Number of random samples drawn from the fitted posterior distribution and used to compute predicted class probabilities. Using multiple samples averages over the remaining uncertainty in the model, generally producing better-calibrated probability estimates. Set to 1 to use only the posterior mean coefficients for prediction (faster, but ignores model uncertainty). The default of 64 is a good balance between prediction quality and speed.
random_seed¶
Random seed. Different values may give slightly different outcomes.
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.
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.
probabilistic¶
Use probabilistic outputs. If enabled, the node will output for each class the probability that a given trial is of that class; otherwise it will output the most likely class label.
verbosity¶
Verbosity level. Higher numbers will produce more extensive diagnostic output.
set_breakpoint¶
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.
metadata¶
User-definable meta-data associated with the node. Usually reserved for technical purposes.