View source: R/model-engines.R
| integrate_black_box_model | R Documentation |
Integrate a controlled black-box model engine
integrate_black_box_model(
name,
fit_fun,
predict_fun,
supports = c("classification", "regression"),
probability = TRUE,
metadata = list(),
safety_declaration
)
name |
Unique name for the custom engine. |
fit_fun |
Function that fits the custom engine. |
predict_fun |
Function that generates predictions. |
supports |
Task types supported by the engine. |
probability |
Whether classification probabilities are supported. |
metadata |
Optional engine metadata. |
safety_declaration |
Named logical safety declarations. |
A controlled gp3ml_engine object containing the custom fit and prediction functions, supported task types, metadata, and explicit safety declarations.
custom_fit <- function(x, y, task, args) {
training_data <- data.frame(
.outcome = y,
x,
check.names = FALSE
)
stats::glm(
.outcome ~ .,
data = training_data,
family = stats::binomial()
)
}
custom_predict <- function(fit, newdata, type, task, ...) {
as.numeric(stats::predict(
fit,
newdata = as.data.frame(newdata),
type = "response"
))
}
engine <- integrate_black_box_model(
name = "custom_glm",
fit_fun = custom_fit,
predict_fun = custom_predict,
supports = "classification",
probability = TRUE,
safety_declaration = list(
prohibited_uses_acknowledged = TRUE,
prediction_time_inputs_only = TRUE,
group_aware_evaluation_required = TRUE
)
)
engine$name
engine$supports
engine$probability
engine$safety_declaration
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.