Machine learning, which is a subset of artificial intelligence (AI), is the ability of computers to recognize patterns in data and make predictions or decisions based on those patterns. A learner (programmer) passes examples to the system and its learning algorithm modifies itself to fit the examples, instead of writing one rule for every possible application. The trained model can then be used to classify new data, based on what it has learned.
A spam filter is a simple one. No list of phrases or tricks could be all-encompassing. Rather, the filter can be trained through thousands of emails which have already been marked by people as spam or not spam. It finds out from those examples which words, senders, links, and other patterns are associated with undesired messages. Then it applies these patterns to identify new emails.
There are a number of machine learning-powered tools that people use on a daily basis. Recommendations for movies or products, voice activated commands, and fraud detection are just a few examples of what these systems are capable of. The field has three traditional parts: supervised learning, unsupervised learning and reinforcement learning. More recent methods such as semi-supervised learning and self-supervised learning are playing a significant role in contemporary AI.
Here, you will get a breakdown of the working of machine learning, a simple example to go through. Comparisons between some of the popular algorithms, real-life applications of machine learning, and some limitations of the technology.
Key Takeaways
- Computers can learn patterns and rules from the data using machine learning.
- Machine learning is a part of the artificial intelligence field, but artificial intelligence also encompasses systems which do not learn from data.
- Models make predictions, and are trained by minimizing the error between their predictions and correct answers.
- There are three main types, namely supervised, unsupervised and reinforcement learning.
- Deep learning is a machine learning technique employing multi-layered neural networks.
- The quality and representativeness of training data can be as crucial as the algorithm.
- Some of the critical risks are bias, limited explainability, data drift, privacy, and computing costs.
What is machine learning?
Machine learning is a key concept in the world of Artificial Intelligence. Machine Learning is often referred to as the study of how to make computers learn without being explicitly programmed. This machine learning definition typically comes from the American computer scientist, Arthur Samuel (1901-1990), who in the 1950s created a checkers program that gradually became better, through self-play. A paraphrase of that is the phrase that is often repeated, but it conveys the thrust of Arthur Samuel's 1959 paper, "Some Studies in Machine Learning Using the Game of Checkers".
A more official definition of machine learning was given by the computer scientist Tom Mitchell in 1997. His approach of learning is based on a task, experience and a performance measure. It is a program that learns as it performs a specific task and the more it performs it the better it gets at doing it.
Think about using a spam filter. A task is the classification of email, an experience is from messages that have been labeled, and a measure of performance might be the percent of labeled messages that are classified correctly.
Machine Learning Meaning in Simple Terms
ML means "machine learning." As a practical ML definition, it's software that learns to execute an action, not just on the basis of a set of rules written by a computer programmer.
Machine learning vs traditional programming
Cooking is one good analogy. Traditional programming is like giving a person a recipe, with very specific instructions: This is how to do it, this is the order, this is the outcome. Machine learning has a different approach. You provide the computer with numerous completed samples of food items, and the ingredients for each dish, and the computer calculates the patterns that link the ingredients to the products.
The big point is where the rules come from. In traditional programming, people write them by hand. In the field of machine learning, they are taught through examples.
What is the difference between machine learning and AI?
AI is the larger category of developing AI machines that can execute tasks that are tied to human intelligence. In the machine learning vs artificial intelligence comparison, machine learning is one way of achieving that goal. That is, everything that can be done by machine learning is included in AI, but some AI methods are not based on machine learning.
A simple thermostat is an example of difference. If it's set to activate the heater whenever the temperature drops below 68°F, then it's following a rule. It does not adapt to the environment through learning. A smart thermostat that learns when people are typically home and can adjust the schedule accordingly is more of a machine learning system.
Expert systems were commonly used in early AI systems, notably in the 1970s and 1980s. The systems relied on extensive sets of if-then rules, created by the specialist. They might function well in a specific situation, but fail when they are faced with situations that weren't predicted by those who created the rules.
With problems like speech recognition, image analysis, or fraud detection, where patterns cannot be described using thousands of rules written by humans, machine learning was better suited.
AI and machine learning are frequently used interchangeably, because there are many AI systems that rely heavily on machine learning today. Machine learning techniques are used in various applications such as chat assistants, image generators, recommendation systems, and speech recognition tools.
How does machine learning work?
Machine learning consists of feeding a model with data, evaluating the success of the model and adjusting its internal parameters to reduce the error. Post-training, the model can predict data that it was not trained on. This loop describes supervised learning most closely; the other types covered below learn in slightly different ways.
This is more easily understood on a step-by-step basis.
Converting data into numbers
A mathematical representation of data is used to feed the machine learning algorithms. Each example, then, must be encoded in a format to which the algorithm could apply its processing.
All features of an example are measurable properties. For a house, its square footage, number of bedrooms and age could be used to describe it. One house might thus be symbolized by:
[1900, 4, 30]
This list is a vector because each number corresponds to one of the dimensions of the data.
There are some data that already has a numerical value like prices, temperatures, sensor readings. Other types of information need to be converted. Text, images and sound can all be converted into numbers. This process might include feature engineering, and in today's machine learning systems, useful representations, known as embeddings, can be learned directly from data.
The three parts of a learning algorithm
A typical supervised learning system repeatedly carries out three similar tasks:
- A decision process takes the input features and produces a prediction.
- A loss or error function measures how far that prediction is from the correct answer.
- The parameters of the model are optimized in such a way that future predictions are closer to the truth.
The numbers that can be adjusted in the model are the parameters. They are often referred to as weights in many models.
Training simply involves identifying the values of the parameters which minimizes the overall error on the training set.
Case study: an example of teaching a model for house pricing
Let's model the price of houses in a very oversimplified way, say, as follows:
Price = (A × square feet) + (B × bedrooms) − (C × age in years) + base price
A, B and C are weights that the model must learn.
Assume the initial training is started at:
A = 100
B = 10,000
C = 500
Base price = 50,000
The model predicts for a four bedroom, 30 year old house that is 1,900 square feet in size:
190,000 + 40,000 − 15,000 + 50,000 = $265,000
If the actual sale price was $310,000, the model missed by $45,000.
The weights are optimized so as to minimize that error. The model can then be used for thousands of past sales to determine parameter values that better predict the values of houses that the model has never seen before.
In a real house-price system many more variables would be used and a more sophisticated model. The fundamental learning cycle, however, doesn't change:
Predict → take a measurement of the error → modify the model → repeat.
How does AI learn from its mistakes?
One of the prevalent methods used for training machine learning models is called Gradient Descent. The loss function returns a numerical value that quantifies the error made by the model, and by using calculus, the direction in which the model's parameters should change in order to minimize the error can be calculated.
The model makes a small step in this direction and computes the new error, and the process is repeated. Learning rate is a hyperparameter, set by the people training the model, that controls the size of each step.
Another technique that is important to neural networks is called backpropagation. It determines the portion of individual weights that gave rise to the final error, and enables the network to tune a large number of parameters during the training process.
This means that models with millions or even billions of tunable parameters can be trained.
From training to real-world predictions
Training data is just part of the equation. The true objective is generalization, getting good results on data that the model has not been trained on.
This can be measured by keeping some data aside, and using it to test the trained model. Prediction based on the model to new real world data is called inference after training.
If the model is very good at making predictions when the test examples are the same as the training examples, but not very good when the test examples are different, then it has not learned the underlying pattern very well. It could just be that it has simply memorized the training data.
What are the types of machine learning?
There are three main modes of machine learning: supervised learning, unsupervised learning, and reinforcement learning. Semi-supervised and self-supervised learning are also common in modern AI systems.
The correct method will depend on the data available, and the purpose of the system.
| Type | Learns from | Goal | Example |
|---|---|---|---|
| Supervised learning | Labeled examples | Predict a known answer | Flagging spam email |
| Unsupervised learning | Unlabeled data | Find hidden structure | Grouping customers by habits |
| Reinforcement learning | Rewards and penalties | Choose the best actions | A robot learning to walk |
| Semi-supervised learning | A few labels plus many unlabeled examples | Cut labeling costs | Classifying medical scans |
| Self-supervised learning | Labels created from the data itself | Learn general patterns | Predicting the next word in a sentence |
Supervised learning
Supervised Learning: Each training example is accompanied by a correct answer, known as a label. Imagine you were revising using past exam papers with answers at the back. After enough papers, new questions in the same style stop being a problem.
Supervised tasks come in two kinds. Regression is used to predict numbers, like the number of minutes remaining on a journey or the amount of rainfall for the next day. Classification, predicting a category. Spam filtering is a binary classification problem and a weather model predicting rain, snow, sleet and clear weather is a multiclass classification problem. Most of the business uses listed later in this article, ranging from fraud scoring to demand forecasting, are supervised.
Unsupervised learning
Unsupervised learning is learning without any labels. The model receives the raw data and searches for patterns within the data. The standard method is called clustering, which groups together data points that are near each other. An online store can group customers based on what and when they purchase, and reveal unknown segments of customers. Feeding a clustering model a year of daily temperatures will yield groups that cluster with the seasons, but never in the sense of knowing that seasons exist.
Two other unsupervised methods come up often. Association rules discover products that co-occur in shopping carts as the typical case. Dimensionality reduction reduces the number of features the data has, but preserves as much information as possible, making it easier to plot or pass to another model.
Supervised vs unsupervised learning
Supervised vs unsupervised learning is largely about the answers being in the data. Labels can be used to directly measure the accuracy of a model. If they are not there the model still can find groups, but it is the responsibility of a person to determine what is a group. It takes time and money to mass produce labels, so teams can often use unsupervised methods to make their way through a huge unlabeled data set before spending money on labels.
Reinforcement learning
Reinforcement learning places a program, or an agent, into an environment and allows the program to act. Every action alters the state of the environment, and is rewarded or penalized. The agent learns a policy (strategy) over many tries for choosing actions that will eventually lead to a reward.
The two major options are illustrated in a maze. A policy-based agent learns instructions directly, such as "turn left at this corner." A value based agent (e.g. trained by Q-learning) learns a score for each square in the maze, and continues to move towards higher scores.
Reinforcement learning is used by robots learning to walk, and is used by programs that play board games more effectively than people. It is also used in the final training stage of some chatbots, a technique known as reinforcement learning from human feedback, or RLHF.
Semi-supervised and self-supervised learning
Semi-supervised learning starts with a small labeled set and a much larger unlabeled one. In a common version called self-training, the model learns from the labeled examples, labels the rest with its most confident guesses, then retrains on the bigger pile. The approach suits fields like medical imaging, where getting an expert to label each scan is slow and expensive.
Self-supervised learning creates labels out of the data itself. A language model hides a word in a sentence and learns by guessing it, over and over across billions of sentences. Large language models get most of their training this way before fine-tuning adapts them to specific jobs.
Where generative AI fits
Generative AI refers to models that produce new content such as text, images, audio or code. They learn the patterns in very large datasets, usually through self-supervised training, then generate output that follows those patterns. A text-to-image model turns a written prompt into a picture, while a text-to-text model answers questions or summarizes a report. Many of these models also go through supervised fine-tuning and preference-tuning methods such as RLHF so their answers match what people actually ask for.
How to choose the right type of machine learning
Make the best of what you have. Past cases with known outcomes point to a supervised learning approach. If you have a large lot of unlabeled records in which you are looking for groups or strange ones, then you are looking for unsupervised learning. Reinforcement Learning is useful when a system needs to make a series of decisions and can be rewarded for the outcome. If you have a small amount of labeled data, you can use a semi-supervised approach and make use of the remaining data.
Machine learning algorithms and models
The terms "algorithm" and "model" are sometimes used synonymously, but they have different meanings. Machine learning models are what an algorithm produces after training, a type of AI model built from data. The training procedure is a machine learning algorithm. Once the training is complete the model is what you have, a set of weights that you can input new data into. There are various machine learning models that are suited to various problems, so often practitioners will train two or more different models and compare them.
Linear regression is the typical first method that will be used for supervised work. It can be used to model a data set with a straight line or plane, much like the house-price formula above, to predict a number. Logistic regression gives a probability (0 to 1) to a yes/no problem. A decision tree asks a series of questions regarding features, leading to an answer, making it easy to follow.
Random forest is an ensemble learning technique that involves training hundreds of decision trees with a different portion of data and allowing them to vote. Gradient boosting models are also tree-based, but they are constructed one by one, with each tree working to correct the errors made by the previous one - the best known library for this is XGBoost. The classic set includes support vector machines, which draw the widest possible boundary between 2 classes and naive Bayes, which uses probability rules and performs fairly well on text. The simplest in the list is k-nearest neighbors, which labels a new point by looking at its closest points in the training set.
K-means clustering (unsupervised) clusters each point into one of k cluster centers, chosen by you beforehand. Hierarchical clustering is a process that creates a hierarchical structure of nested groups. In DBSCAN, the groups are determined by the number of points in the close vicinity of each point in the dataset and any points that are not in the close vicinity of any other point are marked as anomalies, making it useful for anomaly detection. Gaussian mixture models assume that the data is composed of multiple overlapping bell curves. The most commonly used dimensionality reduction method is Principal component analysis (PCA) and the Apriori algorithm is used to discover association rules.
Reinforcement learning has its own algorithms, such as Q-learning, actor-critic methods, and proximal policy optimization (PPO). PPO was the algorithm used in the RLHF stage of early instruction-following language models.
Deep learning vs machine learning
Deep learning is machine learning using a multi-layered neural network. In that sense, deep learning vs machine learning is a matter of approach. Deep learning is a subset of machine learning, where the features to be learned are learned from raw pixels, audio or text.
The construction of a neural network is done through layers of interconnected nodes, which are loosely inspired by the neurons. Each connection has a weight, each node has a bias and each node feeds the output to the next node through the nonlinear activation function. With enough layers, the network can represent very complicated relationships. A 1986 Nature paper demonstrated that such multi-layer networks can be trained efficiently with backpropagation, and backpropagation is still the standard way deep networks are trained.
Typically, in traditional machine learning, humans would choose which features are important through feature engineering. A deep network works them out on its own. In an image model, the early layers identify edges, the middle layers recognize shapes such as eyes and wheels, and the later layers recognize whole faces or cars.
| Factor | Traditional machine learning | Deep learning |
|---|---|---|
| Feature engineering | Mostly done by people | Learned automatically |
| Data required | Works with smaller datasets | Usually needs large datasets, unless it starts from a pretrained model |
| Hardware | Runs on ordinary computers | Usually needs GPUs or specialized chips |
| Interpretability | Often easy to explain | Hard to explain |
| Best suited to | Tables of structured data | Images, audio, text and video |
Various network architectures are best for various types of data. Convolutional neural networks (CNNs) scan small filters over an image, and became the established standard in computer vision. Recurrent neural networks (RNNs) take a sequence in steps: reading one step at a time, they have a hidden state which acts as a short-term memory. Transformers were introduced in a 2017 transformer paper, which introduced an “attention” mechanism that considers all parts of the input simultaneously, and they now underpin almost all large language models. For generating images, the main designs are diffusion models, variational autoencoders (VAEs) and generative adversarial networks (GANs).
What is machine learning used for?
Machine learning is mostly used for prediction at a scale people can't match. There are too many cards to be checked by a person at a bank, but a model can score a card payment within milliseconds. Such uses are sometimes divided into three categories: descriptive models provide explanation of what has occurred; predictive models provide prediction of what will occur; prescriptive models provide recommendation of what should be done next.
In everyday life there are some machine learning examples. Email filters learn from spam/phishing that users report, while modern productivity tools use ML to schedule tasks, summarize meetings and autocomplete notes. Banks compare each purchase with a customer's usual spending to identify fraud. Shows and products are recommended to viewers by streaming services and online stores based on what similar viewers liked, and stores predict how much demand they will have, based on past sales, weather and holidays. Navigation apps estimate arrival times from historical traffic data.
Another big area is language, as all the translation tools, speech recognition, and chat assistants are based on natural language processing models. In health care, image models assist radiologists in identifying tumors in computed tomography scans and symptoms of eye disease in photographs of the retina. Computer vision is used in self-driving systems for lane detection, sign detection, and pedestrian detection. Machine learning is employed by scientists in weather predictions, design of materials and the vast amounts of data generated by particle detectors and telescopes.
What these machine learning applications share is volume. They're all dealing with more data, or faster decisions, than a team of people could get through, and a pattern too complex to record as rules. Normally, in a problem that has a few dozen cases and a very clear rule, a general software program is always a better option.
When should you use machine learning?
Start with the business problem, not the technology. Machine learning is worth the cost when you have a large amount of historical data, the pattern in that data is too complex to write down as rules, and an occasional wrong prediction is acceptable or can be caught by a person.
A fraud team scoring millions of card payments meets all of those conditions. A payroll system calculating overtime does not, because the rules are fixed and every answer has to be exact, so ordinary software is cheaper and easier to audit. Before starting a project, ask which decision the model will support, what data exists to train it, and how you will measure whether it beats the current process.
How Do You Evaluate a Machine Learning Model?
You test it with data that it has not yet encountered. The model may have obtained a perfect score on its training data set because it memorized it, so the number alone doesn't mean that much.
The majority of projects partition the data in three ways. The model is trained on the training set and engineers adjust the parameters such as the learning rate against the validation set. The test set remains unchanged throughout the test and provides the final score at the end of the test. The cross-validation will be repeated several times, using different slices to get a more robust estimation.
The two classic failures are at opposite extremes. Overfitting occurs when a model learns noise and fails on new cases and underfitting when the model is too simplified to detect the actual pattern. The middle ground is referred to as the bias-variance tradeoff and regularization works by penalizing a model for becoming over-complicated compared to the data.
Being accurate is not enough! Imagine a set of data in which 1 transaction out of 1,000 is fraud. A model that predicts all transactions as safe is 99.9% correct, and makes no false positives, but it also catches no fraud. Classification work therefore also captures precision (how many of the flagged cases were fraud cases) and recall (how many of the fraud cases were flagged). These two are combined in the F1-score, and the AUC-ROC curve illustrates the trade-off between these two at various thresholds. Regression models are judged by the average size of their errors.
How good is good enough depends on what's at stake. A movie recommendation that misses now and then costs nothing. A model reading medical scans or steering a car needs a much higher bar, plus a person checking its decisions.
The machine learning lifecycle
A model isn't finished when training ends. Typical phases of real projects:
- State the problem and determine the criteria for success.
- Collect data from databases, sensors, logs or other sources.
- Clean the data by fixing missing values, removing duplicates and handling outliers.
- Design and specify the characteristics that the model should learn.
- Train several candidate models.
- Test them on a separate test set and select the one that performs best.
- Install the selected model in an app, website or internal system.
- Monitor its predictions and retrain it when performance slips.
Monitoring matters because data keeps changing after launch. Consumers adapt, fraudsters adjust and sensor age and accuracy wanes over time in what's known as model drift. The practices of automating deployment, monitoring and retraining are known as MLOps. Teams in regulated sectors add model governance on top, which is a documented description of how each model was developed, tested and approved.
Limitations and risks of machine learning
The quality of a model is limited by the quality of its training data. Missing values, wrong labels or a sample that doesn't match the real world all lead to bad predictions. The algorithmic bias enters into hiring, lending and policing tools when data that contains discrimination is fed into the model and has the effect of training the model to repeat that discrimination.
Explainability is the second big problem. Inspecting large models, particularly deep networks, is difficult, and often the network creators cannot explain just why they made a certain call. This difference is significant with loan applications that are rejected, or with patient applications that are flagged.
Models also learn shortcuts their designers never intended. A 2018 study in PLOS Medicine found that a pneumonia detector trained on chest X-rays performed worse at hospitals outside its training data. Part of the reason was that the model had picked up features of each hospital's images, not just signs of the disease. In a separate 2013 arXiv paper, researchers showed that pixel changes too small for a person to notice can make a neural network confidently mislabel an image. These inputs are dubbed adversarial examples.
Privacy and cost are the other two. There are concerns regarding personal data used in many models and consent and security. It also requires a substantial amount of computing power and electricity to train large deep learning models. For organizations working out how to manage these risks, the AI Risk Management Framework from NIST lays out a process for identifying and reducing them.
How did machine learning develop?
The core ideas are older than most people assume, as the history of artificial intelligence shows. Alan Turing's paper (1950) in Mind suggested the imitation game, which is now known as the Turing test. The same paper included a section on "learning machines." In 1958 the perceptron, an early neural network, was described by Frank Rosenblatt in Psychological Review. A year later, Samuel's checkers paper brought the phrase "machine learning" into wider use.
The 1986 backpropagation paper reignited interest in neural networks, but rule-based expert systems also known as symbolic AI continued to be the focus of AI research until the 1990s. In the 1990s, the area shifted to statistical techniques like support vector machines, and in 1997 a computer beat the world champion chess player Garry Kasparov.
The use of deep learning started to gain momentum in 2012 when a convolutional network (CNN) achieved a top-5 error rate of approximately 15% on the image recognition contest, compared to approximately 26% for the runner-up. A partially-reinforcement-learning-trained Go program defeated Lee Sedol 4-1 in 2016. The transformer was introduced in 2017 and in just a couple years it was used to form the big language models that power today's generative AI tools.
Machine learning basics: how to get started
Some math, some knowledge of Python and some practice with real datasets are required to learn the basics of machine learning.
The math is mostly statistics and probability, describing uncertainty, along with components of linear algebra to represent vectors and matrices containing data. You should also have sufficient calculus to follow the way the weights are adjusted during gradient descent. The knowledge of ideas is more important than proving theorems.
The default language of the field is Python. NumPy handles numerical arrays, pandas cleans and reshapes tables, and Matplotlib draws charts. The scikit-learn library offers almost all of the classic algorithms from this article under one single signature, and PyTorch is typically used for deep learning.
Another type of machine learning software is no code and automated machine learning tools that train standard models using a point-and-click interface. They handle routine prediction tasks well. However, it is still worthwhile to know what's going on under the hood: knowing about it is how you discover a model that is overfitting, biased or answering the wrong question.
Conclusion
Machine learning converts examples to rules. If a computer can be trained on a large number of flagged e-mail messages, it can be taught to recognize spam; if it can be trained on a large number of previous house sales, it can be taught to price houses. The loop of predicting, measuring the error and adjusting the weights is identical for a simple regression as for a transformer with billions of parameters below the surface.
Whether a model works depends more on the data and testing than on the choice of algorithm. Most of the above mentioned problems are picked up by representative training data and a correct held out test set and monitoring following launch. To get the whole loop, a small labeled dataset plus scikit-learn is sufficient to train a first model.
Frequently asked questions
How to define machine learning in simple terms?
It is the teaching by example approach to teaching computers. You present a system with a number of cases, it learns the pattern and then uses this pattern when presented with new cases, in this case a new email is spam or not.
What is ML in AI?
Learning from data is a key aspect of AI work, known as ML. It is used in the majority of AI products, such as recommendation feeds and chat assistants, making the two terms frequently seen in tandem.
So, what kind of AI or machine learning is ChatGPT?
It is both. ChatGPT is an AI application based on a large language model that was trained through self-supervised learning using text and fine-tuned through supervised learning and RLHF.
Is coding a requirement for the use of machine learning?
Typically, custom models do, they typically are Python-based. While no code tools can train models, coding offers control over data preparation, model selection, performance, and other aspects.
What is the difference between machine learning and data science?
Data science is the broader job of getting answers out of data, covering statistics, cleaning, visualization and reporting. Machine learning is one of its tools, used when a task needs automated predictions.
How much data does machine learning need?
The answer depends on the problem. A simple regression can work with a few hundred clean rows, while deep learning models for images or language usually need hundreds of thousands of examples or more.
