Skip to content

BaseEstimator

The abstract base class defining the estimator interface.

Overview

All estimators in Falcon must implement this interface. The base class defines methods for:

  • Runtime wiring (setup)
  • Training (train)
  • Sampling (sample_prior, sample_posterior, sample_proposal)
  • Persistence (save, load)
  • Control flow (interrupt)

Class Reference

BaseEstimator

Bases: ABC

Fully abstract base class defining the estimator interface.

Subclasses implement a two-phase lifecycle:

  1. __init__: pure config storage — stores all parameters as instance attributes. Defaults live here; nothing runtime is wired up.

  2. setup(): load-bearing runtime wiring — called by NodeWrapper inside a Ray actor before training begins. Applies any flat YAML overrides (config dict), then initialises networks, devices, and all runtime objects.

Example::

graph.add_node("z", estimator=Flow(max_epochs=300, net_type="nsf"))

setup abstractmethod

setup(simulator_instance, theta_key, condition_keys)

Wire up runtime components.

Called by NodeWrapper before training.

Parameters:

Name Type Description Default
simulator_instance

Live prior/simulator, already constructed.

required
theta_key Optional[str]

Name of the parameter node being estimated.

required
condition_keys

List of evidence/scaffold node names.

required
Source code in src/falcon/core/base_estimator.py
@abstractmethod
def setup(
    self,
    simulator_instance,
    theta_key: Optional[str],
    condition_keys,
) -> None:
    """Wire up runtime components.

    Called by ``NodeWrapper`` before training.

    Args:
        simulator_instance: Live prior/simulator, already constructed.
        theta_key: Name of the parameter node being estimated.
        condition_keys: List of evidence/scaffold node names.
    """

train abstractmethod async

train(buffer)
Source code in src/falcon/core/base_estimator.py
@abstractmethod
async def train(self, buffer) -> None:
    pass

sample_prior abstractmethod

sample_prior(num_samples, conditions=None)
Source code in src/falcon/core/base_estimator.py
@abstractmethod
def sample_prior(self, num_samples: int, conditions: Optional[Conditions] = None) -> dict:
    pass

sample_posterior abstractmethod

sample_posterior(num_samples, conditions=None)
Source code in src/falcon/core/base_estimator.py
@abstractmethod
def sample_posterior(self, num_samples: int, conditions: Optional[Conditions] = None) -> dict:
    pass

sample_proposal abstractmethod

sample_proposal(num_samples, conditions=None)
Source code in src/falcon/core/base_estimator.py
@abstractmethod
def sample_proposal(self, num_samples: int, conditions: Optional[Conditions] = None) -> dict:
    pass

save abstractmethod

save(node_dir)
Source code in src/falcon/core/base_estimator.py
@abstractmethod
def save(self, node_dir: Path) -> None:
    pass

load abstractmethod

load(node_dir)
Source code in src/falcon/core/base_estimator.py
@abstractmethod
def load(self, node_dir: Path) -> None:
    pass

interrupt abstractmethod

interrupt()
Source code in src/falcon/core/base_estimator.py
@abstractmethod
def interrupt(self) -> None:
    pass