Skip to content

← machine_learning package

SpikeSlabHeredityClassification

Classify data instances using sparse Bayesian logistic regression with explicit main effects and interaction terms under a heredity-structured spike-and-slab prior.

The node reuses the existing coordinate-ascent variational Bayes core from the main-effects-only Spike-Slab VB classifier while expanding the design with pairwise or three-way interaction columns and recomputing the interaction prior probabilities from the current main-effect inclusion probabilities at each sweep. The default configuration uses weak heredity, centered pairwise products, and lasso screening before interaction expansion, which is the recommended practical setting for EEG-like data where interactions may be meaningful but should remain sparser than main effects. Interaction posterior inclusion probabilities are exposed alongside the main-effect probabilities in the fitted weight packet. More Info... Version 0.7.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 is 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)

feature_scaling

Feature scaling to use. The spike-and-slab prior is scale-sensitive, so scaling the features is recommended for proper shrinkage behavior. The default of 'std' (standardization to zero mean and unit variance) is a good choice for most data. The 'robust' option uses median and interquartile range, which is more resilient to outliers.

verbose name
Feature Scaling
default value
std
port type
EnumPort
value type
str (can be None)

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 data-dependent terms of the variational bound 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.

verbose name
Sample Size Correction
default value
1.0
port type
FloatPort
value type
float (can be None)

expected_relevant_features

Expected number or fraction of relevant features. Controls the prior inclusion probability pi = p0/p, where p0 is the expected relevant count. Values between 0 and 1 are interpreted as a fraction of the total feature count; values greater than or equal to 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), values of 0.02-0.05 are recommended to prevent over-selection of noise features.

verbose name
Expected Relevant Features
default value
0.1
port type
FloatPort
value type
float (can be None)

slab_scale

Scale of the slab (relevant-feature) component. Controls the prior width of the non-zero coefficients on standardized features: larger values allow relevant features to take on larger coefficient values, while smaller values constrain them to stay closer to zero. The default of 1.0 works robustly across a wide range of problems; empirically, values from 0.5 to 2.0 produce nearly identical results on most datasets.

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

include_bias

Include a bias (intercept) term. If disabled, input features should be centered or augmented with a constant feature.

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

learn_inclusion_probability

Learn the global prior inclusion probability from the data during fitting. When enabled, the method adapts how many features it expects to be relevant based on what the data supports. When disabled (the default), the inclusion probability is fixed at the value implied by the expected relevant features parameter.

verbose name
Learn Inclusion Probability
default value
False
port type
BoolPort
value type
bool (can be None)

learn_slab_scale

Learn the slab scale from the data during fitting. When enabled, the method adapts the expected magnitude of relevant coefficients based on the data. When disabled (the default), the slab scale is fixed at its configured value throughout fitting.

verbose name
Learn Slab Scale
default value
False
port type
BoolPort
value type
bool (can be None)

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).

verbose name
Support Threshold
default value
0.5
port type
FloatPort
value type
float (can be None)

max_iterations

Maximum number of coordinate-ascent (CAVI) sweeps. Convergence typically occurs within 100-200 iterations for most problems; the default of 500 is a generous safety margin.

verbose name
Maximum Iterations
default value
500
port type
IntPort
value type
int (can be None)

convergence_tolerance

Convergence tolerance on the maximum change in posterior inclusion probabilities or posterior mean coefficients over a full sweep. The default of 1e-5 yields tight convergence; values up to 1e-4 are acceptable for faster fitting with minimal accuracy loss.

verbose name
Convergence Tolerance
default value
1e-05
port type
FloatPort
value type
float (can be None)

laplace_solver

Solver for the inner CAVI coordinate sweep. 'scipy' uses scipy.optimize.minimize with L-BFGS-B for the 2D Laplace subproblem (the reference implementation). 'newton' replaces that with a hand-rolled 2D damped Newton iteration using the closed-form Hessian, which is numerically equivalent but avoids scipy's per-call overhead. 'numba' additionally JIT-compiles the entire per-feature sweep (x_appm updates, coef_lin dot product, Newton iteration, alpha update) as a single fused kernel, which is the fastest strictly-IEEE option for moderate to large feature counts. 'numba_fastmath' is the same kernel built with LLVM fast-math (reassoc, reciprocal, finite-only); it is typically 20-50% faster again but permits small reorderings at the ~1e-14 level. All numba variants pay a one-time JIT compilation cost on first use in a process (cached to disk).

verbose name
Laplace Subproblem Solver
default value
numba_fastmath
port type
EnumPort
value type
str (can be None)

random_seed

Random seed. Different values may give slightly different outcomes.

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

initialize_once

Calibrate the model only once. If set to False, then this node recalibrates 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.

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

probabilistic

Use probabilistic outputs. If enabled, the node will output for each class the predicted probability that a given trial belongs to that class.

verbose name
Output Probabilities
default value
True
port type
BoolPort
value type
bool (can be None)

verbosity

Verbosity level. Higher values print more fitting diagnostics.

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

heredity

The heredity structure coupling interaction inclusion to its parent main effects. 'strong' requires all parent mains to be active before an interaction can enter. 'weak' allows an interaction when at least one parent is active. 'none' removes heredity coupling and uses a plain spike-and-slab prior on the expanded design. 'custom' uses the probabilities supplied in custom_heredity_probabilities and currently supports pairwise interactions only.

verbose name
Heredity
default value
weak
port type
EnumPort
value type
str (can be None)

custom_heredity_probabilities

Custom pairwise heredity probabilities (a_0, a_1, a_2, a_3) used when heredity is set to 'custom'. These correspond to the probabilities of including an interaction when neither parent is active, only the first parent is active, only the second parent is active, or both parents are active.

verbose name
Custom Heredity Probabilities
default value
[0.0, 0.1, 0.1, 0.1]
port type
ListPort
value type
list (can be None)

interaction_form

How to construct interaction feature columns. 'centered_product' multiplies training-centered parent features, reducing overlap between main and interaction effects. 'orthogonalised_product' additionally removes the projection onto the parent mains and the intercept so the interaction column captures only non-additive structure.

verbose name
Interaction Form
default value
centered_product
port type
EnumPort
value type
str (can be None)

interaction_order

Maximum interaction order. A value of 1 disables interaction expansion and reduces the node to the main-effects-only spike-and-slab VB classifier. A value of 2 adds pairwise interactions, and 3 additionally adds three-way interactions.

verbose name
Interaction Order
default value
2
port type
IntPort
value type
int (can be None)

include_self_interactions

Include squared terms alongside the main effects. These act as simple quadratic terms whose inclusion depends on the corresponding main effect.

verbose name
Include Self Interactions
default value
False
port type
BoolPort
value type
bool (can be None)

main_effect_screening

Optional screening applied to the main effects before interaction expansion. The default 'lasso' reuses the package-like lasso warm start to keep the expanded design tractable in moderate-to-high-dimensional problems.

verbose name
Main Effect Screening
default value
lasso
port type
EnumPort
value type
str (can be None)

main_effect_screening_k

Optional cap on the number of main effects retained for interaction expansion. When omitted with lasso screening, all non-zero lasso-selected mains are kept.

verbose name
Main Effect Screening K
default value
None
port type
IntPort
value type
int (can be None)

vb_prescreen

Run an additional main-effects-only spike-and-slab VB pass after screening and keep only features whose posterior inclusion probability is at least 0.5 . This is more principled than lasso-only screening but costs an extra fit.

verbose name
Vb Prescreen
default value
False
port type
BoolPort
value type
bool (can be None)

interaction_inclusion_scale

Multiplier mapping the main-effect prior inclusion probability to the baseline interaction inclusion probability. Interactions are therefore encouraged to be sparser than main effects by default.

verbose name
Interaction Inclusion Scale
default value
0.1
port type
FloatPort
value type
float (can be None)

interaction_slab_scale

Multiplier mapping the main-effect slab scale to the slab scale used for interaction terms.

verbose name
Interaction Slab Scale
default value
1.0
port type
FloatPort
value type
float (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)