innovate.predict
All current Python definitions
View source · Source file SHA-256: 522871fe0b61b840b5f85b8f278beb2b79c7afd68645265ae3a68983d56d74e4
Signature
Section titled “Signature”def predict( model: str, data: pl.DataFrame | pl.LazyFrame, parameters: dict[str, float], *, model_options: dict[str, Any] | None = None, quantity: str = 'level', covariate_rate_columns: dict[str, str] | None = None,) -> pl.DataFrame: ...Append native predictions without changing the input row order.
Input columns are retained in the returned table. A LazyFrame is collected at
execution and IPC transport copies buffers. Numeric time and parameters must
use consistent caller-selected units. A rate can be signed for models with
declining levels; it is not automatically a measure of gross incidence.
Native derivatives use level units per unit of time, even on an irregular
grid. They are instantaneous rates, not counts integrated over the gap
between two rows.
Parameters
Section titled “Parameters”model: Native model key, such asbassorlogistic.data: Polars table containing a nonempty, finite, strictly increasing numerictimecolumn without nulls, plus any declared covariates.parameters: Finite parameter values keyed by the selected model’s native parameter names. Parameters are not inferred or estimated here.model_options: Constructor options for the selected model;Nonemeans an empty mapping. Declaredcovariatesname columns indata.quantity:"level"(default) for levels or"rate"for native derivatives. The selected model must supply the requested quantity.covariate_rate_columns: Optional mapping from every declared Logistic control name to its numeric derivative column indata. Supported only for Logistic rate predictions with declared covariates.
Returns
Section titled “Returns”A new DataFrame with the original columns and predictions. Scalar output
adds prediction or rate; multi-series output uses numbered names
such as prediction_1 or rate_1. Output width follows the model.
Raises
Section titled “Raises”ValueError: If native validation or prediction fails, required columns are missing or invalid, output names collide, or JSON values are non-finite.TypeError: If data is not a Polars frame or options are not JSON-compatible.polars.exceptions.PolarsError: If lazy collection or IPC processing fails.
Examples
Section titled “Examples”import innovateimport polars as plgrid = pl.DataFrame({"time": [0.0, 1.0, 2.0], "id": ["a", "b", "c"]})result = innovate.predict("logistic", grid, {"L": 100.0, "k": 1.0, "x0": 1.0})assert result["id"].to_list() == ["a", "b", "c"]assert result["prediction"][1] == 50.0