Machine Learning With Python For Everyone Addison Wesley Data Analytics Series 1St Edition Pdf full chapter pdf docx

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 54

Machine Learning with Python for

Everyone (Addison Wesley Data &


Analytics Series) 1st Edition, (Ebook
PDF)
Visit to download the full and correct content document:
https://ebookmass.com/product/machine-learning-with-python-for-everyone-addison-
wesley-data-analytics-series-1st-edition-ebook-pdf/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Machine Learning for Time Series Forecasting with


Python Francesca Lazzeri

https://ebookmass.com/product/machine-learning-for-time-series-
forecasting-with-python-francesca-lazzeri/

Fundamentals of Machine Learning for Predictive Data


Analytics: Algorithms,

https://ebookmass.com/product/fundamentals-of-machine-learning-
for-predictive-data-analytics-algorithms/

Machine Learning on Geographical Data Using Python 1st


Edition Joos Korstanje

https://ebookmass.com/product/machine-learning-on-geographical-
data-using-python-1st-edition-joos-korstanje/

Beginner's Guide to Streamlit with Python: Build Web-


Based Data and Machine Learning Applications 1st
Edition Sujay Raghavendra

https://ebookmass.com/product/beginners-guide-to-streamlit-with-
python-build-web-based-data-and-machine-learning-
applications-1st-edition-sujay-raghavendra/
Time Series Algorithms Recipes: Implement Machine
Learning and Deep Learning Techniques with Python
Akshay R Kulkarni

https://ebookmass.com/product/time-series-algorithms-recipes-
implement-machine-learning-and-deep-learning-techniques-with-
python-akshay-r-kulkarni/

BIG DATA ANALYTICS: Introduction to Hadoop, Spark, and


Machine-Learning Raj Kamal

https://ebookmass.com/product/big-data-analytics-introduction-to-
hadoop-spark-and-machine-learning-raj-kamal/

Demystifying Big Data, Machine Learning, and Deep


Learning for Healthcare Analytics Pradeep N Sandeep
Kautish Sheng-Lung Peng

https://ebookmass.com/product/demystifying-big-data-machine-
learning-and-deep-learning-for-healthcare-analytics-pradeep-n-
sandeep-kautish-sheng-lung-peng/

Financial Machina: Machine Learning For Finance: The


Quintessential Compendium for Python Machine Learning
For 2024 & Beyond Sampson

https://ebookmass.com/product/financial-machina-machine-learning-
for-finance-the-quintessential-compendium-for-python-machine-
learning-for-2024-beyond-sampson/

Python Data Analytics: With Pandas, NumPy, and


Matplotlib, 3rd Edition Fabio Nelli

https://ebookmass.com/product/python-data-analytics-with-pandas-
numpy-and-matplotlib-3rd-edition-fabio-nelli-2/
5.9 EOC

5.9.1 Summary

5.9.2 Notes

5.9.3 Exercises

6 Evaluating Classifiers
6.1 Baseline Classifiers

6.2 Beyond Accuracy: Metrics for Classification

6.2.1 Eliminating Confusion from the Confusion


Matrix

6.2.2 Ways of Being Wrong

6.2.3 Metrics from the Confusion Matrix

6.2.4 To the Code!

6.2.5 Dealing with Multiple Classes: Multiclass


Averaging

6.2.6 F1

6.3 ROC Curves

6.3.1 Patterns in the ROC

6.3.2 Binary ROC

6.3.3 AUC: Area-Under-the-(ROC)-Curve

6.3.4 Multi-class Learners, One-Versus-Rest, and


ROC

6.4 Another Take on Multiclass: One-Versus-One

6.4.1 Multi-Class AUC Part Two: The Quest for a


Single Value

6.5 Precision-Recall Curves

6.6 Cumulative Response and Lift Curves

6.7 More Sophisticated Evaluation of Classifiers: Take


Two
6.7.1 Binary

6.7.2 A Novel Multi-class Problem

6.8 EOC

6.8.1 Summary

6.8.2 Notes

6.8.3 Exercises

7 Evaluating Regressors
7.1 Baseline Regressors

7.2 Additional Measures for Regression

7.2.1 Creating our Own Evaluation Metric

7.2.2 Other Built-in Regression Metrics


2
7.2.3 R

7.3 Residual Plots

7.3.1 Error Plots

7.3.2 Residual Plots

7.4 A First Look at Standardization

7.5 Evaluating Regressors in a more Sophisticated


Way: Take Two

7.5.1 Cross-Validated Results on Multiple Metrics

7.5.2 Summarizing Cross-Validated Results

7.5.3 Residuals

7.6 EOC

7.6.1 Summary

7.6.2 Notes

7.6.3 Exercises

III More Methods and Fundamentals


8 More Classification Methods
8.1 Revisiting Classification

8.2 Decision Trees

8.2.1 Tree Building Algorithms

8.2.2 Let’s Go: Decision Tree Time

8.2.3 Bias and Variance in Decision Trees

8.3 Support Vector Classifiers

8.3.1 Performing SVC

8.3.2 Bias and Variance in SVCs

8.4 Logistic Regression

8.4.1 Betting Odds

8.4.2 Probabilities, Odds, and Log-Odds

8.4.3 Just Do It: Logistic Regression Edition

8.4.4 A Logistic Regression: A Space Oddity

8.5 Discriminant Analysis

8.5.1 Covariance

8.5.2 The Methods

8.5.3 Performing DA

8.6 Assumptions, Biases, and Classifiers

8.7 Comparison of Classifiers: Take Three

8.7.1 Digits

8.8 EOC

8.8.1 Summary

8.8.2 Notes

8.8.3 Exercises

9 More Regression Methods


9.1 Linear Regression in the Penalty Box:
Regularization

9.1.1 Performing Regularized Regression

9.2 Support Vector Regression

9.2.1 Hinge Loss

9.2.2 From Linear Regression to Regularized


Regression to SV Regression

9.2.3 Just Do It - SVR Style

9.3 Piecewise Constant Regression

9.4 Regression Trees

9.4.1 Performing Regression with Trees

9.5 Comparison of Regressors: Take Three

9.6 EOC

9.6.1 Summary

9.6.2 Notes

9.6.3 Exercises

10 Manual Feature Engineering: Manipulating


Data for Fun and Profit
10.1 Feature Engineering Terminology and Motivation

10.1.1 Why Engineer Features?

10.1.2 When does Engineering Happen?

10.1.3 How does Feature Engineering Occur?

10.2 Feature Selection and Data Reduction: Taking


out the Trash

10.3 Feature Scaling

10.4 Discretization

10.5 Categorical Coding


10.5.1 Another Way to Code and the Curious Case
of the Missing Intercept

10.6 Relationships and Interactions

10.6.1 Manual Feature Construction

10.6.2 Interactions

10.6.3 Adding Features with Transformers

10.7 Target Manipulations

10.7.1 Manipulating the Input Space

10.7.2 Manipulating the Target

10.8 EOC

10.8.1 Summary

10.8.2 Notes

10.8.3 Exercises

11 Tuning Hyper-Parameters and Pipelines


11.1 Models, Parameters, Hyperparameters

11.2 Tuning Hyper-Parameters

11.2.1 A Note on Computer Science and Learning


Terminology

11.2.2 An Example of Complete Search

11.2.3 Using Randomness to Search for a Needle


in a Haystack

11.3 Down the Recursive Rabbit Hole: Nested Cross-


Validation

11.3.1 Cross-Validation, Redux

11.3.2 GridSearch as a Model

11.3.3 Cross-Validation Nested within Cross-


Validation

11.3.4 Comments on Nested CV


11.4 Pipelines

11.4.1 A Simple Pipeline

11.4.2 A More Complex Pipeline

11.5 Pipelines and Tuning Together

11.6 EOC

11.6.1 Summary

11.6.2 Notes

11.6.3 Exercises

IV Adding Complexity

12 Combining Learners
12.1 Ensembles

12.2 Voting Ensembles

12.3 Bagging and Random Forests

12.3.1 Bootstrapping

12.3.2 From Bootstrapping to Bagging

12.3.3 Through the Random Forest

12.4 Boosting

12.4.1 Boosting Details

12.5 Comparing the Tree-Ensemble Methods

12.6 EOC

12.6.1 Summary

12.6.2 Notes

12.6.3 Exercises

13 Models that Engineer Features For Us


13.1 Feature Selection
13.1.1 Single-Step Filtering with Metric Based
Feature Selection

13.1.2 Model Based Feature Selection

13.1.3 Integrating Feature Selection with a


Learning Pipeline

13.2 Feature Construction with Kernels

13.2.1 Manual Kernel Methods

13.2.2 Kernel Methods and Kernel Options

13.2.3 Kernelized SVCs: SVMs

13.2.4 Take Home Notes on SVM and an Example

13.3 Principal Components Analysis: An


Unsupervised Technique

13.3.1 A Warm Up: Centering

13.3.2 Finding a Different Best Line

13.3.3 A First PCA

13.3.4 Under the Hood with PCA

13.3.5 A Finale: Comments on General PCA

13.3.6 Kernel PCA and Manifold Methods

13.4 EOC

13.4.1 Summary

13.4.2 Notes

13.4.3 Exercises

14 Feature Engineering for Domains: Domain


Specific Learning
14.1 Working with Text

14.1.1 Encoding Text

14.1.2 Example of Text Learning


14.2 Clustering

14.2.1 K-Means Clustering

14.3 Working with Images

14.3.1 Bag of Visual Words

14.3.2 Our Image Data

14.3.3 An End-to-End System

14.3.4 Gathered Code BOVW Transformer

14.4 EOC

14.4.1 Summary

14.4.2 Notes

14.4.3 Exercises

15 Connections, Extensions, and Further


Directions
15.1 Optimization

15.2 Linear Regression from Raw Materials

15.3 Building Logistic Regression from Raw Materials

15.4 SVM from Raw Materials

15.5 Neural Networks

15.5.1 A NN view of Linear Regression

15.5.2 A NN view of Logistic Regression

15.5.3 Beyond Basic Neural Networks

15.6 Probabilistic Graphical Models

15.6.1 Sampling

15.6.2 A PGM view of Linear Regression

15.6.3 A PGM View of Logistic Regression

15.7 EOC

15.7.1 Summary
15.7.2 Notes

15.7.3 Exercises

A mlwpy.py Listing
Preface

In 1983, the movie WarGames came out. I was a pre-


teen and I was absolutely engrossed: by the possibility of
a nuclear apocalypse, by the almost magical way the lead
character interacted with computer systems, but mostly
by the potential of machines that could learn. I spent
years studying the strategic nuclear arsenals of the East
and the West —fortunately with a naivete of a tweener —
but it took almost 10 years before I took my first serious
steps in computer programming. Teaching a computer to
do a set process was amazing. Learning the intricacies of
complex systems and bending them around my curiosity
was a great experience. Still, I had a large step forward to
take. A few short years later, I worked with my first
program that was explicitly designed to learn. I was
blown away and I knew I found my intellectual home. I
want to share the world of computer programs that
learn with you.
Who do I think you are? I’ve written Machine Learning
(with Python) for Everyone for the absolute beginner to
machine learning. Even more so, you may well have very
little college level mathematics in your toolbox and I’m
not going to try to change that. While many machine
learning books are very heavy on mathematical concepts
and equations, I’ve done my best to minimize the
amount of mathematical luggage you’ll have to carry. I
do expect, given the book’s title, that you’ll have some
basic proficiency in Python. If you can read Python,
you’ll be able to get a lot more out of our discussions.
While many books on machine learning rely on
mathematics, I’m relying on stories, pictures, and
Python code to communicate with you. There will be the
occasional equation. Largely, these can be skipped if you
are so inclined. But, if I’ve done my job well, I’ll have
given you enough context around the equation to maybe
—just maybe —understand what it is trying to say.
Why might you have this book in your hand? The least
common denominator is that all of my readers want to
learn about machine learning. Now, you might be
coming from very different backgrounds: a student in an
introductory computing class focused on machine
learning, a mid-career business analyst who all of
sudden has been thurst beyond the limits of spreadsheet
analysis, a tech hobbyist looking to expand her interests,
a scientist needing to analyze your data in a new way.
Machine learning is permeating its way through society.
Depending on your background, Machine Learning
(with Python) for Everyone has different things to offer
you. Even a mathematically sophisticated reader who is
looking to do break in to machine learning using Python
can get a lot out of this book.

So, my goal is to take someone with an interest or need


to do some machine learning and teach them the process
and most important concepts of machine learning in a
concrete way using the Python scikit-learn library
and some of its friends. You’ll come awway with overall
patterns and strategies, pitfalls and gotchas, that will be
applied in every learning system you ever study, build, or
use.
Many books that try to convey mathematical topics, like
machine learning, do so by presenting equations as if
they tell a story to the uninitiated. I think that leaves
many of us —even those of us that like mathematics! —
stuck. For myself, I build a far better mental picture of
the process of machine learning by combining visual and
verbal descriptions with running code. I’m a computer
scientist at heart and by training. I love building things.
Building things is how I know that I’ve reached a level
where I really understand them. You might be familiar
with the phrase, “If you really want to know something,
teach it to someone.” Well, there’s a follow-on. “If you
really want to know something, teach a computer to do
it!” That’s my take on how I’m going to teach you
machine learning. With minimal mathematics, I want to
give you the concepts behind the most important and
frequently used machine learning tools and techniques.
Then, I want you to immediately see how to make a
computer do it. One note, we won’t be programming
these methods from scratch. We’ll be standing on the
shoulders of other giants and using some very powerful
and time-saving, pre-built software libraries —more on
that shortly.
We won’t be covering all of these libraries in great detail
—there is simply too much material to do that. Instead,
we are going to be practical. We are going to use the best
tool for the job. I’ll explain enough to orient you to the
concepts we’re using and then we’ll get to using it. For
our mathematically-inclined colleagues, I’ll give pointers
to more in-depth references they can pursue. I’ll save
most of this for end-of-the-chapter notes so the rest of us
can skip it easily.

If you are flipping through this introduction, deciding if


you want to invest time in this book, I want to give you
some insight into things that are out-of-scope for us. We
aren’t going to dive into mathematical proofs or rely on
mathematics to explain things. There are many books
out there that follow that path and I’ll give pointers to
my favorites at the ends of the chapters. Likewise, I’m
going to assume that you are fluent in basic- to
intermediate-level Python programming. However, for
more advanced Python topics —and things that shows up
from a 3rd party package like NumPy or Pandas —I’ll
explain enough of what’s going on so that you can
understand it and its context.
Our main focus is on the techniques of machine learning.
We will investigate a number of learning algorithms and
other processing methods along the way. However, our
goal is not completeness. We’ll discuss the most common
techniques. We will only glance briefly at two large sub-
areas of machine learning: graphical models and neural
or deep networks. But, we will see how the techniques we
focus on relate to these more advanced methods.
Another topic we won’t cover is implementing specific
learning algorithms. We’ll build on top of the algorithms
that are already available in scikit-learn and
friends: we’ll create larger solutions using them as
components. But, someone has to implement the gears
and cogs inside the black-box we funnel data into. If you
are really interested in implementation aspects, you are
in good company: I love them! Have all your friends buy
a copy of this book, so I can argue I need to write a
follow-up that dives into these lower-level details.

I must take a few moments to thank several people that


have contributed greatly to this book. My editor at
Pearson, Debra Williams, has been instrumental in every
phase of this books development. From our initial
meetings, to her probing for a topic that might meet both
our needs, to gently sheparding me through many
(many!) early drafts, to constantly giving me just enough
of a push to keep going, and finally climbing the steepest
parts of the mountain at its peek ... through all of these
phases, Debra has shown the highest degrees of
professionalism. I can only respond with a heartfelt
thank you.
My wife, Dr. Barbara Fenner, also deserves more praise
and thanks than I can give her in this short space. In
additional to the normal burdens that any partner of an
author must bear, she also served as my primary draft
reader and our intrepid illustrator. All of hte non-
computer generated diagrams in this book are thanks to
her hard work. While this is not our first joint academic
project, it has been turned into the longest. Her patience,
is by all appearances, never ending. Barbara, I thank
you!

My primarily technical reader was Marilyn Roth.


Marilyn was unfailing positive towards even my most
egregious errors. Machine Learning (with Python) for
Everyone is immeasurably better for her input. Thank
you.
Online resources for this book will be available at
https://github.com/mfenner1.
Part I. First Steps
Chapter 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. Yet, 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 breakdown 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 off
the assembly line to make sure their transistors didn’t
blow up when you turned them on and ran a program —
people don’t like smoke in their workspace. 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 awhile: 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 stratgies 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 benefits of those moves. At first, 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 evaulate 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 very carefully
express what the computer was told to do. Samuel did
not simply tell the computer to-play-checkers. He told
the computer to-learn-to-play-checkers. 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
five 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 field 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
specifically, 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 apolgies to Dr.
Seuss —they might be a Lorax or a Who, 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?
If you are so inclined, you can imagine —or glance at
Figure 1.1 —a cartoon character running around with a
basket of different measuring sticks which, when held up
to an object, return some characteristic of that object:
this vehicle has four wheels, this person has brown hair,
the temperature of that tea is 180F, and so on, ad
nauseaum. 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.

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 values for each
patient. Some relevant values are the height, weight, sex,
age, smoking history, systolic and diasystolic —that’s the
high and low numbers —blood pressures and resting
heart rate. The different 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 is a group of values for a given
attribute. Together, attribute-value pairs are a feature of
an example.

Notice that each example, a 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
when people talk about features or attributes, they are
trying to describe the same thing using either word as a
synonym. They are usually referring the column of
values. But, 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
first 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 typical, conversational usage and call
the columns features. If we are specifically 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 different groups of people.
We might see these groups in a census or an
epidemeological medical study: 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. Yes, you’re right: 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:

• 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


versus:

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, multi-column
form, it would take up three columns. Generally, we
aren’t motivated or worried about size here. Instead,
some learning methods are, shall we say, particular and
prefer 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. As such, we may lump them together under
the term numeric 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 —
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 generally can’t necessaryily perform
meaningful numerical calculations directly on those
values. If two states —say Pennsylvania and Vermont —
are coded as 2 and 14, it probably doesn’t make sense to
perform arithmetic on those values. There is an
exception. If, by design, those values mean something
beyond a unique identifier, we might be able to do some
or all of the maths. For extra credit, you might try to find
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 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) disease. To do so, we would need
another piece of information: did these folks develop
cardiovascular disease? If we have that information, we
can add it to the list of attributes. We could capture and
record the idea of “developing cardiovascular disease” in
several different ways. Did the patient:

• develop any heart disease within 10 years: yes/no


• develop X-level severity heart disease within 10
years: None or Grade I, II, III

• show some level of a specific indicator for heart


disease within 10 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 scientific puzzles we want to solve. Time is a
precious resource; we might not have 10 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 different
attributes to record.
In any case, we can pick a concrete, measurable target
and ask, “can we find 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 10 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 classification.
Here, we are using the term classification in the sense of
finding the different 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 categorical and
numeric, 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 numeric values and some
switches we can flip off and on. By adjusting the knobs
and switches, we can make different 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
arbitrily small and large values — –∞ to ∞, if you insist —
and we don’t strictly need on/off switches, since knobs
set to precisely 0 or 1 could serve a similar purpose.

Figure 1.2 Descriptions go in. Categories or other


values come out. We can adjust the machine to
improve the relationship between the ins and outs.

Moving forward, this factory image is a great entry point


to understand how learning algorithms figure out
relationships between features and a target. We can sit
down as the machine operator and press a magic —
probably green —go button. Materials roll in the
machine from the left and something pops out on the
right. Our curiosity gets the best of us and we twiddle the
dials and flip the switches. Then, different things pop out
the right-hand side. We turn up KnobOne and the
machine pays attendtion to the sounds that the input
object makes. We turn down KnobTwo and the machine
pays less attention to the number of limbs on the input
object. If we have a goal —if there is some known
product we’d like to see the machine produce —hopefully
our knob twiddling gets us closer to it.
Learning algorithms are formal rules for how we
manipulate our controls. After seeing examples where
the target is known, learning algorithms take a given big-
black-box and use a well-defined method to set the dials
and switches to good values. While good can be quite a
debatable quality in an ethics class, we have a gold-
standard: our known target values. If they don’t match,
we have a problem. The algorithm adjusts the control
panel settings so our predicted outs match the known
outs. Our name for the machine is a learning model or
just a model.

An example goes in to the machine and, based on the


settings of the knobs and switches, a class or a numerical
value pops out. Do you want a different output value
from the same input ingredients? Turn the knobs to
different settings or flip a switch. One machine has a
fixed set of knobs and switches. The knobs can be
turned, but we can’t add new knobs. If we add a knob, we
have a different machine. Amazingly, the differences
between knob-based learning methods boil down to
answering three questions:

1. What knobs and switches are there: what is on the


control panel?
2. How do the knobs and switches interact with an
input example: what are the inner workings of the
machine?
3. How do we set the knobs from some known data:
how do we align the inputs with the outputs we
want to see?

Many learning models that we will discuss can be


described as a machine with knobs and switches —with
no need of the additional side-input tray. Other methods
require the side-tray. We’ll hold off discussing that more
thoroughly, but you can flip to the discussion of nearest-
neighbors in Section 3.5, if your curiosity is getting the
best of you.
Each learning method —which we imagine as a black-
box factory machine and a way to set knobs on that
machine —is really an implementation of an algorithm.
For our purposes, an algorithm is a finite, well-defined
sequence of steps to solve a task. An implementation of
an algorithm is the specification of those steps in a
particular programming language. The algorithm is the
abstract idea; the implementation is the concrete
existence of that idea —or, at least as concrete as a
computer program can be! In reality, algorithms can also
be implemented in hardware —just like our factory
machines. It’s far easier for us to work with software.

1.4 EXAMPLES OF LEARNING


SYSTEMS
Under the umbrella of supervised learning from
examples, there is a major distinction between two
alternatives: predicting values and predicting categories.
Are we trying (1) to relate the inputs to one of a few
possible categories indicated by discrete symbols or (2)
to relate the inputs to a more-or-less continuous range of
numeric values? In short, is the target categorical or
numeric? As I mentioned, predicting a category is called
classification. Predicting a numeric value is called
regression. Let’s explore some examples of each.

1.4.1 Predicting Categories: Examples of Classifiers


Classifiers are models that take input examples and
produce an output that is one of a small number of
possible groups or classes:

1. Image Classification. From an input image,


output the animal (e.g., cat, dog, zebra) that is in
the image or none, if there is no animal present.
Image analysis of this sort is at the intersection of
machine learning and computer vision. Here, our
inputs will be a large collection of image files.
They might be in different formats (png, jpeg,
etc.). There may be substantial differences
between the images: (1) they might be at different
scales, (2) the animals may be centered or cut-off
on the edges of the frame, and (3) the animals
might be occluded by other things like a tree.
These all represent challenges for a learning
system —and for learning researchers! But, there
are some nice aspects to image recognition. Our
concept of cat and what images constitute a cat is
fairly fixed. Yes, there could be blurred
boundaries with animated cats —Hobbes,
Garfield, Heathcliff, I’m looking at you —but short
of evolutionary time scales, cat is a pretty static
concept. We don’t have a moving target: the
relationship between the images and our concept
of cat is fixed over time.
2. Stock Action From a stock’s price history,
company fundamental data, and other relevent
financial and market data, output whether we
should buy or sell a stock. This problem adds
some challenges. Financial records might only be
available in text form. We might be interested in
relevant news stories and we have to somehow
figure out what’s relevant —either by hand or
(perhaps!) another learning system. Once we’ve
figured out the relevant text, we have to interpret
it. These steps are where learning systems interact
with the field of natural language processing
(NLP). Continuing on with our larger task, we
have a time series of data —repeated
measurements over time. Our challenges are
piling up. In financial markets, we expect that we
probably have a moving target! What worked
yesterday to pick a winning stock is almost
certainly not going to work tomorrow in the exact
same way. We may need some sort of method or
technique that accounts for a changing
relationship between the inputs and the output.
Or, we may simply hope for the best and use a
technique that assumes we don’t have a moving
target. Disclaimer: I am not a financial advisor nor
am I offering investment advice.
3. Medical Diagnosis From a patient’s medical
record, output whether they are sick or healthy.
Here we have an even more complicated task. We
might be dealing with a combination of text and
images from medical records, notes, and medical
imaging. Depending on context that may or may
not be captured in the records —for example,
traveling to tropical areas opens up the possibility
of catching certain nasty diseases —different signs
and symptoms may lead to very different
diagnoses. Likewise, for all our vast knowledge of
medicine, we are only beginning to understand
some areas. It would be great for our system to be
able to read and study, like a doctor and
researcher, the latest and greatest techniques for
diagnosing patients. Learning to learn-to-learn is
a meta-task in the extreme.

These are big picture examples of classification systems.


As of 2019, learning systems exist that handle many
aspects of variations of these tasks. We will even dive
into basic image and language classifiers along our way.
While each of these examples has its own domain-
specific difficulties, they share a common task in
Another random document with
no related content on Scribd:
LETTER MCXCIV.
To Miss G――, at Clifton.

London, February 3, 1758.

Dear Madam,

I WAS glad, after so long a silence, to receive a line from Clifton,


where I find by report there is like to be a total revolution. Your
two worthy friends I have neither seen nor heard from; and good
Lady H――n I have not visited, because I believe her Ladyship
desired to be entirely private. I suppose she will now be soon in
town. God comfort her under all her trials, and sanctify new
creature-partings and disappointments to your further proficiency,
dear Madam, in the divine life. There is a needs-be for all this. God
help you to sing,

―――― O happy rod,

That brought me nearer to my God.

I have been in hopes of being with him. But I cannot go, though at
present reduced to the short allowance of preaching once a day,
except thrice on a Sunday, At both ends of the town, the word runs
and is glorified. The champions in the church go on like sons of
thunder. I am to be at Clapham this evening: Mr. V―― will gladly
embrace the first opportunity. May it be a Bethel! Bristol, in all
probability, will be my first Spring excursion. O that I may begin to
begin to spring for my God! I beg, dear Madam, the continuance of
your prayers, as being, dear Madam,
Your most obliged and ready servant in our glorious High-
priest,

G. W.

LETTER MCXCV.
To Mrs. B―― B――, at Bath.

London, February 3, 1758.

Dear Madam,

I CANNOT help acquainting you and your honoured sister, and Mrs.
G――, that the plan concerted some time ago is likely to be put in
execution. The trenches for the wall, I believe are begun, and by the
first of May, the houses are to be finished. If possible, I would furnish
them, that the poor might be sure of goods, as well as a house. All
things are possible with God. The thing hath scarce as yet taken
wind. Such secret expeditions, I trust, God will favour. Both
congregations and the divine influences increase. By thoughtfulness,
frequent preaching, and a crazy tabernacle, my nightly rests are
continually broken; but the joy of the Lord is my strength: and I hope
ere long to be where I shall keep awake for ever. I most earnestly
beg the continuance of your prayers, and you may be assured of
being always remembered in the poor addresses of, dear good
Ladies,

Your most obliged and ready servant for Christ’s sake,

G. W.
LETTER MCXCVI.
To the Reverend Mr. Samuel S――, in Bath.

London, February 3, 1758.

Reverend and dear Sir,

Y OUR kind letter drove me to my knees, and as I do not hear of


your dear and honoured father’s release, I suppose he is yet
detained a prisoner. I shall make public and private mention of him,
until I know he is gone beyond the reach of prayer, and entered upon
his eternal work of praise. I pity the poor ministers, who will sorely
miss him, but shall rejoice in his entering into his Master’s joy. Once
more I send the good old saint my most cordial salutations and
thanks unfeigned. At the great day, before men and angels, I shall do
it openly. Then likewise, my dear Sir, I hope to see you and yours
joining in one universal uninterrupted hallelujah, and casting your
crowns before the throne of the glorious Emmanuel. In whose great
name, with most sincere condolence with Mrs. S―― and all your
afflicted family, I once more beg leave to subscribe myself, reverend
and dear Sir,

Yours most affectionately in our common Lord,

G. W.

LETTER MCXCVII.
To Professor F――.

London, March 5, 1758.

Most reverend and dear Sir,


T HOUGH I am almost ashamed to put pen to paper, yet the kind
mention (as I hear from good Mr. Z――) you have been
pleased to make from time to time of me, together with the
importunities of that venerable man of God, have at length prevailed
upon me to trouble you with this letter. O that an infinitely
condescending Redeemer may excite you thereby, most honoured
Sir, to be instant in prayer for one who is the chief of sinners, and
less than the least of all saints. Long, long before now did I think of
entering into my wish’d-for rest. Times without number hath this
tabernacle groaned; but having obtained help from God, I yet
continue, in my poor way, to preach to all that are willing to hear, the
unsearchable riches of Jesus Christ. Through grace the fields are
as yet white, and as ready to harvest as ever. In the Summer I
range, and with a table for my pulpit, and the heavens for my
sounding-board, I am enabled generally thrice a day, to call to many
thousands to come to Jesus that they may have life. In the Winter I
am confined to this metropolis; but to my great mortification, through
continual vomiting, want of rest, and of appetite, I have been
reduced for some time to the short allowance of preaching only once
a day, except Sundays, when I generally preach thrice. Thousands
attend every evening at both ends of the town, and on Lord’s-days
many, many go away for want of room. The divine presence is
apparently amongst us, and every week produces fresh instances of
the power of converting grace. Blessed be God, we meet with no
disturbances in town, and very seldom in the country: but last year,
while I was preaching in the fields in Ireland, a popish mob was so
incensed at my preaching the Lord our Righteousness, and praying
for our good old King, and the King of Prussia, that they surrounded,
stoned, and almost killed me. But we are immortal till our work is
done, and glad should I have been to have died in such a cause. Mr.
W――y hath societies in Ireland and elsewhere; and though we
differ a little in some principles, yet brotherly love continues. I
generally, when itinerating, preach among his people, as freely as
among those who are called our own. In London several new flaming
preachers are come forth; and in various parts of the kingdom we
hear of divers others, who seem determined to know and preach
nothing but Jesus Christ, and him crucified. Thousands and
thousands are now praying daily for success to the Prussian and
Hanoverian arms. Your fast-days were kept here with great
solemnity, and will be so again, God willing, when I know the day.
Our Joshua’s are in the field. Many a Moses is gone up into the
mount to pray. Nil desperandum Christo duce, auspice Christo. The
ark trembles, but underneath are the everlasting arms of an
everlasting God. He that wrought such wonders for the Prussian
monarch last year, can repeat them this. Lord, we believe, help our
unbelief! The distresses of German protestants, we look upon as our
own. We have also endeavoured to give thanks for the great mercy
vouchsafed your Orphan-house, and the protestant cause. Lord
Jesus, repeat the occasions, for thine infinite mercy’s sake! Pardon,
pardon, most worthy Sir, the length of this, and impute it to the
encouragement given by the venerable Mr. Z―― to, most honoured
Sir,

Your dutiful son and servant,

G. W.

LETTER MCXCVIII.
To Mr. K――.

London, May 13, 1758.

My very dear Mr. K――,

I HOPE this will find you rejoicing in success given to dear Mr.
A――’s labours. If he is with you, be pleased to desire him to
prepare for coming to London immediately after Whitsuntide. He and
dear Mr. D―― may be in town whilst I take my Welch and West-
country range. I am unaccountably detained here; but I trust for
good. The word seems to run and be glorified more and more. I am
somewhat surprised that I hear nothing from Mr. P――, or my dear
Mr. S――d: but all is well. My hearty love to him and all his dear
relations. Can you fix no time for coming up? I do not hear of the
cyder being arrived. When shall we be called to drink the new wine
of the kingdom? Lord, give me patience to wait! I am quite puzzled.
Mr. P―― W――, without sending me a line, is come to Bristol, and
proposes staying there some time. The consequence of his coming,
is division and uneasiness already. I care not to go and fish in
troubled waters: neither can I advise you so to do: and yet I believe
your going would be a very great blessing. I expect a line from Mr.
D―― every hour, who, I suppose, is upon the road to London. If not
set out, defer it for a few days, and you shall hear, God willing, more
particularly from, my very dear man, in great haste, but greater love,

Yours, &c. &c. in our sympathizing Jesus,

G. W.

LETTER MCXCIX.
To Mr. ――.

Gloucester, May 22, 1758.

My very dear Sir,

I HOPE you got to London in great safety. Through divine goodness


I arrived at Gloucester on Saturday afternoon, and preached
thrice and gave the holy sacrament on Sunday. Thousands
attended, and our Lord gave us a blessed opening of the Summer
campaign. I am now writing in the room where I was born. Blessed
be God, I know there is a place where I was born again. That is my
native city indeed. After finishing this, I shall set out for Bristol, where
I propose staying over Sunday: then for Wales. My very dear Sir, add
to my obligations, by following me with your prayers. This tabernacle
makes me to groan. The one-horse chaise will not do for me. As it
will not quarter I am shaken to pieces. Driving likewise wearies me,
and prevents my reading; and if the road be bad, my servant that
rides the fore-horse is dirtied exceedingly. I have therefore sent to
Mr. S――’s about the post-chaise, and desired him to beg the favour
of you, my dear Sir, to look at it, and let me know your thoughts. This
is giving fresh trouble: but you are my friend. May the friend of all
richly reward you for all labours of love. He will, he will.—You shall
have a hundred-fold in this life, and in the world to come, life
everlasting. Being about to set off, I can only add my due and most
cordial respects to all your dear relations and enquiring friends, and
to beg the continuance of all your prayers, in behalf of, my very dear
Sir,

Yours most affectionately in our glorious Head,

G. W.

LETTER MCC.
To Mr. B――.

Bristol, May 24, 1758.

My dear Mr. B――,

D O not take my seeming long silence ill. Indeed it was


unavoidable. Ever since the receipt of your kind letter, I have
been so exceedingly and yet I trust profitably busied at London, that
till I left it last week, I had not one moment to spare. However, your
affair was not quite neglected. I communicated it to the physician of
the Foundling-Hospital, who is my constant hearer, and he wrote me
the enclosed letter, and sent me also the enclosed paper. I heartily
wish your design may take effect at Edinburgh. Glad should I be to
do any thing in my power to promote it, but I have little expectation of
seeing Scotland this year. The English work is so extensive, and the
blessed prospect of abundant success at London, hath kept me so
long there, that I shall be much straitned in time;—but if friends pray,
who knows what may be done. Lord Jesus, direct my goings in thy
way! On Sunday we opened the summer campaign in
Gloucestershire. Yesterday I came hither. In both places the fields
are white ready unto harvest. Fresh labourers are raised up in
Bedfordshire. A flamer (a learned clergyman) is broke forth, and
almost a whole parish, (I think in Buckinghamshire) is lately brought
to enquire after Jesus. I know you will say, may it spread far and
near! I must conclude. Excuse my not writing to all my dear, never to
be forgotten friends, and beg them to continue to pray for, dear Mr.
B――,

Theirs and yours, &c.

G. W.

LETTER MCCI.
To Mr. R―― K――n.

Bristol, May 26, 1758.

My very dear Mr. K――n,

R EPEATED acts of kindness and love, call for repeated


acknowledgments.—Accept therefore hearty thanks for your
last Salt-Hill favour, and assure yourself, that neither this nor any
former labour of love, will be forgotten by Him, who takes notice of a
cup of cold water given in the name of a disciple. Through his divine
goodness I got safe into Gloucestershire, where I opened the
summer campaign last Sunday. Ever since Tuesday evening, I have
been preaching here twice daily. Multitudes fly like doves to the
windows. Abiding impressions seem to be made.—This is the
Lord’s doing: to Him be all the glory! On next Monday, God willing, I
set out for Wales. I know you will follow me with your prayers. I am
sure mine always attend you and yours: I love such old steady
friends. It is Christ-like, not to be given to change.—Blessed be
God for an unchangeable Jesus!

To feel his power, to hear his voice,

To taste his love, be all our choice!

I must away to my throne.—Adieu! The Lord be with you and yours!


My hearty love to Mr. J――, and all who are so kind as to enquire
after, my very dear Mr. K――n,

Yours, &c. in our common Lord,

G. W.

LETTER MCCII.
Bristol, May 28, 1758. Nine in the morning.

My very dear Sir,

I AM quite ashamed, that I should give you so much trouble:—but


you are my friend indeed. May the never-failing friend of sinners
bless and reward you a thousand fold! I have been just now
preaching the unsearchable riches of his grace, to a multitude of
souls, in a fine square.—Presently, at eleven o’clock, the blessed
talk is to be repeated at Kingswood, and then once more in the
evening here. Yesterday I went to Bath. But every thing wearies this
shattered bark. To-morrow, God willing, I go for Wales. The chaise
must be my carriage. I would part with that, and my other, and then if
I could have a good four wheel carriage for thirty or forty pounds, the
expence would not be so great. I would not lay out a single farthing
but for my blessed Master. Mr. S―― is an honest friendly soul.—I
leave it entirely, my very dear Sir, to you and him. The Lord give you
to ride daily on in the chariot of his love. I return cordial thanks to
your mother and sisters for their concern for unworthy me.—Mrs.
G―― and B―― long to see them. I had a good season of christian
conversation at Bath, and found Sir C―― H――m really converted
unto God.—I doubt not but dear Mr. D――s will enjoy much of his
blessed presence.—Be pleased to present my hearty love to him,
and all, and accept the same for yourself and family, from, my very
dear Sir,

Yours most affectionately in our glorious Head,

G. W.

LETTER MCCIII.
To Countess D――.

Bristol, June 16, 1758.

Honoured Madam,

F OR this fortnight past, I expected never to have wrote to, or seen


your Ladyship, till I saw you sitting at Christ’s right hand.
Never was I brought so low as on my late Welch circuit. But as far as
I can hear, it was one of the most prosperous I ever took. Twice
every day, thousands and thousands attended in various towns in
South-Wales, and on the Sundays the numbers were incredible.
Surely they fled like doves to the windows. Welcome, thrice welcome
death in such a cause! Here, and in Gloucestershire, like scenes
were opened. Blessed expeditions these. I hope expeditions of
another nature will not be the worse for the prayers put up on such
occasions. They must and will enter the ears of the Lord of
Sabaoth. Blessed be God, that Sir Charles is so honestly and openly
embarked in Christ’s cause. My poor prayers are for him and his,
night and day. I hope to see good Lady G―― in my way to London.
In the mean while, praying that your Ladyship may more and more
be blessed in the latter stages of your road, and at last be admitted
with triumph into your Master’s joy, is the earnest prayer of,
honoured Madam,

Your Ladyship’s most dutiful, obliged servant for Christ’s


sake,

G. W.

LETTER MCCIV.
To Lady Fanny S――.

Bristol, June 16, 1758.

Honoured Madam,

I SHALL not for a good while forget my Twickenham journey. It was


a day much to be remembered by unworthy me. Lord, why am I
thus highly favoured? And yet (O unwearied goodness!) he
continues to bless me, vile as I am, more and more. O what
delightful field gospel-scenes have been displayed in
Gloucestershire, Bristol and Wales! There I have been feebly
labouring for above a fortnight.—Thousands and thousands attended
twice every day in various places, and on Sundays the numbers
were almost incredible. A blessed influence ran through the whole
circuit, and sundry times, I humbly hoped my longing soul would
have taken its wished-for flight; but I am preserved to return hither,
as last night, and perhaps next week shall see London. The Lord
Jesus direct my goings in his ways! Your Ladyship will remember a
poor worthless, but I trust willing pilgrim. You are called to enjoy your
Bethel at home; I meet with them abroad. The same God is rich unto
all that call on him faithfully. I hope your Ladyship hath seen dear Mr.
J―― grown in grace. It will be pleasant to see Sir Charles and the
Earl striving who shall go fastest to heaven. Your Ladyship will scorn
to be outstript by any. The almighty God approves the ambition, and
angels look down with pleasure to see the event. Blessed be God,
that is certain. All believers here do run, and all hereafter shall obtain
the prize. That your Ladyship may lay hold of it with exulting joy, is
the earnest prayer of, honoured Madam,

Your Ladyship’s most dutiful, obliged, and ready servant, for


Christ’s sake,

G. W.

LETTER MCCV.
To Captain H――y.

Bristol, June 16, 1758.

My very dear Sir,

T HE Welch roads have almost demolished my open one-horse


chaise, as well as me. But it is in Jesus’s cause. Grace! grace!
I am almost ashamed to think of your being put to so much trouble,
in procuring a close chaise for unworthy me. I like the purchase
exceeding well, and send a pepper-corn of acknowledgment for this
and all other unmerited favours. The God whom I desire to serve in
the gospel of his dear Son, knows and will reward all. Though I
thought I heard the sound of my blessed Master’s chariot wheels
ready to carry me to heaven, yet it should seem I am once more to
see you, and your dear relations, and my other christian friends on
earth. Some time next week I hope to be there. The legacy is
wonderful; much better left for the poor than me. I can give it away
with a good grace: at present I think the Orphan-house shall have
the whole; it is much wanted there. See, my dear Sir, how the
christian’s blessings must be brought out of the fire. It is
inconceivable what I have undergone within these three weeks. I
never was so before. I trust some lasting blessings have been left
behind in Wales. Welcome shocks, both of body and mind. In such a
case it is worth dying for. Dear Mr. D―― hath felt them in London,
as I have done in Wales.—All for the Elect’s sake. Welcome, thrice
welcome the bitter sweets, which the all-wise and compassionate
Physician prescribes; but I am a stubborn patient. O what gripings of
the old man are discovered by such dispensations! I must away to
preach. I thank you heartily, dear Sir, for the continuance of your
prayers, and with most cordial respects to your dear and near
relations, I beg leave to subscribe myself,

Yours, &c.

G. W.

LETTER MCCVI.
To Lady H――n.

Bristol, June 17, 1758.

Ever-honoured Madam,

T HIS leaves me returned from Wales. It proved a most delightful


trying circuit. I suppose your Ladyship hath heard how low I
have been in body, scarce ever lower; not able to sit up in company
all the time, yet strengthened to travel without bodily food, and to
preach to thousands everyday. Never were the fields whiter, and
more ready to harvest. The Lord Jesus seemed to ride in triumph
through the great congregation in Haverford-west. Perhaps the
auditory consisted of near fifteen thousand. Tears flowed like water
from the stony rock. The cup of God’s people quite runs over. Many
were sick of love. Welcome then bodily pain, and bodily sickness! O
for a hearse to carry my weary carcase to the wished-for grave!
“There the wicked cease from troubling, there the weary are at rest.”
But perhaps I must see London first. With regret I turn my back on
this blessed itinerating weather, but Mr. Dav―― must be released.
O for some disinterested soul to help at the chapel during the
summer season! Spiritual, divine ambition, whither art thou fled! But I
see such honours are reserved for few. I rejoice in the increase of
your Ladyship’s spiritual routs. I can guess at the consolations such
uncommon scenes must afford to your Ladyship’s new-born soul. No
wonder you are distressed from other quarters. Indeed, my most
noble and ever-honoured patroness, thus it must be. Christ’s
witnesses must be purged at home. Inward domestic trials, fit for
outward public work. Nature recoils, when constrained to take the
cup; and it may be from a near and dear relation’s hand: but infinite
Wisdom knows what is best. O that I could be more passive! O that I
could let the good and all-wise Physician chuse my medicines, and
the hands that shall convey them to me! but I am a stubborn
reasoning creature, and thereby force almighty love frequently to
drench me. O, I am sick! I am sick! sick in body, but infinitely more so
in my mind,—to see what dross yet remains in, and surrounds my
soul. Blessed be God, there is one, who will sit as a refiner’s fire,
and purify the sons of Levi. O for an heart to bear its scorching, soul
purging heat! When I am tried, I shall come forth as gold. I write this
to your Ladyship out of the burning bush. Blessed place! Christ is
there! Christ is there! To his never-failing mercy do I most humbly
commend your Ladyship, and with ten thousand thousand thanks for
honouring such an unfruitful unworthy worm with your unmerited
patronage, I beg leave to subscribe myself, ever-honoured Madam,

Your Ladyship’s most dutiful, and ready servant, for


Christ’s sake,

G. W.
LETTER MCCVII.
To Mr. S――.

Newcastle, July 31, 1758.

My very dear Sir,

T HUS far, a never-failing Redeemer hath brought on the most


worthless and weak pilgrim, that was ever employed in
publishing his everlasting gospel. All the last week was taken up in
preaching at Everton, Saint Neots, Kayso, Bedford, Oulney, Weston,
Underwood, Ravenstone and Northampton. Four clergymen lent me
their churches, and three read prayers for me in one day. I preached
also in Mr. Bunyan’s pulpit, and at Northampton I took the field. Good
seasons at all the places. Mr. B――e, who was lately awakened at
Everton, promises to be a burning and shining light. Yesterday we
had good times here, and to-morrow, God willing, I shall set off for
Edinburgh. My bodily strength increases but very little. Sometimes I
am almost tempted to turn back, but through divine strength I hope
to go forward, and shall strive, as much as in me lies, to die in this
glorious work. God will bless you and yours, my very dear Sir, for
strengthening my feeble hands in it, so often as you have done.
Jesus knows, and will reward all labours of love and works of faith.
They are more precious than rubies. God willing, you shall hear from
me again, when I see how the Lord deals with me in Scotland. In
the mean while, be pleased to add to my obligations by the
continuance of your prayers, and accepting of thanks unfeigned, and
cordial love to your whole self, and dear daughter, from, my very
dear friend,

Yours most affectionately in our glorious Head,

G. W.
LETTER MCCVIII.
To the Reverend Mr. G――.

Edinburgh, August 10, 1758.

My very dear Friend,

I THANK you most heartily for your kind letter of invitation to G――.
But alas! what shall I say?—I fear it cannot be complied with. For
above these three months last past, I have been so weak in my
animal frame, that I can scarcely drag the crazy load along. With
great difficulty I came here, and if I should stay to come westward, it
would make my journey to London too far in the year, as I have
many places to call upon in the way. Blessed be God, the work
prospers in London more than ever. I am strengthened to preach
here twice a day; but alas, I grow weaker and weaker in preaching,
and in all I do for the ever-loving and altogether lovely Jesus. I
suppose you have heard of the death of Mr. Jonathan Edwards.—
Happy he!—You will add to my obligations, by continuing to pray,
that the divine strength may be magnified in my weakness, and that I
may speedily (if it be the divine will) be sent for to my wished-for
heaven!—Praying that we may have a happy meeting there, with ten
thousand thanks for all past unmerited kindnesses, I subscribe
myself, very dear friends,

Yours, &c. in our common glorious Head,

G. W.

P. S. My tender love awaits all enquiring friends.

LETTER MCCIX.
To Mr. ――.

Edinburgh, August 15, 1758.

My very dear Sir,

N OT till last Saturday, did your first long wished-for letter come to
hand. I wonder that I―― C―― did not dispatch it
immediately. As I knew not what its contents would be, I did not write
to Staffordshire; for I was and am determined to fix upon nothing
without advising with you. And indeed, I think the whole must be put
off till we can have a free conference. In the mean while, I shall write
to our young friend, and pray that the friend of all would direct in this
important affair. He will, he will. It is not with Mr. S―― as you
imagine. He is quite free. But more of this when we meet.—When we
meet! strange words for a dying man!—But it seems I am growing
better. Within these four days I have felt a great alteration.—Perhaps
it may continue. God’s will be done. Surely, never was there so weak
a creature ever employed in such a work for God,—and yet people
flock rather more than ever. Doctor W―― and Mr. R―― often wish
you here. We have two lovely scenes every day. I hope the
Redeemer will come with dear Mr. D――. I bless him for returning
you, my dear Sir, in safety. My most cordial respects attend your
dear relations, and beg the continuance of your prayers, for, my very
dear Sir,

Yours, &c.

G. W.

LETTER MCCX.
To the Reverend Mr. T――.

Edinburgh, August 17, 1758.


My very dear Friend,

I T is a little hard, that we should be so near, and not have a


personal interview. But our Lord orders all things well. Most of
my christian meetings must be adjourned to heaven. Thither I have
been in hopes of going for many weeks last past: but it will not do.
This preaching is a strange restorative. I wish you may take it every
day. If things are not right at home, it is well if we can take or catch
fire abroad. Would strength permit, I could tell you much good news
from London. But time is short, and this my body weighs me down. I
have thoughts of leaving Edinburgh on Tuesday next, in order to
return to England. Friends object much against it. May the friend of
all, guide and influence. I find no diminution in the auditories, and I
trust good is done. To the giver of every good gift be all the glory! I
commend you and yours to his never-failing mercy, and beg the
continuance of your prayers in behalf of, my very dear friend,

Yours most affectionately in our common Lord,

G. W.

LETTER MCCXI.
To Mr. S――.

Edinburgh, August 19, 1758.

My very dear Sir,

I CAME here a fortnight ago, very low indeed; but by preaching


about thirty times, blessed be God, I am a good deal better.
Multitudes, of all ranks, flock twice every day. A divine influence
attends the word, and though sown in so much weakness, I trust it
will meet with a divine increase. On Tuesday next, I thought to have
moved; but as it is race week, and my health is improving, friends
advise me to stay, to stir them up to run with patience the race which
is set before us. O that my sluggish soul may be quickened, and I
may begin to press forwards, for the prize of my high calling! I doubt
not but this will find my dear friend upon the wing for heaven. That
you and yours may mount higher and higher like an eagle, till you fly
into the bosom of a waiting God, is the earnest prayer of, my very
dear Sir,

Yours, &c. in our glorious Head,

G. W.

LETTER MCCXII.
To the Reverend Mr. G――.

Edinburgh, August 24, 1758.

Reverend and very dear Sir,

A FTER long meditation and earnest prayer, I cannot come to any


determination about my journey to Glasgow. For these four
months last past, I have been brought so exceeding low in my body,
that I was in hopes every sermon I preached would waft me to my
wish’d-for home. Scotland, I hoped, would finish my warfare; but it
hath rather driven me back to sea again. By force I have been
detained here this race week; but if I come to Glasgow, I shall be
detained in Scotland a fortnight longer, which will greatly hinder me
in my English work. However, I will continue to look up; and by
Saturday’s post my dear Gaius may expect a positive answer. Lord
Jesus, direct my goings in thy way! I am much obliged to you and
other dear Glasgow friends for taking notice of such a worthless
creature. All I can say is, that I am less than the least of all, but for
Christ’s sake, reverend and very dear Sir,
Theirs and yours most affectionately in our glorious Head,

G. W.

LETTER MCCXIII.
To the Reverend Mr. T――.

Edinburgh, September 9, 1758.

My very dear Friend,

I T is strange that you and I cannot be more together. I believe


Satan doth not like it: ere long we shall get out of his reach. In
heaven we shall enjoy our God and each others company for ever.
O that I moved faster towards it! Complain not. I am the drone, the
dwarf, the all that is worthless and unworthy; but Jesus’ grace is free
and infinite. He owned my feeble labours at Glasgow. Indeed we had
good seasons: some quite remarkable. I hear of another clergyman
lately awakened in the north of England. Something uncommon is
upon the carpet. Lord, prepare us for whatever thou hast prepared
for us. Wednesday next is execution-day; I mean, I am to take my
leave. I now bid you and yours farewel. God bless you. Forget not to
pray, my very dear friend, for,

Ever yours, &c.

G. W.

LETTER MCCXIV.
To Mr. S――.

You might also like