Artificial Intelligence
Machine learning basics: learning paradigms, project steps, model and library choice, feature selection, and an overview of RAG architecture.
4 min readUpdated
Machine learning is the part of artificial intelligence that builds models from data instead of hand-written rules. This note summarises the main learning paradigms, the usual steps of a machine learning project, common algorithms and libraries, and feature selection. It ends with a map of retrieval-augmented generation (RAG), the standard way to ground a large language model in your own documents.
Learning paradigms
- Supervised learning learns a mapping from inputs to known outputs using labelled examples. It works well when correct labels exist, for example diagnoses confirmed by a doctor. It covers two kinds of task:
- Classification predicts a discrete label (spam or not spam, disease A or B).
- Regression predicts a continuous value (a price, a temperature).
- Unsupervised learning finds structure in unlabelled data. Typical tasks are clustering (grouping similar items), dimensionality reduction and anomaly detection.
- Semi-supervised learning combines a small labelled set with a large unlabelled one.
- Reinforcement learning trains an agent that interacts with an environment in discrete time steps. At each step the agent takes an action and receives a reward, and it learns a policy that maximises the total reward over time. It is neither classification nor regression; it is used for control, robotics and games such as chess, Go and strategy games.
Deep learning (neural networks with many layers) is not a separate paradigm: it is a family of models that can be trained in any of the settings above.
Steps in a machine learning project
Most projects go through the same stages:
- Understand the domain and the question you are answering.
- Study the data (exploration, data mining).
- Clean and normalise the data, and build the tools to do so repeatably.
- Choose candidate models.
- Try a few models, shortlist the best ones and pick one.
- Train, tune and, where possible, A/B test the model.
- Correct overfitting or underfitting.
- Measure the result in production: monitor errors, what the model learns, and its effect on the business.
The diagram below shows a typical pipeline: raw data is cleaned, features are selected, preprocessed and constructed, then a model is selected, its parameters optimised and the model validated.

Choose a model
With an understanding of the domain and the data, you can narrow down which models are likely to work. Common choices by paradigm:
- Supervised learning
- k-nearest neighbours
- Linear and polynomial regression, logistic regression
- Support vector machines (SVM)
- Decision trees and random forests
- Unsupervised learning (clustering)
- k-means
- Hierarchical cluster analysis (HCA)
- Expectation maximisation (for example, Gaussian mixture models)
- Semi-supervised learning
- Reinforcement learning
- Deep learning, including recurrent neural networks (RNN) for sequences
Choose a library
Ready-made implementations exist for most algorithms:
- scikit-learn for classic machine learning in Python, with pandas and NumPy for data handling
- Spark MLlib and PySpark for distributed training on large data sets
- TensorFlow and PyTorch for deep learning
- Reinforcement learning exercises and solutions (Denny Britz)
Feature selection
Feature selection picks a subset of the available features (attributes) to build the model with. It removes features that are irrelevant or redundant, that do not add accuracy, or that even reduce it. The aims are:
- simpler models that are easier to interpret and explain
- shorter training times and cheaper predictions
- avoiding the curse of dimensionality
- better generalisation through less overfitting
- a better understanding of the process that generated the data
Feature selection is different from dimensionality reduction. Both reduce the number of attributes, but dimensionality reduction creates new attributes as combinations of the original ones, while feature selection keeps or drops the original attributes unchanged. Examples of dimensionality reduction are principal component analysis (PCA), singular value decomposition (SVD) and Sammon’s mapping.
RAG architecture
Retrieval-augmented generation (RAG) answers a question with a language model that is given relevant documents retrieved for that question, instead of relying only on what the model learned in training. The diagram maps the techniques used at each stage:
- Query translation: rewrite or decompose the question (multi-query, step-back, RAG-Fusion, HyDE).
- Routing: send the question to the right data source or prompt, by logic or by embedding similarity.
- Query construction: turn natural language into a query for the store, such as text-to-SQL, text-to-Cypher for graph databases, or metadata filters for a vector store.
- Indexing: split, summarise and embed documents (chunk optimisation, multi-representation indexing, specialised embeddings, hierarchical indexing such as RAPTOR).
- Retrieval: rank, filter or compress the retrieved documents, and retrieve again if they are not relevant (re-ranking, CRAG).
- Generation: produce the answer, and use its quality to trigger rewriting or re-retrieval (Self-RAG).
