The VikiD Truth

Knowledge base / Computing / Computer science, theory & data

Read This! | Computing | Picolisp | Picolisp Machine | Pil Sources | Linux | BASH | C-Programmming | Javascipt | Python | Scheme | Operating Systems | AssemblyLanguage | Computer Security | Firewalls | Exploitation | Social Engineering | Metasploit | Emacs | vim | Pharo Smalltalk | Databases | Networking | Machine Learning

Machine Learning

Here is the truth about machine learning: it is curve fitting with very good bookkeeping. You choose a family of functions with adjustable knobs, show it examples, and nudge the knobs until its outputs match the examples. Everything from a spam filter to a large language model is that idea, scaled up.

What it is, in plain words

Ordinary programming: you write the rules, the computer applies them to data. Machine learning: you give the computer data and the answers, and it finds the rules.

The three big families:

  1. Supervised learning – examples come with labels (this email is spam, this house sold for X). The model learns to predict the label. Regression predicts numbers; classification predicts categories.
  2. Unsupervised learning – no labels. Find structure: clusters, the main directions of variation (PCA), unusual points.
  3. Reinforcement learning – an agent acts, gets rewards, and learns a policy that earns more reward.

Since 2017 one architecture, the transformer, has taken over language, images, audio and code. Today’s large language models are transformers trained first on huge amounts of text to predict the next token (self-supervised learning), then tuned with human and AI feedback. But underneath they use exactly the same ingredients as the list below: data as vectors, a model, a loss, and optimisation.

Why it matters

An everyday analogy: learning to throw darts

Your first throws go everywhere. After each throw you see how far off you were (the loss) and adjust your arm a little in the direction that would have helped (the gradient). After hundreds of throws you are hitting the board. You never wrote down the physics of darts. Your arm learned a function from “where I aim” to “where it lands”. That is gradient descent.

The core equation

Linear regression is the “hello world” of the field. Given inputs xx and targets yy, find weights ww and bias bb so that y^=wx+b\hat{y} = w x + b is close to yy. “Close” means minimising the mean squared error:

L(w,b)=1n∑i=1n(wxi+b−yi)2 L(w, b) = \frac{1}{n} \sum_{i=1}^{n} \left( w x_i + b - y_i \right)^2

Gradient descent repeats a small step downhill, with learning rate η\eta:

w←w−η∂L∂w,b←b−η∂L∂b w \leftarrow w - \eta \frac{\partial L}{\partial w}, \qquad b \leftarrow b - \eta \frac{\partial L}{\partial b}

A neural network is the same thing with many layers of weights and a non-linear function between them.

A hands-on example

Gradient descent from scratch with NumPy, then the same with scikit-learn:

import numpy as np

rng = np.random.default_rng(0)
x = rng.uniform(0, 10, 100)
y = 3 * x + 2 + rng.normal(0, 1, 100)       # true w=3, b=2, plus noise

w, b, eta = 0.0, 0.0, 0.01
for step in range(2000):
    err = w * x + b - y
    w -= eta * 2 * np.mean(err * x)          # dL/dw
    b -= eta * 2 * np.mean(err)              # dL/db
print(f"learned w={w:.2f}, b={b:.2f}")      # close to 3 and 2

from sklearn.linear_model import LinearRegression
m = LinearRegression().fit(x.reshape(-1, 1), y)
print(m.coef_, m.intercept_)

Install with pip install numpy scikit-learn in a virtual environment (python -m venv .venv). For deep learning the standard library in 2026 is PyTorch, with JAX as the main alternative. You can follow the same loop by hand even in PicoLisp with fixed-point numbers, which is a good way to prove to yourself there is no magic.

Common misconceptions

Connections

Machine learning in a Nutshell:

The mathematics needed:

Last edited · 24 revisions

Tags: #Computing