larch.model.troubleshooting.nan_weight#

nan_weight(model: NumbaModel, repair: Literal['?', True, '!'] = '?', verbose: int = 3) tuple[NumbaModel, DataFrame | None][source]#

Check if some weight values are NaN.

Parameters:
  • model (larch.Model) – The model to check.

  • repair ({"?", "!", True}) – Whether to repair the data. Any true value other than “?” or “!” will make NaN values in weight zero. The question mark simply emits a warning if there are NaN values found, while the exclamation mark will raise an error.

  • verbose (int, default 3) – The number of example columns to list for each problem.

Returns:

  • model (larch.Model) – The model with revised dataset attached.

  • diagnosis (pd.DataFrame) – The number of bad instances, and some example rows.

Raises:

ValueError – If the repair is set to ‘!’ and there are any NaN values found.