stanbkt.fits.PFFitOptions#

class stanbkt.fits.PFFitOptions(seed=None, extra_kwargs=<factory>, init_alpha=None, tol_obj=None, tol_rel_obj=None, tol_grad=None, tol_rel_grad=None, tol_param=None, history_size=None, num_paths=None, max_lbfgs_iters=None, draws=None, num_elbo_draws=None, psis_resample=True, calculate_lp=True, inits=None, show_console=False, refresh=None, num_threads=None)#

Bases: BaseFitOptions

Common options for cmdstanpy.CmdStanModel.pathfinder().

Parameters:
  • init_alpha (float | None) – Initial step size parameter for Pathfinder.

  • tol_obj (float | None) – Absolute tolerance on the objective value.

  • tol_rel_obj (float | None) – Relative tolerance on the objective value.

  • tol_grad (float | None) – Absolute tolerance on the gradient norm.

  • tol_rel_grad (float | None) – Relative tolerance on the gradient norm.

  • tol_param (float | None) – Tolerance on parameter changes.

  • history_size (int | None) – History size used by the underlying L-BFGS optimizer.

  • num_paths (int | None) – Number of Pathfinder optimization paths.

  • max_lbfgs_iters (int | None) – Maximum number of L-BFGS iterations per path.

  • draws (int | None) – Number of draws returned from the Pathfinder approximation.

  • num_elbo_draws (int | None) – Number of draws used for ELBO estimation.

  • psis_resample (bool) – Whether to use PSIS resampling for returned draws.

  • calculate_lp (bool) – Whether to calculate log probability values for draws.

  • seed (int | None) – RNG seed.

  • inits (dict[str, float] | float | PathLike | str | None) – Initial parameter values or path to an initialization file.

  • show_console (bool) – Whether to stream CmdStan console output.

  • refresh (int | None) – Frequency of progress messages written by CmdStan.

  • num_threads (int | None) – Number of threads available to the CmdStan process.

  • extra_kwargs (dict[str, Any])

Notes

This dataclass intentionally exposes only a small set of commonly used Pathfinder arguments. Less common options can be supplied through extra_kwargs.

calculate_lp: bool = True#
draws: int | None = None#
extra_kwargs: dict[str, Any]#
classmethod from_dict(d)#

Create fit options from a dictionary.

Known dataclass fields are extracted and used for instantiation. Remaining keys are stored in extra_kwargs for CmdStanPy.

Parameters:

d (dict[str, Any]) – Dictionary containing fit options. Keys matching dataclass fields are assigned to those fields; remaining keys go to extra_kwargs.

Returns:

New instance of the fit options class with fields populated from dict.

Return type:

Self

history_size: int | None = None#
init_alpha: float | None = None#
inits: dict[str, float] | float | PathLike | str | None = None#
max_lbfgs_iters: int | None = None#
num_elbo_draws: int | None = None#
num_paths: int | None = None#
num_threads: int | None = None#
psis_resample: bool = True#
refresh: int | None = None#
seed: int | None = None#
show_console: bool = False#
to_dict()#

Convert options to a CmdStanPy kwargs dictionary.

None values are removed so CmdStanPy can apply its own defaults.

Returns:

Flat kwargs dictionary for CmdStanPy APIs.

Return type:

dict[str, Any]

tol_grad: float | None = None#
tol_obj: float | None = None#
tol_param: float | None = None#
tol_rel_grad: float | None = None#
tol_rel_obj: float | None = None#