An AI algorithm is a step-by-step method that tells a computer how to learn from data, find patterns or solve a problem. In machine learning, the algorithm is the learning procedure. When you run it on data, it produces an AI model that can then make predictions on new input.
Key takeaways
- An algorithm is a method. A model is the result of applying that method to data.
- AI algorithms fall into a few families: supervised, unsupervised, reinforcement learning and search or rule-based methods.
- Choosing an algorithm depends on the task, the data you have and how explainable the result must be.
- “The algorithm” in social media usually means an entire ranking system, not a single algorithm.
An AI algorithm explained in simple terms
A cooking method, like “fold gently, then bake at low heat”, is not a cake. It is a procedure. Apply it to ingredients and you get a cake. An AI algorithm is the procedure. Apply it to data and you get a trained model. The same algorithm on different data produces a different model. That is why two companies can use the same algorithm and get very different results.
How does an AI algorithm learn?
- It starts with a model that has random or default settings.
- It makes a prediction on a training example.
- It measures the error using a “loss function”, a score for how wrong the prediction was.
- It adjusts the model’s settings to reduce that error. In neural networks this is usually done with gradient descent and backpropagation.
- It repeats this across many examples, often millions of times, until the error stops improving.
Main types of AI algorithms
| Family | How it learns | Common algorithms | Typical tasks |
|---|---|---|---|
| Supervised learning | From labelled examples with known answers | Linear and logistic regression, decision trees, random forests, gradient boosting, neural networks | Classification, prediction |
| Unsupervised learning | Finds structure in unlabelled data | k-means clustering, principal component analysis | Segmentation, anomaly detection |
| Reinforcement learning | By trial, error and reward | Q-learning, policy gradient methods | Games, robotics, control |
| Self-supervised learning | Creates its own labels from raw data, such as hiding a word and guessing it | Transformer pre-training | Large language models |
| Search and rule-based | Follows explicit logic or explores options | A* search, expert rules, minimax | Route planning, puzzles, compliance checks |
Examples you already know
- Decision trees split data with yes/no questions, like “Is income above X?”, and are easy to explain.
- k-means groups customers into segments with similar behaviour.
- Gradient boosting is widely used for fraud and credit scoring on tabular data.
- Neural networks power image recognition, speech and language models.
- A* search finds efficient routes in maps and games.
AI algorithm vs AI model
This is the most common mix-up. The algorithm is general and reusable, like “gradient boosting”. The model is specific: “our gradient-boosted fraud model trained on 2025 transactions”. When someone says “the algorithm decided”, they usually mean the model, or the whole AI system that uses it.
How to choose an algorithm
- Type of task: categories, numbers, groups or sequences of actions.
- Data volume: simple algorithms often beat complex ones on small datasets.
- Data type: tables suit tree-based methods; images, audio and text suit neural networks.
- Explainability: regulated decisions may need methods that can be clearly explained.
- Cost and speed: some algorithms are far cheaper to train and run.
Limits and misconceptions
An algorithm is not neutral just because it is maths. Its results depend on the data it learns from and the goal it is told to optimise. If the goal is “maximise clicks”, the algorithm will find whatever gets clicks, even if that is not good for users. Most “algorithm” problems in the news are really problems of data, goals and oversight.
