larch.model.troubleshooting.chosen_but_not_available#

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

Check if some observations are chosen but not available.

Alternatives that are unavailable have their utility values set to negative infinity. If even one observation is chosen but not available, the model log-likelihood will nominally be negative infinity regardless of the values of any other parameters. Note that some compute engines (e.g. JAX) may not actually return negative infinity log likelihoods due to clipping of extreme values.

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

  • repair ({'?', '+', '-', '!'}, default '?') – How to repair the data. The plus (‘+’) will make the conflicting alternatives available, overriding the availability status. The minus (‘-’) will make them not chosen (possibly leaving no chosen alternative). A question mark (‘?’) effects no repair, and simply emits a warning without interrupting program execution. An exclamation mark will raise an error if there are any conflicts.

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

Returns:

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

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

Raises:

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