Skip to contents

Binds each graph input to data frame columns and reads one output as each row's mean, with a family for predict_distribution() (an imported network carries no parameter uncertainty and the file no family, so the draws are process draws around the predicted means).

Usage

onnx_predictor(
  model,
  family,
  inputs,
  output = 1,
  scale = c("mean", "link"),
  link = NULL,
  dispersion = 1,
  theta = NULL,
  power = NULL
)

Arguments

model

An onnx_model.

family

The family of the predictive draws ("poisson", "gamma", ...).

inputs

A named list: each graph input's column names. A rank-2 input takes its columns in order ([rows, columns]), a rank-1 input one column; an integer input (an embedding's category codes) must hold whole numbers.

output

Which output is the mean (1 for the first).

scale

"mean": the output is the mean. "link": the output is on the link scale and added to the offset, mu = g^-1(offset + output).

The link for scale = "link"; NULL for the log link for the gamma, inverse Gaussian and Tweedie and the canonical link otherwise.

dispersion

The family's dispersion for predictive draws.

theta, power

The negative binomial's theta or the Tweedie power.

Value

An onnx_predictor. Use stats::predict() and predict_distribution() with a data frame holding the bound columns (and offset = for scale = "link").