Lesson 2 of 28 · AI foundations
What is machine learning?
Machine learning (ML) is a branch of artificial intelligence in which computers learn to perform a task from examples instead of being programmed with step-by-step rules. A machine-learning system studies data, finds patterns, and uses them to make predictions or decisions about new data, such as flagging spam, recommending a film or estimating a delivery time.
How machine learning works
Every machine-learning system has three ingredients. Data: the examples it learns from, such as past house sales with their prices. A model: a mathematical formula with many adjustable settings, called parameters. Training: the process of nudging those parameters, again and again, until the model's predictions match the examples as closely as possible.
It works much like learning to guess house prices yourself. After seeing hundreds of homes and what they sold for, you develop a feel for how size, location and condition affect the price, without anyone handing you a formula. Arthur Samuel's 1959 paper on a program that learned to play checkers is one of the earliest uses of the term "machine learning".
The three main types of machine learning
Machine learning is usually divided by the kind of feedback the system gets while it learns:
- Supervised learning: every example comes with the right answer, called a label, such as an email marked "spam". The model learns to predict the label for new examples. This is the most common type.
- Unsupervised learning: the examples have no labels, and the model finds structure on its own, such as grouping customers with similar buying habits.
- Reinforcement learning: the system learns by trial and error, receiving rewards for good outcomes, as in game-playing programs and robot control. A version using human feedback is also used to tune chat assistants.
What machine learning is not
Machine learning is not understanding. A model finds correlations in its data; it does not know why they hold. If the training data is biased or out of date, the predictions will be too, a problem often summed up as "garbage in, garbage out".
It is also not always the best tool. If a simple rule does the job, such as "orders over a set amount need a manager's approval", a rule is cheaper and easier to check. And most deployed models do not keep learning while you use them: they are trained, frozen and then put to work, and only change when the vendor retrains them.
Where you meet machine learning
Machine learning sits behind card-fraud alerts, spam filters, product and video recommendations, voice typing, photo search and delivery-time estimates. In business software it scores sales leads, forecasts demand and flags unusual transactions.
It is also the foundation of everything later in this course: deep learning is a kind of machine learning, and generative AI tools such as chat assistants are built with deep learning. Knowing that a model learned from data helps you ask the right buying question: what data was it trained on, and does that match your situation?
Example
Train a tiny spam filter in Python
Code sample# Teach a model to tell spam from normal messages
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import MultinomialNB
messages = ['win a free prize now', 'lunch at 1pm?', 'claim your free cash', 'meeting notes attached']
labels = ['spam', 'ok', 'spam', 'ok']
vectorizer = CountVectorizer()
model = MultinomialNB().fit(vectorizer.fit_transform(messages), labels)
print(model.predict(vectorizer.transform(['free cash prize']))) # ['spam']Runs in Python with the scikit-learn library installed. Four examples are far too few for real use, but the pattern is the same at any scale: examples and labels go in, and a model that predicts labels for new text comes out.
Key points
- Machine learning lets computers learn a task from examples instead of explicit rules.
- Training adjusts a model's parameters until its predictions match the examples.
- Supervised, unsupervised and reinforcement learning are the three main types.
- A model is only as good, and as fair, as the data it learned from.
- Machine learning is a subset of AI, and deep learning is a subset of machine learning.
Try it on Mindber
Related terms
Related topics
Frequently asked questions
Is machine learning the same as AI?
No. AI is the broad goal of making computers do tasks that need intelligence. Machine learning is the main method used to reach that goal today: instead of writing rules, you train a model on examples. All machine learning is AI, but some AI, such as a hand-written rule system, is not machine learning.
Do I need maths or coding to use machine learning?
Not to use it. Most people meet machine learning inside finished products, and many no-code tools let you train simple models from a spreadsheet. Building your own models from scratch does require programming, usually in Python, plus some statistics and linear algebra.
Does a machine-learning model keep learning while I use it?
Usually not. Most models are trained, frozen and then deployed, so their parameters do not change while you use them. Vendors may collect usage data to train a future version, which is why it is worth reading a product's data-use terms before entering sensitive information.
Sources
- Some Studies in Machine Learning Using the Game of Checkers. Arthur L. Samuel, IBM Journal of Research and Development, July 1959
- Machine Learning Crash Course. Google for Developers
Last updated