Learn R Programming

specmine (version 1.0)

train_and_predict: Train and predict

Description

Train a model and predict new unlabeled samples with that model.

Usage

train_and_predict(dataset, new.samples, column.class, model, validation, num.folds = 10, num.repeats = 10, tunelength = 10, tunegrid = NULL, metric = NULL, summary.function =  defaultSummary)

Arguments

dataset
list representing the dataset from a metabolomics experiment.
new.samples
dataframe with new samples to predict the class label.
column.class
metadata column class.
model
model to be used in training.
validation
validation method.
num.folds
number of folds in cross validation.
num.repeats
number of repeats.
tunelength
number of levels for each tuning parameters.
tunegrid
dataframe with possible tuning values.
metric
metric used to evaluate the model's performance. Can be "Accuracy" or "ROC".
summary.function
summary function. For "ROC" the multiClassSummary function must be used.

Value

Returns a list with the training result and the predictions result.

Examples

Run this code
  ## Example of training and predicting
  data(cachexia)
  result = train_and_predict(cachexia, new.samples = cachexia$data,
	 "Muscle.loss", "pls", "cv")

Run the code above in your browser using DataLab