| metann | R Documentation |
Trains a feed-forward multilayer perceptron using metaheuristic or gradient-based optimization algorithms. The function supports regression and classification tasks through either an x-y interface or a formula-data interface.
metann(
formula = NULL,
data = NULL,
x = NULL,
y = NULL,
architecture = NULL,
hidden_layers = NULL,
activation = "relu",
output_activation = NULL,
task = c("auto", "regression", "classification"),
optimizer = optimizer_pso(),
loss = NULL,
metrics = NULL,
seed = NULL,
verbose = TRUE
)
formula |
Optional formula specifying the model. |
data |
Optional data frame containing the variables in |
x |
Optional numeric matrix or data frame of input features. |
y |
Optional response vector or one-column matrix. |
architecture |
Optional MLP architecture created by |
|
Optional integer vector specifying hidden layer sizes.
Used when | |
activation |
Activation function used for hidden layers when
|
output_activation |
Optional activation function used for the output
layer when |
task |
One of |
optimizer |
A character string or a metANN optimizer object. |
loss |
Optional character string or metANN loss object. If |
metrics |
Optional character vector, metric object, or list of metric
objects. If |
seed |
Optional random seed. |
verbose |
Logical. If |
An object of class "metann".
Montana, D. J., and Davis, L. (1989). Training Feedforward Neural Networks Using Genetic Algorithms. Proceedings of the 11th International Joint Conference on Artificial Intelligence, 762–767.
Ilonen, J., Kamarainen, J.-K., and Lampinen, J. (2003). Differential Evolution Training Algorithm for Feed-Forward Neural Networks. Neural Processing Letters, 17, 93–105. doi:10.1023/A:1022995128597
Karaboga, D., and Ozturk, C. (2009). Neural Networks Training by Artificial Bee Colony Algorithm on Pattern Classification. Neural Network World, 19(3), 279–292.
Mirjalili, S. (2015). How Effective is the Grey Wolf Optimizer in Training Multi-Layer Perceptrons. Applied Intelligence, 43, 150–161. doi:10.1007/s10489-014-0645-7
Dilber, B., and Ozdemir, A. F. (2026). A novel approach to training feed-forward multi-layer perceptrons with recently proposed secretary bird optimization algorithm. Neural Computing and Applications, 38(5). doi:10.1007/s00521-026-11874-x
fit <- metann(
formula = Petal.Width ~ Sepal.Length + Sepal.Width + Petal.Length,
data = iris,
hidden_layers = c(5),
optimizer = optimizer_pso(pop_size = 10, max_iter = 20),
loss = "mse",
metrics = c("rmse", "mae", "r2"),
seed = 123,
verbose = FALSE
)
fit
iris_bin <- iris
iris_bin$IsSetosa <- factor(
ifelse(iris_bin$Species == "setosa", "setosa", "other")
)
fit_class <- metann(
formula = IsSetosa ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width,
data = iris_bin,
hidden_layers = c(5),
optimizer = optimizer_pso(pop_size = 10, max_iter = 20),
seed = 123,
verbose = FALSE
)
fit_class
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.