## -----------------------------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## -----------------------------------------------------------------------------
# library(orbital)
# library(torch)
# 
# net <- nn_sequential(
#   nn_linear(4, 8),
#   nn_relu(),
#   nn_linear(8, 1)
# )
# 
# ob <- orbital(net, input_names = c("x1", "x2", "x3", "x4"))
# predict(ob, new_data)

## -----------------------------------------------------------------------------
# library(keras3)
# 
# x <- keras_model_sequential(input_shape = 4) |>
#   layer_dense(8, activation = "relu") |>
#   layer_dense(1)
# 
# ob <- orbital(x, input_names = c("x1", "x2", "x3", "x4"))

## -----------------------------------------------------------------------------
# ob <- orbital(
#   net,
#   input_names = c("x1", "x2", "x3", "x4"),
#   type = "class",
#   lvl = c("no", "yes")
# )

## -----------------------------------------------------------------------------
# ob <- orbital(net, input_names = c("x1", "x2", "x3", "x4"), output_layer = 1)
# predict(ob, new_data)
# #>   .pred_layer_1_1 .pred_layer_1_2 ... .pred_layer_1_8

## -----------------------------------------------------------------------------
# net <- list(
#   trunk = nn_sequential(
#     nn_linear(4, 8),
#     nn_relu()
#   ),
#   heads = list(
#     price = nn_sequential(nn_linear(8, 1)),
#     category = nn_sequential(nn_linear(8, 2))
#   )
# )
# 
# ob <- orbital(
#   net,
#   input_names = c("x1", "x2", "x3", "x4"),
#   mode = list(price = "regression", category = "classification"),
#   lvl = list(category = c("standard", "luxury"))
# )
# preds <- predict(ob, new_data)
# names(preds)
# #> [1] ".pred_price" ".pred_category_class"

## -----------------------------------------------------------------------------
# library(keras3)
# 
# inp <- keras_input(shape = 4L)
# trunk <- inp |> layer_dense(8, activation = "relu")
# price <- trunk |> layer_dense(1)
# category <- trunk |> layer_dense(2)
# 
# x <- keras_model(inputs = inp, outputs = list(price = price, category = category))
# 
# ob <- orbital(
#   x,
#   input_names = c("x1", "x2", "x3", "x4"),
#   mode = list(price = "regression", category = "classification"),
#   lvl = list(category = c("standard", "luxury"))
# )

