tuneandtrain {RobustPrediction}R Documentation

Tune and Train Classifier

Description

This function tunes and trains a classifier using a specified tuning method. Depending on the method chosen, the function will either perform RobustTuneC, external tuning, or internal tuning.

Usage

tuneandtrain(data, dataext = NULL, tuningmethod, classifier, ...)

Arguments

data

A data frame containing the training data. The first column should be the response variable, which must be a factor for classification tasks. The remaining columns should be the predictor variables. Ensure that the data is properly formatted, with no missing values.

dataext

A data frame containing the external validation data, required only for the tuning methods "robusttunec" and "ext". Similar to the 'data' argument, the first column should be the response variable (factor), and the remaining columns should be the predictors. If 'tuningmethod = "int"', this parameter is ignored.

tuningmethod

A character string specifying which tuning approach to use. Options are:

  • "robusttunec": Uses robust tuning that combines internal and external validation for parameter selection.

  • "ext": Uses external validation data for tuning the parameters.

  • "int": Internal cross-validation is used to tune the parameters without any external data.

classifier

A character string specifying which classifier to use. Options include:

  • "boosting": Boosting algorithms for improving weak classifiers.

  • "rf": Random Forest for robust decision tree-based models.

  • "lasso": Lasso regression for feature selection and regularization.

  • "ridge": Ridge regression for regularization.

  • "svm": Support Vector Machines for high-dimensional classification.

...

Additional parameters to be passed to the specific tuning and training functions. These can include options such as the number of trees for Random Forest, the number of folds for cross-validation, or hyperparameters specific to the chosen classifier.

Value

A list containing the results of the tuning and training process, which typically includes:

Examples

# Load sample data
data(sample_data_train)
data(sample_data_extern)

# Example usage: Robust tuning with Ridge classifier
result_boosting <- tuneandtrain(sample_data_train, sample_data_extern, 
  tuningmethod = "robusttunec", classifier = "ridge")
result_boosting$best_lambda
result_boosting$best_model
result_boosting$final_auc

# Example usage: Internal cross-validation with Lasso classifier
result_lasso <- tuneandtrain(sample_data_train, tuningmethod = "int", 
  classifier = "lasso", maxit = 120000, nlambda = 200, nfolds = 5)
result_lasso$best_lambda
result_lasso$best_model
result_lasso$final_auc
result_lasso$active_set_Train

[Package RobustPrediction version 0.1.7 Index]