neuralnet() — Neural networks
Stacks simple bending units into a flexible function.
neuralnet(hidden_units, X, y)
Key idea
- A hidden unit is a tiny building block that makes one smooth bend; summing many of them builds a flexible curve. (e.g. 8 units -> 8 bends added up)
- The weights (numbers scaling each input) are learned by gradient descent using backpropagation.
- More units or layers = more flexibility and more risk of overfitting (memorising noise).
- With enough hidden units a network can approximate almost any shape.
Definition
y^=∑hwhtanh(ah+bhx)+w0
- h
- a hidden unit
- tanh
- the activation that bends the input
- wh,bh
- weights learned by gradient descent
In plain words
Take a bunch of simple curved building blocks, slide and stretch each one, and stack them until they trace any shape you like.
Where you'd use it
- Image, speech, and text tasks where features interact in complex ways.
- Any rich, large dataset where flexible non-linear models shine.
- The foundation of modern deep learning and large language models.
Frequently asked questions
- Do I need to scale the inputs?
- Yes — and you usually need plenty of data; small sets overfit badly.