A custom model definition that lets caret::train() tune, resample
and evaluate bHIVE classifiers.
Details
Pass bHIVEmodel as the method of caret::train().
Training fits bHIVE with the tuned nAntibodies,
beta and epsilon. Further arguments given to
caret::train() (for example maxIter, scale or
immunology modules) are passed on to bHIVE(). Progress output is
off unless verbose = TRUE is passed. Prediction labels each new
observation with the class of its best-matching antibody, using the fitted
AINet model, so new data gets the same scaling and kernel as
the training data.
caret requires column names on x.
Components
label"Artificial Immune Network (bHIVE)".
library"bHIVE".
type"Classification".
parametersThe tunable parameters:
nAntibodies(initial antibody count),beta(clone multiplier) andepsilon(suppression threshold).gridfunction(x, y, len, search). A default tuning grid, regular (search = "grid") or random.fitfunction(x, y, wts, param, lev, last, classProbs, ...). FitsbHIVE()and returns its result.predictfunction(modelFit, newdata, submodels). Returns a factor of predicted classes.probNULL. Class probabilities are not implemented, socaret::train()warns and continues ifclassProbs = TRUE.
Examples
bHIVEmodel$label
#> [1] "Artificial Immune Network (bHIVE)"
bHIVEmodel$parameters
#> parameter class label
#> 1 nAntibodies numeric Number of Antibodies
#> 2 beta numeric Clone Multiplier
#> 3 epsilon numeric Epsilon Threshold
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 = bHIVEmodel,
trControl = caret::trainControl(method = "cv", number = 3),
tuneGrid = data.frame(nAntibodies = 40, beta = 5, epsilon = 0.05),
maxIter = 10
)
fit
table(Predicted = predict(fit, X), Actual = y)
}
#> Loading required package: ggplot2
#> Loading required package: lattice
#>
#> Attaching package: ‘caret’
#> The following object is masked from ‘package:generics’:
#>
#> train
#> Actual
#> Predicted setosa versicolor virginica
#> setosa 50 0 0
#> versicolor 0 43 2
#> virginica 0 7 48
