Learn R Programming

daltoolboxdp (version 1.2.737)

skcla_mlp: Multi-layer Perceptron Classifier

Description

Implements classification using a multi-layer perceptron (MLP). Wraps scikit-learn's MLPClassifier through reticulate.

Usage

skcla_mlp(
  attribute,
  slevels,
  hidden_layer_sizes = c(100),
  activation = "relu",
  solver = "adam",
  alpha = 1e-04,
  batch_size = "auto",
  learning_rate = "constant",
  learning_rate_init = 0.001,
  power_t = 0.5,
  max_iter = 200,
  shuffle = TRUE,
  random_state = NULL,
  tol = 1e-04,
  verbose = FALSE,
  warm_start = FALSE,
  momentum = 0.9,
  nesterovs_momentum = TRUE,
  early_stopping = FALSE,
  validation_fraction = 0.1,
  beta_1 = 0.9,
  beta_2 = 0.999,
  epsilon = 1e-08,
  n_iter_no_change = 10,
  max_fun = 15000
)

Value

A skcla_mlp classifier object.

Arguments

attribute

Target attribute name for model building

slevels

List of possible values for classification target

hidden_layer_sizes

Number of neurons in each hidden layer

activation

Activation function for hidden layer ('identity', 'logistic', 'tanh', 'relu')

solver

The solver for weight optimization ('lbfgs', 'sgd', 'adam')

alpha

L2 penalty (regularization term) parameter

batch_size

Size of minibatches for stochastic optimizers

learning_rate

Learning rate schedule for weight updates

learning_rate_init

Initial learning rate used

power_t

Exponent for inverse scaling learning rate

max_iter

Maximum number of iterations

shuffle

Whether to shuffle samples in each iteration

random_state

Seed for random number generation

tol

Tolerance for optimization

verbose

Whether to print progress messages to stdout

warm_start

Whether to reuse previous solution

momentum

Momentum for gradient descent update

nesterovs_momentum

Whether to use Nesterov's momentum

early_stopping

Whether to use early stopping

validation_fraction

Proportion of training data for validation

beta_1

Exponential decay rate for estimates of first moment vector

beta_2

Exponential decay rate for estimates of second moment vector

epsilon

Value for numerical stability in adam

n_iter_no_change

Maximum number of epochs to not meet tol improvement

max_fun

Maximum number of loss function calls

Details

Neural Network Classifier

References

Bishop, C. M. (1995). Neural Networks for Pattern Recognition.

Examples

Run this code
if (FALSE) {
data(iris)

# 1) Define MLP architecture (two hidden layers)
clf <- skcla_mlp(attribute = 'Species', slevels = levels(iris$Species), 
                hidden_layer_sizes = c(32, 16))

# 2) Fit and predict
clf <- daltoolbox::fit(clf, iris)
pred <- predict(clf, iris)
table(pred, iris$Species)
}

# More examples:
# https://github.com/cefet-rj-dal/daltoolboxdp/blob/main/examples/skcla_mlp.md

Run the code above in your browser using DataLab