orbit.utils package

Submodules

orbit.utils.general module

orbit.utils.general.expand_grid(base)

Given a base key values span, expand them into a dataframe covering all combinations :param base: dictionary with keys equal columns name and value equals key values :type base: dict

Returns:

pd.DataFrame

Return type:

dataframe generate based on user specified base

orbit.utils.general.get_parent_path(current_file_path)
Parameters:
  • current_file_path (str) – The given file path, should be an absolute path

  • Returns

  • ------- – str : The parent path of give file path

orbit.utils.general.is_empty_dataframe(df)

A simple function to tell whether the passed in df is an empty dataframe or not. :param df: given input dataframe :type df: pd.DataFrame

Returns:

bool

Return type:

True if df is none, or if df is an empty dataframe; False otherwise.

orbit.utils.general.is_even_gap_datetime(array)

Returns True if array is evenly distributed

orbit.utils.general.is_ordered_datetime(array)

Returns True if array is ordered and non-repetitive

orbit.utils.general.regenerate_base_df(df, time_col, key_col, val_cols=[], fill_na=None)

Given a dataframe, key column, time column and value column, re-generate multiple time-series to cover full range date-time with all the keys. This can be a useful utils for working multiple time-series.

Parameters:
  • df (pd.DataFrame) –

  • time_col (str) –

  • key_col (str) –

  • val_cols (List[str]; values column considered to be imputed) –

  • fill_na (Optional[float]; values to fill when there are missing values of the row) –

orbit.utils.general.update_dict(original_dict, append_dict)

orbit.utils.pyro module

orbit.utils.pyro.get_pyro_model(model_name)

orbit.utils.stan module

orbit.utils.stan.get_compiled_stan_model(stan_model_name: str = '', stan_file_path: str | None = None, exe_file_path: str | None = None, force_compile: bool = False) CmdStanModel

Return a compiled Stan model using CmdStan. This includes both prepackaged models as well as user provided models through stan_file_path.

Parameters:
  • stan_model_name – The name of the Stan model to use. Use this for the built in models (dlt, ets, ktrlite, lgt)

  • stan_file_path – The path to the Stan file to use. If not provided, the default is to search for the file in the ‘orbit’ package. If provided, function will ignore the stan_model_name parameter, and will compile the provide stan_file_path into executable in place (same folder as stan_file_path)

  • exe_file_path – The path to the Stan-exe file to use. If not provided, the default is to search for the file in the ‘orbit’ package. If provided, function will ignore the stan_model_name parameter, and will compile the provide stan_file_path into executable in place (same folder as stan_file_path)

Returns:

sm – A compiled Stan model.

Return type:

CmdStanModel

class orbit.utils.stan.suppress_stdout_stderr

Bases: object

A context manager for doing a “deep suppression” of stdout and stderr in Python, i.e. will suppress all print, even if the print originates in a compiled C/Fortran sub-function.

This will not suppress raised exceptions, since exceptions are printed

to stderr just before a script exits, and after the context manager has exited (at least, I think that is why it lets exceptions through).

Module contents