Machine learning in a nutshell: the core components and the methods used to “learn”.
This is a free giveaway: I am publishing the whole of Chapter 3 of The Ethics of AI: Facts, Fictions, and Forecasts, where I explain Machine Learning and put it against how humans learn. Although the main aim of the chapter is educational — helping the general public understand what ML is about beyond the hype! — the point I build up through many chapters, including this one, is that computers and humans are VERY different.
Machine: “A mechanically, electrically, or electronically operated device for performing a task.”
To learn: “To gain knowledge or understanding of or skill in by study, instruction, or experience.”
My daughter is almost four years old. Not too long ago, she walked up to me while I was grilling and asked me a question.
“Daddy, what is this?”
— “It’s pieces of wood in a bowl of water.”
“Why did you do that?”
— “I want to get some smoke in the barbeque.”
“How do you make smoke?”
— “You know, if you place wet wood on top of the charcoal, it makes a nice smelling smoke!”
“Ha.” she noted, matter-of-factly.
As it is custom with children that age, she asks me an incredible amount of questions. All discussions end with her brief, dry “Ha” — her way to say, “Got it. I understand now.”
It fascinates me that she never questions whether my answer makes sense or not. She just accepts things as they are. It’s that simple.
With adults, things are never this easy. We are used to reasoning, deducing, or “fact-checking” everything. My daughter does not fact-check everything I say to her. She didn’t need to put the wet wood on the barbeque to know how the smoke comes about. She just trusted me.
If I look back at my own experience, most things I learned in life came through a similar process. I didn’t need to fact-check or run an experiment to know that America exists. I trusted my primary school teacher, who told me about America and the author of the world map we had on the glass wall. When I learned multiplication tables and basic math, I didn’t ask about their inner workings — I just trusted the teachers who taught me that 2 + 2 = 4. Trust, or “by authority,” is one of the most basic ways through which humans learn.
There are many ways humans learn, and the humanity of this style keeps surprising scientists and humanists alike. When speaking of machine learning, we shall be cautious not to assume that machines learn in the same way.
Machine Learning
Sometimes, AI and ML are even used interchangeably because ML is the way in which AI systems “learn” to accomplish a task.
As we have seen for the term “artificial intelligence,” the language we use to describe technological advances is often centered on the human experience, so, as a consequence, it tends to lend human qualities to inhuman objects. This is no different with the term “machine learning.” While learning might be the closest we can come up to describing how machines acquire knowledge, this unknowing personification leads us to believe technology can advance beyond us, become autonomous of its creators, and eventually take over the world.
Now, what does machine learning actually mean? And how does it work?
Nowadays, machine learning is the main field of technology that powers most artificial intelligence applications. Building on the definitions given in the previous Chapter, ML is how we humans instruct computers to function as rational agents with a certain degree of autonomy and adaptability.
Machine learning can either be seen as a mathematical and statistical model used to predict a certain outcome, or as a computer programming technique that differs from classical programming (Figure 1).
A classical computer program takes in a mix of rules and data points given to the machine by a programmer and gives you an answer. Think about your calculator. You input data: 2+2, and in return it compiles the input with pre-programmed mathematical rules and gives you an answer: four. It will do this with any set of numbers and symbols you type in, following the rules it was programmed to adhere to.
A machine learning program works differently. It takes data points and answers as input, and it outputs rules. Using the same examples, say we want to program a calculator using machine learning. We would input many examples of mathematical operations (data) with their answers. For example, we would input “2 + 2 = 4,” “3 x 2 = 6,” “10–3 = 7,” etc. It would need millions of such examples. The program’s output is a set of rules to follow for reproducing results similar to the examples it has seen. So, when you input “2 + 2,” it should reproduce the example that is as close as possible to the actual mathematical operation: “2 + 2 = 4.” Programming a calculator with machine learning is overkill, as in this context it is simple enough to give clear rules to the device.
Moreover, the objective of the calculator is to give the right answer all the time. Machine learning uses statistical techniques and may have a percentage of error. Even if the chance is tiny, a calculator cannot afford to get one answer wrong.
An interesting note here is that ML is known by different names in different fields: statistical learning and pattern recognition are a couple of examples. The computer program recognizes patterns using statistics. Using the ML-programmed calculator above, the machine learning techniques, after seeing tons of times that 2 + 2 = 4, its rules work out a higher probability that the input “2 + 2” should give an output of four, with a lower chance that it equals any other number. How we collect data plays a very important role: if the data isn’t enough or over represents certain answers over others, the ML program will learn from skewed data in such a way that it is more likely to give you the wrong answer.
Machine learning comes up with rules by combining mathematical, statistical, and computer programming techniques to find data patterns, and this is one reason why engineers describe the method as “learning.” Given millions of examples, the program “learns” rules to reproduce such samples.
There are different ways machine learning models discover patterns in data. The three main categories of ML are “supervised,” “unsupervised,” and “reinforcement” (The University of Helsinki). The best way to program an application depends on the problem at hand and data availability.
The calculator system described above is an example of supervised learning. We are given inputs with their correct outputs as data examples (the complete equations “2 + 2 = 4,” “3 x 2 = 6,” “10–3 = 7,” etc.). The task of the machine is to learn how to reproduce the correct result of an equation. The results of the equations in the data input are called “labels.”
A more common, real-life problem where supervised learning is more suitable is image recognition. The data is usually millions of images that have been labeled with terms like “cat,” “dog,” “traffic light,” etc. Gathering this data is not straightforward. Labeling images is a tedious and quite expensive task, requiring hours of human work. This is important to keep in mind for understanding that the process of machine learning is not as “automated” as it seems and that data definition and collection are critical limitations that we’ll discuss later.
Problems where unsupervised learning provides better solutions are the ones where you don’t have labels or correct outputs in the data, either because the context doesn’t give you that data or because it is too expensive to tag. There are situations where it might be useful to let the computer figure out an appropriate label. In this case, the computer program’s task is to find a structure in the data for organizing the data itself in a useful manner: for example, grouping similar goods to form groups with similar ratings, characteristics, or complementary use.
Say you have an e-commerce website that collects a vast amount of data: for each product, you have customers’ ratings, size, price, color, specs, and a list of other items bought together. It might be useful to let an algorithm group items with similar features, or similar ratings, or with a similar list of items bought together for providing the customer suggestions of other items to buy. You don’t have labels like “item X is similar to item Y” (it would be too expensive and inefficient to let people label each product), so figuring out what groups are similar is the typical task of an unsupervised learning algorithm. After you fill your Amazon trolley, and before checking out, you see tempting items with a message like “People who bought Nike Air Max shoes also bought these,” which is likely to be the output of an unsupervised learning algorithm.
In fact, unsupervised machine learning techniques are often built into the types of AI that people find creepy or invasive. While the suggestions this technology gives may make it seem like the program “knows” a lot about you, the fact is this simply isn’t true; instead, it mostly uses statistical models to group your habits and interests based on your browsing with other people who displayed similar patterns. The case that made the headline was the American retailer Target. They were able to accurately predict that a teenage customer was pregnant. But don’t worry, Target computers don’t “know” everything about that customer. They could just recognize a statistical pattern based on customers with a similar purchasing history.
One last machine learning technique that we use for programming computers or robots to complete tasks in complex environments is called “reinforcement learning.”
Reinforcement learning is a fascinating mechanism which is commonly used in situations where a computer program needs to adjust its predictions on the go. This is useful for a robot vacuum cleaner that must work in an environment where feedback about right or wrong choices is available with some delay. For example, the vacuum cleaner first moves over a spot on the floor, then checks if it’s dirty. It knows if it’s dirty after having made the choice to move over that spot. The data collected at each pass “reinforces” the previous knowledge of the world the device had. A similar dynamic plays out in games where each move changes all the prospects for future movements: once you place the bishop in a certain square of the chessboard, the strategy of all future moves, both yours and your opponent’s, must change. In fact, Alpha Go, the computer program developed by Google DeepMind that defeated Go’s world champion, used some elements of reinforcement learning to search faster for solutions.
When you hear things like ”machines learn or program themselves,” all that really means is that computer algorithms — that are designed and written by humans! — update some numbers (called parameters) upon processing new data. They follow statistical models and equations that keep updating parameters for optimizing a specific objective.
Human Learning
There are two elements that go into learning: what is learned and how it is learned.
The content of learning is knowledge, understanding, or a skill. Knowledge and understanding are very broad terms for humans, whereas for machines they are very narrow. All the machine “knows” and can update are numbers — the parameters of sophisticated mathematical equations. As a result, a machine can accomplish a new task (and we can call this “gaining a skill”).
We have seen earlier how a machine acquires knowledge, and it is somewhat different from the way humans do. As I’ve mentioned earlier in this chapter, humans learn by study, instruction, or experience. Machines don’t study, but we can say that classical computer programming equals giving instructions. ML programs let machines figure out rules by giving them experience (data). Finally, the word “experience” for humans is way richer than it is for machines. In the next chapter, we’ll see that data is a minimal representation of reality. In contrast, human experience encompasses an incredible amount of factors such as sensorial input (taste, smell, vision, sound, texture); psychological, cultural, and socio-economical filters; and response, feelings, and bodily reactions.
Marcus du Sautoy, British mathematician and author of popular science books, gives a great example of human learning in a video by BBC Studios (“Why Learning like Humans Is So Difficult For Machines”). He sets up to learn a new task: walking across a wire by experience. Du Sautoy explains that this task encapsulates some essential facets of human learning: body control, reasoning, and instinct. He tries everything, and he seems not to get across the wire. At some point, his trainer suggests a little tip: “Try a little song as well, a little tune that makes you relax a bit.” Armed with the new trick, Marcus can learn to walk across the wire after several trials and errors. The scientist explains:
“We can’t fully explain how our brain is learning this way. I don’t know why the humming is helping, but it is.”
Human learning is a far richer experience than machine learning. Different ways of learning help everyone in a different way. For example, the scientific method enriches disciplines like marketing, history, and physical education which historically used other ways of acquiring knowledge. Marketing today relies heavily on psychology. Education relies on psychology and biology. In fact, a former teacher told me that the trick in the BBC video with du Sautoy is one that she was taught before entering the classroom — there’s science behind how music helps us to relax, learn, and even retain information. Fitness studies spend a lot of time talking about biology and the things that may be going on physiologically in our bodies in relation to nutrition, exercise, sexual health, etc.
The scientific method is only one technique humans use to learn, and it is a pretty recent one. For millions of years, humans learned with other methods. According to Price et al., humans learn by intuition, authority, rationalism, empiricism, and the scientific method. According to the Bahá’í faith, we do this with sense, reason, and tradition as well. Naveed adds commons sense, tenacity, and metaphysics.
My daughter learned about making smoke with wet wood by authority. In this sense, an authority is someone we know we can trust. And how do we know? We use intuition and common sense to establish that we can trust them. I learned about machine learning first by authority — I trusted a professor. Then I consolidated the learning by rationalizing and using the scientific method — trying out what I learned to see if it worked like I expected. Finally, it took me years of tenacity and applying the learning in real life, going over and over the same equations many times to make sure I could thoroughly understand what goes on in an algorithm.
I hope you enjoyed the last post of my article series, where I share excerpts and stories from my book, The Ethics of AI: Facts, Fictions, and Forecasts — if you enjoyed it and want to connect, you can reach me here via email or connect with me on social: LinkedIn, Twitter. Also, you can find my book on Amazon — here is the link to buy it.