test_models {promor} | R Documentation |
Test machine learning models on test data
Description
This function can be used to predict test data using models generated by different machine learning algorithms
Usage
test_models(
model_list,
split_df,
type = "prob",
save_confusionmatrix = FALSE,
file_path = NULL,
...
)
Arguments
model_list |
A |
split_df |
A |
type |
Type of output. Set |
save_confusionmatrix |
Logical. If |
file_path |
A string containing the directory path to save the file. |
... |
Additional arguments to be passed on to
|
Details
-
test_models
function uses models obtained fromtrain_models
to predict a given test data set. Setting
type = "raw"
is required to obtain confusion matrices.Setting
type = "prob"
(default) will output a list of probabilities that can be used to generate ROC curves usingroc_plot
.
Value
-
probability_list
: Iftype = "prob"
, a list of data frames containing class probabilities for each method in themodel_list
will be returned. -
prediction_list
: Iftype = "raw"
, a list of factors containing class predictions for each method will be returned.
Author(s)
Chathurani Ranathunge
See Also
-
split_df
-
train_models
Examples
## Create a model_df object
covid_model_df <- pre_process(covid_fit_df, covid_norm_df)
## Split the data frame into training and test data sets
covid_split_df <- split_data(covid_model_df)
## Fit models using the default list of machine learning (ML) algorithms
covid_model_list <- train_models(covid_split_df)
# Test a list of models on a test data set and output class probabilities,
covid_prob_list <- test_models(model_list = covid_model_list, split_df = covid_split_df)
## Not run:
# Save confusion matrices in the working directory and output class predictions
covid_pred_list <- test_models(
model_list = covid_model_list,
split_df = covid_split_df,
type = "raw",
save_confusionmatrix = TRUE,
file_path = "."
)
## End(Not run)