A minimal, dependency-free toy prediction model for the ModelsCloud platform. It predicts a risk from three predictors using a fixed-coefficient logistic score — illustrative only, not a real risk model.
Predictors
sex— patient sex, coded0= female,1= male.age— age in years.marker_value— a generic numeric biomarker; higher values raise the predicted risk.
It implements the standard prediction-model API:
| Function | Role |
|---|---|
model_run(model_input) |
Predict for a table of patients (synchronous) |
get_sample_input() |
Return an example input dataset |
model_run() also draws a barplot of the predicted risks as a side effect.
On the server OpenCPU captures this plot automatically, so it can be retrieved
with modelscloud::get_plots().
library(modelscloud)
# Public testing key — fine to use for trying out the examples collection
connect_to_model("examples/toymodel1",
access_key = "23b7bab3-118e-4516-b53c-91bca8e0082d")
sample <- get_sample_input()
result <- model_run(sample)
# Retrieve the barplot the model produced
get_plots(result) # list available plots
img <- get_plots(result, id = 1) # retrieve the barplot
plot(img) # display itPrediction models are typically called synchronously in this way.