0% found this document useful (0 votes)
90 views5 pages

Machine Learning Basics Explained

Master machine learning with Python, regardless of your skill level. Mark E. Fenner has designed this for people new to Machine Learning who can write Python code. Through plain-English explanations, visual aids, and practical examples, you'll learn the processes, patterns, and strategies for building effective learning systems. Explore key mathematical and computational topics in an accessible way and follow step-by-step instructions to build, train, and evaluate learning systems.

Uploaded by

Jordan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views5 pages

Machine Learning Basics Explained

Master machine learning with Python, regardless of your skill level. Mark E. Fenner has designed this for people new to Machine Learning who can write Python code. Through plain-English explanations, visual aids, and practical examples, you'll learn the processes, patterns, and strategies for building effective learning systems. Explore key mathematical and computational topics in an accessible way and follow step-by-step instructions to build, train, and evaluate learning systems.

Uploaded by

Jordan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1

Let’s Discuss Learning

1.1 Welcome
From time to time, people trot out a tired claim that computers can “only do what they
are told to do.” The claim is taken to mean that computers can only do what their
programmers know how to do and can explain to the computer. This claim is false.
Computers can perform tasks that their programmers cannot explain to them. Computers
can solve tasks that their programmers do not understand. We will break down this
paradox with an example of a computer program that learns.
I’ll start by discussing one of the oldest — if not the oldest known — examples of a
programmed machine-learning system. I’ve turned this into a story, but it is rooted in
historical facts. Arthur Samuel was working for IBM in the 1950s and he had an interesting
problem. He had to test the big computing machines that were coming o昀昀 the assembly
line to make sure transistors didn’t blow up when you turned a machine on and ran a
program — people don’t like smoke in their workplace. Now, Samuel quickly got bored
with running simple toy programs and, like many computing enthusiasts, he turned his
attention towards games. He built a computer program that let him play checkers against
himself. That was fun for a while: he tested IBM’s computers by playing checkers. But, as
is often the case, he got bored playing two-person games solo. His mind began to consider
the possibility of getting a good game of checkers against a computer opponent. Problem was,
he wasn’t good enough at checkers to explain good checkers strategies to a computer!
Samuel came up with the idea of having the computer learn how to play checkers. He
set up scenarios where the computer could make moves and evaluate the costs and bene昀椀ts
of those moves. At 昀椀rst, the computer was bad, very bad. But eventually, the program
started making progress. It was slow going. Suddenly, Samuel had a great two-for-one idea:
he decided to let one computer play another and take himself out of the loop. Because the
computers could make moves much faster than Samuel could enter his moves — let alone
think about them— the result was many more cycles of “make a move and evaluate the
outcome” per minute and hour and day.
Here is the amazing part. It didn’t take very long for the computer opponent to be
able to consistently beat Samuel. The computer became a better checkers player than its
programmer! How on earth could this happen, if “computers can only do what they are told
to do”? The answer to this riddle comes when we analyze what the computer was told to

Humble Bundle Pearson AI Bundle Ñ © Pearson. Do Not Distribute.


4 Chapter 1 Let’s Discuss Learning

do. What Samuel told the computer to do was not the play-checkers task; it was the
learn-to-play-checkers task. Yes, we just went all meta on you. Meta is what happens when
you take a picture of someone taking a picture (of someone else). Meta is what happens
when a sentence refers to itself; the next sentence is an example. This sentence has 昀椀ve
words. When we access the meta level, we step outside the box we were playing in and we
get an entirely new perspective on the world. Learning to play checkers — a task that develops
skill at another task— is a meta task. It lets us move beyond a limiting interpretation of
the statement, computers can only do what they are told. Computers do what they are told, but
they can be told to develop a capability. Computers can be told to learn.

1.2 Scope, Terminology, Prediction,


and Data
There are many kinds of computational learning systems out there. The academic 昀椀eld
that studies these systems is called machine learning. Our journey will focus on the current
wunderkind of learning systems that has risen to great prominence: learning from examples.
Even more speci昀椀cally, we will mostly be concerned with supervised learning from examples.
What is that? Here’s an example. I start by giving you several photos of two animals you’ve
never seen before— with apologies to Dr. Seuss, they might be a Lorax or a Who— and
then I tell you which animal is in which photo. If I give you a new, unseen photo you
might be able to tell me the type of animal in it. Congratulations, you’re doing great! You
just performed supervised learning from examples. When a computer is coaxed to learn
from examples, the examples are presented a certain way. Each example is measured
on a common group of attributes and we record the values for each attribute on each
example. Huh?
Imagine— or glance at Figure 1.1— a cartoon character running around with a
basket of di昀昀erent measuring sticks which, when held up to an object, return some
characteristic of that object, such as this vehicle has four wheels, this person has brown hair, the
temperature of that tea is 180◦ F, and so on ad nauseam (that’s an archaic way of saying until
you’re sick of my examples).

Figure 1.1 Humans have an insatiable desire to measure all sorts of things.

Humble Bundle Pearson AI Bundle Ñ © Pearson. Do Not Distribute.


1.2 Scope, Terminology, Prediction, and Data 5

1.2.1 Features
Let’s get a bit more concrete. For example — a meta-example, if you will — a dataset
focused on human medical records might record several relevant values for each patient,
such as height, weight, sex, age, smoking history, systolic and diastolic (that’s the high and
low numbers) blood pressures, and resting heart rate. The di昀昀erent people represented in
the dataset are our examples. The biometric and demographic characteristics are our
attributes.
We can capture this data very conveniently as in Table 1.1.

Table 1.1 A simple biomedical data table. Each row is an example. Each column
contains values for a given attribute. Together, each attribute-value pair is a feature of an
example.
patient id height weight sex age smoker hr sys bp dia bp
007 5’2” 120 M 11 no 75 120 80
2139 5’4” 140 F 41 no 65 115 75
1111 5’11” 185 M 41 no 52 125 75

Notice that each example — each row — is measured on the same attributes shown in
the header row. The values of each attribute run down the respective columns.
We call the rows of the table the examples of the dataset and we refer to the columns as
the features. Features are the measurements or values of our attributes. Often, people use
“features” and “attributes” as synonyms describing the same thing; what they are referring
to are the column of values. Still, some people like to distinguish among three concepts:
what-is-measured, what-the-value-is, and what-the-measured-value-is. For those strict folks, the
昀椀rst is an attribute, the second is a value, and the last is a feature— an attribute and a value
paired together. Again, we’ll mostly follow the typical conversational usage and call the
columns features. If we are speci昀椀cally talking about what-is-measured, we’ll stick with the
term attribute. You will inevitably see both, used both ways, when you read about machine
learning.
Let’s take a moment and look at the types of values our attributes — what is
measured— can take. One type of value distinguishes between di昀昀erent groups of people.
We might see such groups in a census or an epidemiological medical study — for
example, sex {male, female} or a broad record of ethnic-cultural-genetic heritage
{African, Asian, European, Native American, Polynesian}. Attributes like these are called
discrete, symbolic, categorical, or nominal attributes, but we are not going to stress about
those names. If you struggled with those in a social science class, you are free to give a
hearty huzzah.
Here are two important, or at least practical, points about categorical data. One point
is that these values are discrete. They take a small, limited number of possibilities that
typically represent one of several options. You’re right that small and several are relative
terms — just go with it. The second point is that the information in those attributes can be
recorded in two distinct ways:

Humble Bundle Pearson AI Bundle Ñ © Pearson. Do Not Distribute.


6 Chapter 1 Let’s Discuss Learning

. As a single feature that takes one value for each option, or


. As several features, one per option, where one, and only one, of those features is
marked as yes or true and the remainder are marked as no or false.
Here’s an example. Consider

Name Sex
Mark Male
Barb Female
Ethan Male

versus:

Name Sex is Female Sex is Male


Mark No Yes
Barb Yes No
Ethan No Yes

If we had a column for community type in a census, the values might be Urban, Rural,
and Suburban with three possible values. If we had the expanded, multicolumn form, it
would take up three columns. Generally, we aren’t motivated or worried about table size
here. What matters is that some learning methods are, shall we say, particular in preferring
one form or the other. There are other details to point out, but we’ll save them for later.
Some feature values can be recorded and operated on as numbers. We may lump them
together under the term numerical features. In other contexts, they are known as continuous
or, depending on other details, interval or ratio values. Values for attributes like height and
weight are typically recorded as decimal numbers. Values for attributes like age and blood
pressure are often recorded as whole numbers. Values like counts— say, how many wheels
are on a vehicle— are strictly whole numbers. Conveniently, we can perform arithmetic
(+, −, ×, / ) on these. While we can record categorical data as numbers, we can’t
necessarily perform meaningful numerical calculations directly on those values. If two
states — say, Pennsylvania and Vermont— are coded as 2 and 14, it probably makes no
sense to perform arithmetic on those values. There is an exception: if, by design, those
values mean something beyond a unique identi昀椀er, we might be able to do some or all of
the maths. For extra credit, you can 昀椀nd some meaning in the state values I used where
mathematics would make sense.

1.2.2 Target Values and Predictions


Let’s shift our focus back to the list of biomedical attributes we gathered. As a reminder,
the column headings were height, weight, sex, age, smoker, heart rate, systolic blood
pressure, and diastolic blood pressure. These attributes might be useful data for a health
care provider trying to assess the likelihood of a patient developing cardiovascular heart. To
do so, we would need another piece of information: did these folks develop heart disease?

Humble Bundle Pearson AI Bundle Ñ © Pearson. Do Not Distribute.


1.3 Putting the Machine in Machine Learning 7

If we have that information, we can add it to the list of attributes. We could capture and
record the idea of “developing heart disease” in several di昀昀erent ways. Did the patient:
. Develop any heart disease within ten years: yes/no
. Develop X-level severity heart disease within ten years: None or Grade I, II, III
. Show some level of a speci昀椀c indicator for heart disease within ten years: percent of
coronary artery blockage
We could tinker with these questions based on resources at our disposal, medically
relevant knowledge, and the medical or scienti昀椀c puzzles we want to solve. Time is a
precious resource; we might not have ten years to wait for an outcome. There might be
medical knowledge about what percent of blockage is a critical amount. We could modify
the time horizon or come up with di昀昀erent attributes to record.
In any case, we can pick a concrete, measurable target and ask, “Can we 昀椀nd a
predictive relationship between the attributes we have today and the outcome that we will
see at some future time?” We are literally trying to predict the future— maybe ten years from
now — from things we know today. We call the concrete outcome our target feature or
simply our target. If our target is a category like {sick, healthy} or {None, I, II, III}, we call
the process of learning the relationship classi昀椀cation. Here, we are using the term
classi昀椀cation in the sense of 昀椀nding the di昀昀erent classes, or categories, of a possible
outcome. If the target is a smooth sweeping of numerical values, like the usual decimal
numbers from elementary school {27.2, 42.0, 3.14159, −117.6}, we call the process
regression. If you want to know why, go and google Galton regression for the history lesson.
We now have some handy terminology in our toolbox: most importantly features, both
either categorical or numerical, and a target. If we want to emphasize the features being used
to predict the future unknown outcome, we may call them input features or predictive
features. There are a few issues I’ve swept under the carpet. In particular, we’ll address some
alternative terminology at the end of the chapter.

1.3 Putting the Machine in Machine


Learning
I want you to create a mental image of a factory machine. If you need help, glance at
Figure 1.2. On the left-hand side, there is a conveyor belt that feeds inputs into the
machine. On the right-hand side, the machine spits out outputs which are words or
numbers. The words might be cat or dog. The numbers might be {0, 1} or {−2.1, 3.7}.
The machine itself is a big hulking box of metal. We can’t really see what happens on the
inside. But we can see a control panel on the side of the machine, with an operator’s seat in
front of it. The control panel has some knobs we can set to numerical values and some
switches we can 昀氀ip on and o昀昀. By adjusting the knobs and switches, we can make
di昀昀erent products appear on the right-hand side of the machine, depending on what came
in the left-hand side. Lastly, there is a small side tray beside the operator’s chair. The tray
can be used to feed additional information, that is not easily captured by knobs and
switches, into the machine. Two quick notes for the skeptical reader: our knobs can get us

Humble Bundle Pearson AI Bundle Ñ © Pearson. Do Not Distribute.

Common questions

Powered by AI

The concept of "target features" in a dataset guides the development of predictive machine learning models by providing the specific outputs that the model is trained to predict. These targets are critical because they define the goal of the predictive analysis, influencing the choice of learning tasks, such as classification or regression, based on whether the targets are categorical or numerical. Understanding the nature and structure of target features directly impacts how input features are selected, processed, and used to train models, ensuring the model optimally predicts real-world outcomes based on past data .

Supervised learning utilizes categorical and numerical data by transforming them into a form that models can interpret to identify patterns. Categorical data is often encoded into numerical form to integrate seamlessly with numerical data, allowing for the application of algorithms that rely on mathematical computations. A predictive model uses both data types; for example, it might consider numerical features like age or blood pressure alongside categorical features like gender or smoker status to develop a comprehensive understanding of the predictors affecting the target outcome .

Supervised learning from examples aids in making predictions by training a model using input data composed of example features and corresponding known outcomes, called target values. The input features help the model learn patterns or relationships to predict the target values of new, unseen examples. Target values serve as the outcomes the learning process seeks to predict, playing a crucial role in guiding the learning algorithm to understand the predictive relationship between input features and outcomes .

Arthur Samuel's programming approach exemplified meta-learning by instructing the computer not directly to play checkers, but to learn how to play checkers. This distinction highlighted meta-learning, where the computer was told to develop a capability — the ability to learn rather than execute a predefined task. By setting the computer to play against itself, Samuel enabled it to evaluate moves and improve, eventually surpassing his own playing skill. This approach demonstrated that computers could perform tasks their programmers couldn't explain to them once given the capacity to learn from experience .

The significance of the "meta" concept in machine learning, as illustrated by Arthur Samuel's checkers program, lies in its demonstration that machines can be instructed to learn tasks rather than perform direct assignments. Samuel's program shifted the task from playing checkers to learning how to play, which is a higher level of abstraction and allows the machine to develop competence in unexpected and complex ways. This meta approach broadens the capabilities of computers beyond their initial programming, as they learn from experience and self-correct over time to become proficient at tasks originally beyond the programmer’s detailed instructions .

Arthur Samuel's work on checkers counters the claim that computers can only do what they are explicitly programmed to do by demonstrating a computer's ability to learn and improve beyond the programmer’s explicit knowledge. Instead of programming the computer with specific strategies to play checkers, Samuel instructed the computer to learn those strategies independently. It engaged in a process of self-play, refining its ability through trial and error and evaluation of moves. This learning process enabled the computer to surpass Samuel’s own playing skills, showing that while computers follow the instructions given, they can develop capabilities, such as strategic thinking, that the programmers themselves might not possess .

Understanding feature types impacts the choice of machine learning methods as various algorithms have specific requirements or preferences for handling data. Continuous features are numerical and support mathematical operations, making them suitable for techniques involving calculations, like linear regression. Categorical features require different handling, such as encoding into numerical form if needed, to fit algorithms that expect only numeric input. Certain methods, like decision trees, naturally handle categorical data by partitioning data based on discrete attribute values. Thus, identifying feature types helps in selecting algorithms that efficiently process the available data .

In machine learning, features refer to the columns of values, which are derived from measuring various attributes. An attribute is what is measured, while a value is the specific result of that measurement. Together, an attribute and its corresponding value form a feature. For instance, in a biomedical dataset, attributes could be height, weight, and age, with their respective values forming features. Although features and attributes are often used interchangeably in conversational use, a clear understanding of their distinction is crucial for precise discussion about data .

In machine learning, a dataset is structured such that each row represents an example, and each column represents a feature. Features are the specific attributes or measurements related to the examples. For instance, in a biomedical dataset, rows could represent individual patients, while columns could reflect attributes like height, weight, and age. Each cell in this table, indicative of a feature, holds the value of the attribute for that specific example, such as a patient’s height in inches .

Numerical calculations cannot be performed directly on categorical data because these data types represent discrete groups or categories rather than continuous values. Arithmetic operations on such assigned numerical codes would have no meaningful interpretation, as they do not represent mathematical relationships. However, an exception exists when these categorical values are designed to hold ordinal significance, such as severity levels or rankings, where mathematical operations can provide contextual insights .

You might also like