Skip to main content

MLPClassifier

A dense feed-forward neural network for classification, trained with mini-batch Adam (or SGD) on the cross-entropy loss.

Algorithm

Forward and backward passes are expressed entirely as Eigen matrix operations. The output layer is sigmoid (binary) or softmax (multiclass). Adam moment vectors persist across partial_fit calls for warm-started streaming.

Constructor

Skigen::MLPClassifier<Scalar> model(std::vector<int> hidden_layer_sizes = {100}, Activation = ReLU, Solver = Adam, ...);

Parameters

ParameterDefaultDescription
hidden_layer_sizes{100}Units per hidden layer.
activationReLUIdentity, Logistic, Tanh, ReLU.
solverAdamAdam or SGD (LBFGS reserved).
alpha1e-4L2 regularisation strength.
learning_rate_init1e-3Initial step size.
max_iter200Maximum epochs.
random_statenulloptSeed.

Methods

MethodDescription
fit(X, y)Train the network.
predict(X)Class labels.
predict_proba(X)Softmax/sigmoid outputs.
score(X, y)Mean accuracy.

Fitted Attributes

AccessorDescription
coefs()Per-layer weight matrices.
intercepts()Per-layer bias vectors.
n_iter_run()Epochs actually run.

Example

Skigen::MLPClassifier<double> mlp({64, 32});
mlp.fit(X, y);
auto preds = mlp.predict(X_test);

Known Gaps

solver = LBFGS is explicitly feature-gated for v1.2.0. Constructing an MLPClassifier with MLPSolver::LBFGS throws a clear std::invalid_argument; Adam and SGD remain supported.

Verified against scikit-learn

This estimator is checked by the parity suite. See the generator tests/parity/generate_neural_network_reference.py and the reference fixtures in tests/parity/data/mlp_classifier/, exercised by tests/parity/parity_neural_network.cpp.

API Reference

For full signatures see the MLPClassifier API Reference.