test_models: Test machine learning models on test data

View source: R/modelProteins.R

test_modelsR 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 model_list object from performing train_models.

split_df

A split_df object from performing split_data.

type

Type of output. Set type as "prob" (default) to output class probabilities, and "raw" to output class predictions.

save_confusionmatrix

Logical. If TRUE, a tab-delimited text file ("Confusion_matrices.txt") with confusion matrices in the long-form data format will be saved in the directory specified by file_path. See below for more details.

file_path

A string containing the directory path to save the file.

...

Additional arguments to be passed on to predict.

Details

  • test_models function uses models obtained from train_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 using roc_plot.

Value

  • probability_list: If type = "prob", a list of data frames containing class probabilities for each method in the model_list will be returned.

  • prediction_list: If type = "raw", a list of factors containing class predictions for each method will be returned.

Author(s)

Chathurani Ranathunge

See Also

  • split_df

  • train_models

  • predict

  • confusionMatrix

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)


promor documentation built on July 26, 2023, 5:39 p.m.