Public methods
Method new()
Create the trans_classifier object.
Usage
trans_classifier$new(
dataset = NULL,
x.predictors = "all",
y.response = NULL,
n.cores = 1
)
Arguments
dataset
the object of microtable
Class.
x.predictors
default "all"; character string or data.frame; a character string represents selecting the corresponding data from microtable$taxa_abund;
data.frame represents other customized data. See the following available options and description:
- 'all'
use all the taxa stored in microtable$taxa_abund
- 'Genus'
use Genus level table in microtable$taxa_abund, or other specific taxonomic rank
- other input
must be a data.frame; It should be have the same format with the data.frame in microtable$taxa_abund, i.e. rows are features;
cols are samples with same names in sample_table
y.response
default NULL; the response variable in sample_table.
n.cores
default 1; the CPU thread used.
Returns
data_feature and data_response in the object.
Examples
\donttest{
data(dataset)
t1 <- trans_classifier$new(
dataset = dataset,
x.predictors = "all",
y.response = "Group")
}
Method cal_feature_sel()
Perform feature selection.
Usage
trans_classifier$cal_feature_sel(
boruta.maxRuns = 300,
boruta.pValue = 0.01,
boruta.repetitions = 4,
...
)
Arguments
boruta.maxRuns
default 300; maximal number of importance source runs; passed to the maxRuns parameter in Boruta function of Boruta package.
boruta.pValue
default 0.01; p value passed to the pValue parameter in Boruta function of Boruta package.
boruta.repetitions
default 4; repetition runs for the feature selection.
...
parameters pass to Boruta function of Boruta package.
Returns
optimized data_feature in the object.
Examples
\donttest{
t1$cal_feature_sel(boruta.maxRuns = 300, boruta.pValue = 0.01)
}
Method cal_split()
Split data for training and testing.
Usage
trans_classifier$cal_split(prop.train = 3/4)
Arguments
prop.train
default 3/4; the ratio of the dataset used for the training.
Returns
optimized data_feature in the object.
Examples
\donttest{
t1$cal_split(prop.train = 3/4)
}
Method set_trainControl()
Set trainControl for the following training.
Usage
trans_classifier$set_trainControl(method = "repeatedcv", ...)
Arguments
method
default 'repeatedcv'; the method used in trainControl function of caret package.
...
parameters pass to trainControl function of caret package.
Returns
trainControl in the object.
Examples
\dontrun{
t1$set_trainControl()
}
Method cal_train()
Run the training.
Usage
trans_classifier$cal_train(
method = "rf",
metric = "Accuracy",
max.mtry = 2,
max.ntree = 200,
...
)
Arguments
method
default "rf"; representing the random forest method; see method in train function of caret package.
metric
default "Accuracy"; see metric in train function of caret package.
max.mtry
default 2; maximum mtry.
max.ntree
default 200; Number of trees to grow; pass to the ntree parameter of randomForest function in randomForest package.
...
parameters pass to train function of caret package.
Returns
res_train in the object.
Examples
\dontrun{
t1$cal_train()
}
Method cal_feature_imp()
Get feature importance from the training model.
Usage
trans_classifier$cal_feature_imp(...)
Arguments
...
parameters pass to the evaluating function; If "rf" used, pass to randomForest::importance.
Returns
res_feature_imp in the object. One row for each predictor variable. The column(s) are different importance measures.
Examples
\dontrun{
t1$cal_feature_imp()
}
Method cal_predict()
Run the prediction.
Usage
trans_classifier$cal_predict(positive_class = NULL)
Arguments
positive_class
default NULL; see positive parameter in confusionMatrix function of caret package.
Returns
res_confusion_fit and res_confusion_stats stored in the object.
Examples
\dontrun{
t1$cal_predict()
}
Method plot_confusionMatrix()
Plot the cross-tabulation of observed and predicted classes with associated statistics.
Usage
trans_classifier$plot_confusionMatrix(
plot_confusion = TRUE,
plot_statistics = TRUE
)
Arguments
plot_confusion
default TRUE; whether plot the confusion matrix.
plot_statistics
default TRUE; whether plot the statistics.
Returns
ggplot object in the object.
Examples
\dontrun{
t1$plot_confusionMatrix()
}
Method cal_ROC()
Get ROC curve data and the performance data.
Usage
trans_classifier$cal_ROC(...)
Arguments
...
parameters pass to plot.performance function of ROCR package.
Returns
a list including res_perf, all_auc_perf and all_perf_table stored in the object.
Examples
\dontrun{
t1$cal_ROC()
}
Method plot_ROC()
Plot ROC curve.
Usage
trans_classifier$plot_ROC(
color_values = RColorBrewer::brewer.pal(8, "Dark2"),
...
)
Arguments
color_values
default RColorBrewer::brewer.pal(8, "Dark2"); colors used in the plot.
...
parameters pass to geom_line function of ggplot2 package.
Returns
ggplot2 object.
Examples
\dontrun{
t1$plot_ROC(size = 1, alpha = 0.7)
}
Method clone()
The objects of this class are cloneable with this method.
Usage
trans_classifier$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.