lace.Engine.predict
- Engine.predict(target: str | int, given: Dict[str | int, object] | None = None, state_ixs: List[int] | None = None, with_uncertainty: bool = True)
Predict a single target from a conditional distribution.
Uncertainty is the normalized mean total variation distance between each state’s predictive distribution and the average predictive distribution.
- Parameters:
target (column index) – The column to predict
given (Dict[column index, value], optional) – Column -> Value dictionary describing observations. Note that columns can either be indices (int) or names (str)
state_ixs (List[int], optional) – An optional list specifying which states should be used in the prediction. If None (default), use all states.
with_uncertainty (bool, optional) – if
True
(default), return the uncertainty
- Returns:
pred (value) – The predicted value
unc (float, optional) – The uncertainty
Examples
Predict whether an animal swims and return uncertainty
>>> from lace.examples import Animals >>> animals = Animals() >>> animals.predict("swims") (0, 0.03782005724890601)
Predict whether an animal swims given that it has flippers
>>> animals.predict("swims", given={"flippers": 1}) (1, 0.08920133574559677)
Let’s confuse lace and see what happens to its uncertainty. Let’s predict whether an non-water animal with flippers swims
>>> animals.predict("swims", given={"flippers": 1, "water": 0}) (0, 0.23777388425463844)
If you want to save time and you do not care about quantifying your epistemic uncertainty, you don’t have to compute uncertainty.
>>> animals.predict("swims", with_uncertainty=False) 0