Package 'innovate.R'

Title: R Bindings Over the Functional Kernel
Description: Provides thin R bindings for the Innovate functional kernel. The package constructs versioned JSON request envelopes, invokes the shared Python bridge, and converts kernel responses into R-native objects.
Authors: Dylan Mordaunt [aut, cre]
Maintainer: Dylan Mordaunt <[email protected]>
License: Apache License (>= 2)
Version: 0.5.0
Built: 2026-05-17 06:26:48 UTC
Source: https://github.com/edithatogo/innovate

Help Index


R bindings for the Innovate kernel

Description

Thin R bindings for the Innovate functional kernel. The package exposes request builders, bridge dispatch helpers, response conversion, and diagnostics helpers without duplicating model logic in R.

Details

The package is organized around the shared Innovate kernel schema. The exported helpers build request lists, call the Python-backed kernel bridge, and convert JSON responses into R-native arrays, data frames, lists, and conditions.

Use kernel_discover_models() to inspect available model metadata when the bridge runtime is available. Use kernel_request() plus one of the operation helpers for fit_model, predict_model, simulate_model, summarize_model, or diagnose_model requests.

Examples in the reference manual avoid launching the bridge so they remain deterministic in offline and CRAN-style checks.

See Also

kernel_schema_version, kernel_request, kernel_call, kernel_response_to_r, kernel_discover_models, kernel_fit_model, kernel_predict_model, kernel_simulate_model, kernel_summarize_model, kernel_diagnose_model, kernel_extract_diagnostics

Examples

kernel_schema_version()

request <- kernel_request(
  operation = "summarize_model",
  model_key = "logistic",
  payload = list(inputs = list(time = c(0, 1), observed = c(0.2, 0.5)))
)
names(request)

Innovate kernel bridge helpers

Description

Construct Innovate kernel requests, invoke the shared Python kernel bridge, and convert kernel responses into ordinary R objects.

Usage

kernel_schema_version()

kernel_request(operation, model_key = NULL, payload = list(), metadata = list(),
  schema_version = KERNEL_SCHEMA_VERSION)

kernel_call(request)

kernel_response_to_r(response)

kernel_discover_models()

kernel_fit_model(request)

kernel_predict_model(request)

kernel_simulate_model(request)

kernel_summarize_model(request)

kernel_diagnose_model(request)

kernel_extract_diagnostics(result)

Arguments

operation

A non-empty scalar character kernel operation name, such as "discover_models", "fit_model", "predict_model", "simulate_model", "summarize_model", or "diagnose_model".

model_key

A scalar character model key. Required for all operations except "discover_models".

payload

A named list containing the operation-specific request payload.

metadata

A named list containing optional request metadata.

schema_version

A scalar character kernel schema version. Defaults to the package's active schema version.

request

A kernel request list, normally created by kernel_request().

response

A decoded kernel response list, normally returned by kernel_call().

result

A converted kernel result object returned by kernel_response_to_r() or one of the operation helpers.

Details

The R package is intentionally a thin adapter over the stable Innovate functional kernel contract. It does not reimplement model semantics. Execution is delegated to the shared Python kernel bridge, while this package handles request construction, process dispatch, error conversion, and response conversion.

kernel_call() writes a temporary JSON request, invokes the bridge script, and reads the JSON response. By default it uses uv run python when uv is available, otherwise it falls back to python3. Set the INNOVATE_PYTHON_COMMAND environment variable to override the launcher.

If the kernel response contains an error payload, kernel_response_to_r() signals an innovate_kernel_error condition. The condition object contains the original kernel error payload in its error field and the full response in its response field.

Value

  • kernel_schema_version() returns a scalar character schema version.

  • kernel_request() returns a request list with schema_version, operation, model_key, payload, and metadata fields.

  • kernel_call() returns a decoded response list from the Python bridge.

  • kernel_response_to_r() and the operation helpers return converted R objects. Kernel arrays become arrays, table-shaped payloads become data frames, discovery payloads become data frames, and nested payloads remain named lists.

  • kernel_extract_diagnostics() returns a diagnostics list when the result exposes one.

See Also

innovate.R-package

Examples

kernel_schema_version()

request <- kernel_request(
  operation = "predict_model",
  model_key = "logistic",
  payload = list(
    state = list(
      model_key = "logistic",
      parameters = list(L = 1, k = 0.5, x0 = 2)
    ),
    inputs = list(time = c(0, 1, 2))
  )
)
request$operation
request$model_key

response <- list(
  schema_version = "1.0",
  operation = "predict_model",
  result = list(shape = list(3L), dtype = "float64", values = list(0.1, 0.2, 0.4)),
  error = NULL,
  metadata = list()
)
values <- kernel_response_to_r(response)
values
attr(values, "kernel_operation")

summary_result <- list(
  diagnostics = list(
    support_level = "supported",
    provenance = "deterministic"
  )
)
kernel_extract_diagnostics(summary_result)