
Multilayered honeycombHIVE classification model for caret
Source:R/honeycombHiVEmodel.R
honeycombHIVEmodel.RdA custom model definition that lets caret::train() tune, resample
and evaluate honeycombHIVE classifiers with gradient-based
refinement.
Details
Training runs honeycombHIVE(refine = TRUE) with the tuned
parameters. Further arguments given to caret::train() are passed on
to honeycombHIVE(). Progress output is off unless
verbose = TRUE is passed. Prediction uses the fitted
AINet model of the final layer. caret requires column names
on x. Class probabilities are not implemented (prob = NULL).
Parameters
nAntibodies: Number of initial antibodies per layer.beta: Clone multiplier controlling the number of clones per antibody.epsilon: Threshold for network suppression to remove redundant antibodies.layers: Number of hierarchical layers.refineOptimizer: Optimizer for gradient-based refinement ("sgd", "momentum", "adagrad", "adam" or "rmsprop").refineSteps: Number of gradient update steps in refinement.refineLR: Learning rate for refinement.
Examples
if (requireNamespace("caret", quietly = TRUE)) {
X <- as.matrix(iris[, 1:4])
y <- iris$Species
set.seed(42)
fit <- caret::train(
x = X, y = y, method = honeycombHIVEmodel,
trControl = caret::trainControl(method = "cv", number = 3),
tuneGrid = data.frame(nAntibodies = 30, beta = 5, epsilon = 0.05,
layers = 2, refineOptimizer = "adam",
refineSteps = 3, refineLR = 0.01),
maxIter = 10
)
fit
table(Predicted = predict(fit, X), Actual = y)
}
#> Actual
#> Predicted setosa versicolor virginica
#> setosa 50 0 0
#> versicolor 0 37 5
#> virginica 0 13 45