View source: R/patient-level_modeling.R
tof_predict | R Documentation |
This function uses a trained 'tof_model' to make predictions on new data.
tof_predict(
tof_model,
new_data,
prediction_type = c("response", "class", "link", "survival curve")
)
tof_model |
A 'tof_model' trained using |
new_data |
A tibble of new observations for which predictions should be made. If new_data isn't provided, predictions will be made for the training data used to fit the model. |
prediction_type |
A string indicating which type of prediction should be provided by the model:
|
A tibble
with a single column ('.pred') containing
the predictions or, for multiclass models with 'prediction_type' == "response",
a tibble with one column for each class. Each row in the output corresponds to a row in 'new_data' (
or, if ‘new_data' is not provided, to a row in the 'tof_model'’s training data).
In the latter case, be sure to check 'tof_model$training_data' to confirm the
order of observations, as the resampling procedure can change their ordering
relative to the original input data.
Other modeling functions:
tof_assess_model()
,
tof_create_grid()
,
tof_split_data()
,
tof_train_model()
feature_tibble <-
dplyr::tibble(
sample = as.character(1:100),
cd45 = runif(n = 100),
pstat5 = runif(n = 100),
cd34 = runif(n = 100),
outcome = (3 * cd45) + (4 * pstat5) + rnorm(100)
)
new_tibble <-
dplyr::tibble(
sample = as.character(1:20),
cd45 = runif(n = 20),
pstat5 = runif(n = 20),
cd34 = runif(n = 20),
outcome = (3 * cd45) + (4 * pstat5) + rnorm(20)
)
split_data <- tof_split_data(feature_tibble, split_method = "simple")
# train a regression model
regression_model <-
tof_train_model(
split_data = split_data,
predictor_cols = c(cd45, pstat5, cd34),
response_col = outcome,
model_type = "linear"
)
# apply the model to new data
tof_predict(tof_model = regression_model, new_data = new_tibble)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.