Qu

predict

Builtin index · Statistics & ML

result = model.predict(Xnew)

Input: Xnew · Output: result

What it is

Applies a fitted model Record model to a new M-row (same D columns as it was fitted on) matrix or vector Xnew.

Overloads

Xnew can be vector or Record.

2 forms. Each carries its own inputs, outputs and worked example — pick the tab for the one you are calling.

CodeInputOutputDescription
result = model.predict(Xnew)
Xnew vectornot documented yet
result vector or Record
—

Examples

Written for this form and run by the build -- the output below is what the engine actually produced.

Xp = randn(30, 2, seed = 71)
yp = Xp * [1.0, -1.0] + 0.05 * randn(30, seed = 72)
mp = ols_model(Xp, yp)
print("model .predict returns a prediction vector: {round(mp.predict(Xp[0:1, :]), 3)}")
output
model .predict returns a prediction vector: [-1.1, -1.639]
CodeInputOutputDescription
result = model.predict(Xnew)
Xnew Record or vectornot documented yet
result vector or Record
state.predict(...) on a Kalman/EKF/UKF/particle state instead returns a whole new state Record -- the time-update step, not a prediction vector. The Estimation section below covers the filter-specific argument shapes.

Examples

Written for this form and run by the build -- the output below is what the engine actually produced.

s0 = kalman_init([0.0, 0.0], [1.0, 0, 0, 1.0] as matrix(2, 2))
F = [1, 0, 1, 1] as matrix(2, 2)
Q = [0.01, 0, 0, 0.01] as matrix(2, 2)
s1 = s0.predict(F, Q)
print("filter .predict returns a new state Record; its x field: {round(s1.x, 3)}")
output
filter .predict returns a new state Record; its x field: [0, 0]

How it works

predict(model, Xnew) — callable as model.predict(Xnew) via the existing recv.method(args) sugar. Dispatches on ModelHandle.kind; see each _model constructor's own doc comment for what each kind's prediction means. For the estimation-theory family ("kalman"/"particle_filter" model kinds), predict means the filter's own time update instead of the regression-style predict(model, Xnew) below — see estimation_predict's own doc comment for the full state.predict(...) contract (linear/EKF/UKF/particle filter, all reached through this one name).

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.