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:
|
classifier |
A character string specifying which classifier to use. Options include:
|
... |
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:
Best hyperparameters selected during the tuning process.
The final trained model.
Performance metrics (AUC) on the training or validation data, depending on the tuning method.
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