plot_network: Plot Neural Network Architecture

View source: R/plot_network.R

plot_networkR Documentation

Plot Neural Network Architecture

Description

Plots the architecture of a feed-forward multilayer perceptron, showing input, hidden, and output layers in a visually enhanced layout.

Usage

plot_network(
  object,
  max_neurons = 20,
  show_connections = TRUE,
  neuron_cex = 2.2,
  label_cex = 0.9,
  main = "Neural Network Architecture",
  ...
)

Arguments

object

A fitted "metann" object or an MLP architecture object.

max_neurons

Maximum number of neurons to display per layer. If a layer has more neurons than this value, only a subset is displayed and the layer is annotated.

show_connections

Logical. If TRUE, connections between adjacent layers are drawn.

neuron_cex

Size of neuron circles.

label_cex

Size of text labels.

main

Main title of the plot.

...

Additional graphical arguments.

Value

The input object invisibly.

Examples

fit <- met_mlp(
  formula = Petal.Width ~ Sepal.Length + Sepal.Width + Petal.Length,
  data = iris,
  hidden_layers = c(5),
  optimizer = optimizer_pso(pop_size = 10, max_iter = 10),
  seed = 123,
  verbose = FALSE
)

plot_network(fit)

metANN documentation built on May 16, 2026, 1:06 a.m.