Artificial Neural Networks (ANN)

Lesson4 min readMachine Learning

An artificial neural network (ANN) is a machine-learning model made of layers of connected units called neurons. Each neuron takes inputs, multiplies them by learned weights, adds a bias and passes the result through a non-linear activation function. By stacking layers, a network can learn complex, non-linear relationships between inputs (price, promotion, weather, past sales) and an output such as next week’s demand.

Structure

  • Input layer: one node per feature.
  • Hidden layers: neurons that learn intermediate patterns.
  • Output layer: the prediction (one number for forecasting, class probabilities for classification).

One neuron, calculated by hand

A neuron receives two inputs: a price index x1 = 0.5 and a promotion flag x2 = 1. The learned weights are 0.8 and 0.4 and the bias is −0.2.

z = 0.8×0.5 + 0.4×1 − 0.2 = 0.4 + 0.4 − 0.2 = 0.6

Activation Formula Output for z = 0.6
ReLU max(0, z) 0.60
Sigmoid 1 ÷ (1 + e^−z) 0.646
Tanh (e^z − e^−z) ÷ (e^z + e^−z) 0.537

If the output layer is a single linear unit with weight 150 and bias 20, a ReLU hidden output of 0.6 gives a forecast of 150 × 0.6 + 20 = 110 units. Real networks have many neurons, and training adjusts all the weights together.

How a network learns

  1. Forward pass: compute predictions from the inputs.
  2. Loss: measure the error (for example mean squared error).
  3. Backpropagation: calculate how each weight contributed to the error.
  4. Gradient descent: adjust the weights a little in the direction that reduces error.
  5. Repeat over many passes (epochs), monitoring error on separate validation data to stop before over-fitting.

Supply chain uses

Use Example
Demand forecasting Many items with promotions, price and external drivers
Lead-time and ETA prediction Estimating shipment delay risk
Image recognition Damage detection, pallet counting, quality inspection
Anomaly detection Fraud, unusual orders, sensor faults
Text and document processing Reading invoices and supplier emails

Strengths and limits

Strengths Limits
Learns complex non-linear patterns and interactions Needs a lot of data and tuning
Handles many inputs, including images and text A “black box”: hard to explain to planners
Can forecast many series with one model Can over-fit, and may do no better than simple methods on short, smooth series

Good practice

  • Scale (normalize) the inputs.
  • Split data by time, with training before validation before test.
  • Compare with simple benchmarks such as Holt-Winters or random forests.
  • Start with a small network and add complexity only if it helps held-out accuracy.
  • Monitor accuracy in production, and retrain as demand patterns change.

Common mistakes

  • Over-fitting the training data.
  • Using future information as a feature (leakage).
  • Choosing a neural network when a simple model would do.
  • No plan to explain forecasts to the business.

Key takeaways

  • A neuron computes a weighted sum plus bias, then an activation function.
  • Networks learn by adjusting weights to reduce error on training data.
  • Use them where data is rich and patterns are non-linear, and always validate against simple baselines.

Frequently asked questions

What is an artificial neural network?

An ANN is a machine-learning model of layers of connected neurons that learns weights from data to map inputs to outputs, capturing complex non-linear relationships.

How does a neuron calculate its output?

It computes a weighted sum of its inputs plus a bias, then applies an activation function such as ReLU or sigmoid.

What is backpropagation?

The method that calculates how much each weight contributed to the prediction error so that gradient descent can adjust the weights to reduce it.

When should I use a neural network instead of a statistical model?

When you have a lot of data, many drivers or complex non-linear patterns, and the network beats simple benchmarks on held-out data.

What is over-fitting?

When a model learns the noise in the training data and performs poorly on new data. It is controlled with validation data, simpler models and early stopping.