Learn R Programming

E2E (version 0.1.2)

mlp_dia: Train a Multi-Layer Perceptron (Neural Network) Model for Classification

Description

Trains a Multi-Layer Perceptron (MLP) neural network model using caret::train for binary classification.

Usage

mlp_dia(X, y, tune = FALSE, cv_folds = 5)

Value

A caret::train object representing the trained MLP model.

Arguments

X

A data frame of features.

y

A factor vector of class labels.

tune

Logical, whether to perform hyperparameter tuning using caret's default grid (if TRUE) or a fixed value (if FALSE).

cv_folds

An integer, the number of cross-validation folds for caret.

Examples

Run this code
# \donttest{
set.seed(42)
n_obs <- 50
X_toy <- data.frame(
  FeatureA = rnorm(n_obs),
  FeatureB = runif(n_obs, 0, 100)
)
y_toy <- factor(sample(c("Control", "Case"), n_obs, replace = TRUE),
                levels = c("Control", "Case"))

# Train the model
mlp_model <- mlp_dia(X_toy, y_toy)
print(mlp_model)
# }

Run the code above in your browser using DataLab