78% found this document useful (9 votes)
204 views66 pages

Artificial Intelligence Programming with Python from Zero to Hero 1st Edition Perry Xiao all chapter instant download

Programming

Uploaded by

hfhfkaxelo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
78% found this document useful (9 votes)
204 views66 pages

Artificial Intelligence Programming with Python from Zero to Hero 1st Edition Perry Xiao all chapter instant download

Programming

Uploaded by

hfhfkaxelo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 66

Download Full Version ebookmass - Visit ebookmass.

com

Artificial Intelligence Programming with Python


from Zero to Hero 1st Edition Perry Xiao

https://ebookmass.com/product/artificial-intelligence-
programming-with-python-from-zero-to-hero-1st-edition-perry-
xiao/

OR CLICK HERE

DOWLOAD NOW

Discover More Ebook - Explore Now at ebookmass.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

Prolog programming for artificial intelligence 4ed.


Edition Ivan Bratko

https://ebookmass.com/product/prolog-programming-for-artificial-
intelligence-4ed-edition-ivan-bratko/

ebookmass.com

Swarm Intelligence: An Approach from Natural to Artificial


1st Edition Kuldeep Singh Kaswan

https://ebookmass.com/product/swarm-intelligence-an-approach-from-
natural-to-artificial-1st-edition-kuldeep-singh-kaswan/

ebookmass.com

Python for Artificial Intelligence. A Comprehensive Guide


Elsherif H.

https://ebookmass.com/product/python-for-artificial-intelligence-a-
comprehensive-guide-elsherif-h/

ebookmass.com

(eTextbook PDF) for We the People (Core Twelfth Edition)


12th Edition

https://ebookmass.com/product/etextbook-pdf-for-we-the-people-core-
twelfth-edition-12th-edition/

ebookmass.com
Handbook of Robotic and Image-Guided Surgery Mohammad H.
Abedin-Nasab (Editor)

https://ebookmass.com/product/handbook-of-robotic-and-image-guided-
surgery-mohammad-h-abedin-nasab-editor/

ebookmass.com

Mathematical techniques of fractional order systems Azar


A.T. Et Al. (Eds.)

https://ebookmass.com/product/mathematical-techniques-of-fractional-
order-systems-azar-a-t-et-al-eds/

ebookmass.com

Lavender and Lust: Wild Blooms Series, Book 9 Jaclyn Combe


& Wild Blooms

https://ebookmass.com/product/lavender-and-lust-wild-blooms-series-
book-9-jaclyn-combe-wild-blooms/

ebookmass.com

Diagnostic Ultrasound: Head and Neck, 2nd Edition Ahuja


Mbbs (Bom) Md (Bom) Frcr Fhkcr Fhkam (Radiology)

https://ebookmass.com/product/diagnostic-ultrasound-head-and-neck-2nd-
edition-ahuja-mbbs-bom-md-bom-frcr-fhkcr-fhkam-radiology/

ebookmass.com

Xero : A Comprehensive Guide for Accountants and


Bookkeepers 1st Edition Amanda Aguillard

https://ebookmass.com/product/xero-a-comprehensive-guide-for-
accountants-and-bookkeepers-1st-edition-amanda-aguillard/

ebookmass.com
Junior Puzzle Book Alligator Books

https://ebookmass.com/product/junior-puzzle-book-alligator-books/

ebookmass.com
Artificial Intelligence
Programming with Python®
Artificial Intelligence
Programming with
Python®
From Zero to Hero

Perry Xiao
Copyright © 2022 by John Wiley & Sons, Inc. All rights reserved.

Published by John Wiley & Sons, Inc., Hoboken, New Jersey.

Published simultaneously in Canada.

ISBN: 978-­1-­119-­82086-­4
ISBN: 978-­1-­119-­82094-­9 (ebk)
ISBN: 978-­1-­119-­82096-­3 (ebk)

No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or
by any means, electronic, mechanical, photocopying, recording, scanning, or otherwise, except as permitted
under Section 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission
of the Publisher, or authorization through payment of the appropriate per-­copy fee to the Copyright Clear-
ance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-­8400, fax (978) 750-­4470, or on the web
at www.copyright.com. Requests to the Publisher for permission should be addressed to the Permissions
Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-­6011, fax (201) 748-­6008,
or online at http://www.wiley.com/go/permission.

Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or war-
ranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all
warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be
created or extended by sales or promotional materials. The advice and strategies contained herein may not
be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in
rendering legal, accounting, or other professional services. If professional assistance is required, the services
of a competent professional person should be sought. Neither the publisher nor the author shall be liable for
damages arising herefrom. The fact that an organization or Website is referred to in this work as a citation
and/or a potential source of further information does not mean that the author or the publisher endorses
the information the organization or Website may provide or recommendations it may make. Further, readers
should be aware the Internet Websites listed in this work may have changed or disappeared between when
this work was written and when it is read.

For general information on our other products and services or for technical support, please contact our Cus-
tomer Care Department within the United States at (800) 762-­2974, outside the United States at (317) 572-­3993
or fax (317) 572-­4002.

Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may
not be available in electronic formats. For more information about Wiley products, visit our web site at
www.wiley.com.

Library of Congress Control Number: 2022931189

Trademarks: Wiley and the Wiley logo are trademarks or registered trademarks of John Wiley & Sons, Inc.
and/or its affiliates, in the United States and other countries, and may not be used without written permis-
sion. Python is a registered trademark of Python Software Foundation. All other trademarks are the property
of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned
in this book.

Cover image: © ktsdesign/Adobe Stock Photos


Cover design: Wiley
This book is dedicated to my family. To my wife, May, my son, Zieger, and
my daughter, Jessica, who make my life complete—­without them, life
would be meaningless. To my parents and my brother, who have shared their
life and love with me that ultimately made me who I am today. To my friends
and colleagues, who supported me throughout my career.

I would also like to dedicate this book to Grace Qing Wang, who sadly
passed away during the course of writing this book. Grace Qing Wang was a
young, energetic professional woman who was passionate about innovation
and artificial intelligence in education. She was also a collaborator and a
good friend. Through Grace I have made many professional connections
that were very beneficial to my career.
About the Author

Dr. Perry Xiao is a professor and course director at the School of Engineering,
London South Bank University in London, United Kingdom. He got his BEng
degree in opto-­electronics, MSc degree in solid-­state physics, and PhD degree
in photophysics. He is a charted engineering (CEng), a Fellow (FIET) from
the Institution of Engineering and Technology (IET), and a Senior Fellow
(SFHEA) from the Higher Education Academy (HEA). He has been teaching
electronics, software, computer networks, and telecommunication subjects
at both the undergraduate level and the postgraduate level for nearly two
decades. He also supervises BEng final project students and MSc project
students every year. His main research interest is to develop novel infrared
and electronic sensing technologies for skin bioengineering applications and
industrial nondestructive testing (NDT). To date, he has finished more than
12 PhD student supervisions, obtained two UK patent applications, published
more than 100 scientific papers, been editorial reviewer for nine journals, and
generated nearly £1 million in research grants.
He is also a director and cofounder of Biox Systems Ltd., UK, a university
spin-­o ff company that designs and manufactures state-­o f-­t he-­a rt skin
measurement instruments, AquaFlux and Epsilon, which have been used in
more than 200 organizations worldwide, including leading cosmetic com-
panies, universities, research institutes, and hospitals.

vii
About the Technical Editors

Dr. Hongmei (Mary) He (FHEA, SIEEE) is an associate professor of cyber-


security in the School of Computer Science and Informatics at De Montfort
University. Previously, she was a lecturer in AI and cyber security at Cranfield
University. She received her PhD in computer science from Loughborough
University in the UK in 2006 and gained sustained experience as a postdoctoral
researcher at various universities. She has worked as an academic in the field
of computer science and engineering for many years and has brief industrial
experience at Motorola Design House in China as a senior embedded system
engineer. Her research can be briefly divided into four themes: AI and data
science, cognitive cybersecurity, cognitive robotics and trustworthy auton-
omous systems, and computing theory and optimization. Dr. He is a senior
member of IEEE in the Computational Intelligence, Cybersecurity, RAS, and
Women in Engineering Societies.

Dr. Weiheng Liao, DPhil (Oxon), is a computer scientist and technology entre-
preneur in AI. He has authored and co-­authored a number of influential papers
in top journals and conferences and is the visiting scholar of several research
universities. His interests include machine learning, AutoML, deep learning,
explainable AI, natural language processing, and their applications in finance
and investment. He cofounded YouShore, one of the world’s first teams to
employ deep NLP to analyze social media data, to extract alternative data, and
to construct alpha signals.
If you want to know more about his recent work, please visit w w w
.madebydata.com.

ix
Acknowledgments

I would like to express my sincere gratitude to Wiley Publishing for giving


me this opportunity. I would also like to thank Devon Lewis, Liz Britten, Pete
Gaughan, Dr. Weiheng Liao, and Hongmei He for their support. Without them,
this book would not have been possible.

xi
Contents at a Glance

Prefacexxiii
Part I Introduction
Chapter 1 Introduction to AI 3
Chapter 2 AI Development Tools 23
Part II Machine Learning and Deep Learning
Chapter 3 Machine Learning 53
Chapter 4 Deep Learning 117
Part III AI Applications
Chapter 5 Image Classification 201
Chapter 6 Face Detection and Face Recognition 265
Chapter 7 Object Detections and Image Segmentations 337
Chapter 8 Pose Detection 433
Chapter 9 GAN and Neural-­Style Transfer 465
Chapter 10 Natural Language Processing 491
Chapter 11 Data Analysis 543
Chapter 12 Advanced AI Computing 613
Index659

xiii
xiv Contents at a Glance

This book is accompanied by bonus content! The following extra elements


can be downloaded from www.wiley.com/go/aiwithpython:
■■ MATLAB for AI Cheat Sheets
■■ Python for AI Cheat Sheets
■■ Python Deep Learning Cheat Sheet
■■ Python Virtual Environment
■■ Jupyter Notebook, Google Colab, and Kaggle
Contents

Prefacexxiii
Part I Introduction
Chapter 1 Introduction to AI 3
1.1 What Is AI? 3
1.2 The History of AI 5
1.3 AI Hypes and AI Winters 9
1.4 The Types of AI 11
1.5 Edge AI and Cloud AI 12
1.6 Key Moments of AI 14
1.7 The State of AI 17
1.8 AI Resources 19
1.9 Summary 21
1.10 Chapter Review Questions 22
Chapter 2 AI Development Tools 23
2.1 AI Hardware Tools 23
2.2 AI Software Tools 24
2.3 Introduction to Python 27
2.4 Python Development Environments 30
2.4 Getting Started with Python 34
2.5 AI Datasets 45
2.6 Python AI Frameworks 47
2.7 Summary 49
2.8 Chapter Review Questions 50
Part II Machine Learning and Deep Learning
Chapter 3 Machine Learning 53
3.1 Introduction 53
3.2 Supervised Learning: Classifications 55

xv
xvi Contents

Scikit-­Learn Datasets 56
Support Vector Machines 56
Naive Bayes 67
Linear Discriminant Analysis 69
Principal Component Analysis 70
Decision Tree 73
Random Forest 76
K-­Nearest Neighbors 77
Neural Networks 78
3.3 Supervised Learning: Regressions 80
3.4 Unsupervised Learning 89
K-­means Clustering 89
3.5 Semi-­supervised Learning 91
3.6 Reinforcement Learning 93
Q-­Learning 95
3.7 Ensemble Learning 102
3.8 AutoML 106
3.9 PyCaret 109
3.10 LazyPredict 111
3.11 Summary 115
3.12 Chapter Review Questions 116
Chapter 4 Deep Learning 117
4.1 Introduction 117
4.2 Artificial Neural Networks 120
4.3 Convolutional Neural Networks 125
4.3.1 LeNet, AlexNet, GoogLeNet 129
4.3.2 VGG, ResNet, DenseNet, MobileNet,
EffecientNet, and YOLO 140
4.3.3 U-­Net 152
4.3.4 AutoEncoder 157
4.3.5 Siamese Neural Networks 161
4.3.6 Capsule Networks 163
4.3.7 CNN Layers Visualization 165
4.4 Recurrent Neural Networks 173
4.4.1 Vanilla RNNs 175
4.4.2 Long-­Short Term Memory 176
4.4.3 Natural Language Processing and Python
Natural Language Toolkit 183
4.5 Transformers 187
4.5.1 BERT and ALBERT 187
4.5.2 GPT-­3 189
4.5.3 Switch Transformers 190
4.6 Graph Neural Networks 191
4.6.1 SuperGLUE 192
4.7 Bayesian Neural Networks 192
Contents xvii

4.8 Meta Learning 195


4.9 Summary 197
4.10 Chapter Review Questions 197
Part III AI Applications
Chapter 5 Image Classification 201
5.1 Introduction 201
5.2 Classification with Pre-­trained Models 203
5.3 Classification with Custom Trained Models:
Transfer Learning 209
5.4 Cancer/Disease Detection 227
5.4.1 Skin Cancer Image Classification 227
5.4.2 Retinopathy Classification 229
5.4.3 Chest X-­Ray Classification 230
5.4.5 Brain Tumor MRI Image Classification 231
5.4.5 RSNA Intracranial Hemorrhage Detection 231
5.5 Federated Learning for Image Classification 232
5.6 Web-­Based Image Classification 233
5.6.1 Streamlit Image File Classification 234
5.6.2 Streamlit Webcam Image Classification 242
5.6.3 Streamlit from GitHub 248
5.6.4 Streamlit Deployment 249
5.7 Image Processing 250
5.7.1 Image Stitching 250
5.7.2 Image Inpainting 253
5.7.3 Image Coloring 255
5.7.4 Image Super Resolution 256
5.7.5 Gabor Filter 257
5.8 Summary 262
5.9 Chapter Review Questions 263
Chapter 6 Face Detection and Face Recognition 265
6.1 Introduction 265
6.2 Face Detection and Face Landmarks 266
6.3 Face Recognition 279
6.3.1 Face Recognition with Face_Recognition 279
6.3.2 Face Recognition with OpenCV 285
6.3.3 GUI-­Based Face Recognition System 288
Other GUI Development Libraries300
6.3.4 Google FaceNet 301
6.4 Age, Gender, and Emotion Detection 301
6.4.1 DeepFace 302
6.4.2 TCS-­HumAIn-­2019 305
6.5 Face Swap 309
6.5.1 Face_Recognition and OpenCV 310
6.5.2 Simple_Faceswap 315
6.5.3 DeepFaceLab 322
xviii Contents

6.6 Face Detection Web Apps 322


6.7 How to Defeat Face Recognition 334
6.8 Summary 335
6.9 Chapter Review Questions 336
Chapter 7 Object Detections and Image Segmentations 337
7.1 Introduction 337
R-­CNN Family 338
YOLO339
SSD340
7.2 Object Detections with Pretrained Models 341
7.2.1 Object Detection with OpenCV 341
7.2.2 Object Detection with YOLO 346
7.2.3 Object Detection with OpenCV and Deep Learning 351
7.2.4 Object Detection with TensorFlow, ImageAI, Mask RNN,
PixelLib, Gluon 354
TensorFlow Object Detection354
ImageAI Object Detection355
MaskRCNN Object Detection357
Gluon Object Detection363
7.2.5 Object Detection with Colab OpenCV 364
7.3 Object Detections with Custom Trained Models 369
7.3.1 OpenCV 369
Step 1369
Step 2369
Step 3369
Step 4370
Step 5371
7.3.2 YOLO 372
Step 1372
Step 2372
Step 3373
Step 4375
Step 5375
7.3.3 TensorFlow, Gluon, and ImageAI 376
TensorFlow376
Gluon376
ImageAI376
7.4 Object Tracking 377
7.4.1 Object Size and Distance Detection 377
7.4.2 Object Tracking with OpenCV 382
Single Object Tracking with OpenCV 382
Multiple Object Tracking with OpenCV384
7.4.2 Object Tracking with YOLOv4 and DeepSORT 386
7.4.3 Object Tracking with Gluon 389
Contents xix

7.5 Image Segmentation 389


7.5.1 Image Semantic Segmentation and Image Instance
Segmentation390
PexelLib390
Detectron2394
Gluon CV 394
7.5.2 K-­means Clustering Image Segmentation 394
7.5.3 Watershed Image Segmentation 396
7.6 Background Removal 405
7.6.1 Background Removal with OpenCV 405
7.6.2 Background Removal with PaddlePaddle 423
7.6.3 Background Removal with PixelLib 425
7.7 Depth Estimation 426
7.7.1 Depth Estimation from a Single Image 426
7.7.2 Depth Estimation from Stereo Images 428
7.8 Augmented Reality 430
7.9 Summary 431
7.10 Chapter Review Questions 431
Chapter 8 Pose Detection 433
8.1 Introduction 433
8.2 Hand Gesture Detection 434
8.2.1 OpenCV 434
8.2.2 TensorFlow.js 452
8.3 Sign Language Detection 453
8.4 Body Pose Detection 454
8.4.1 OpenPose 454
8.4.2 OpenCV 455
8.4.3 Gluon 455
8.4.4 PoseNet 456
8.4.5 ML5JS 457
8.4.6 MediaPipe 459
8.5 Human Activity Recognition 461
ActionAI461
Gluon Action Detection 461
Accelerometer Data HAR 461
8.6 Summary 464
8.7 Chapter Review Questions 464
Chapter 9 GAN and Neural-­Style Transfer 465
9.1 Introduction 465
9.2 Generative Adversarial Network 466
9.2.1 CycleGAN 467
9.2.2 StyleGAN 469
9.2.3 Pix2Pix 474
9.2.4 PULSE 475
9.2.5 Image Super-­Resolution 475
9.2.6 2D to 3D 478
xx Contents

9.3 Neural-­Style Transfer 479


9.4 Adversarial Machine Learning 484
9.5 Music Generation 486
9.6 Summary 489
9.7 Chapter Review Questions 489
Chapter 10 Natural Language Processing 491
10.1 Introduction 491
10.1.1 Natural Language Toolkit 492
10.1.2 spaCy 493
10.1.3 Gensim 493
10.1.4 TextBlob 494
10.2 Text Summarization 494
10.3 Text Sentiment Analysis 508
10.4 Text/Poem Generation 510
10.5.1 Text to Speech 515
10.5.2 Speech to Text 517
10.6 Machine Translation 522
10.7 Optical Character Recognition 523
10.8 QR Code 524
10.9 PDF and DOCX Files 527
10.10 Chatbots and Question Answering 530
10.10.1 ChatterBot 530
10.10.2 Transformers 532
10.10.3 J.A.R.V.I.S. 534
10.10.4 Chatbot Resources and Examples 540
10.11 Summary 541
10.12 Chapter Review Questions 542
Chapter 11 Data Analysis 543
11.1 Introduction 543
11.2 Regression 544
11.2.1 Linear Regression 545
11.2.2 Support Vector Regression 547
11.2.3 Partial Least Squares Regression 554
11.3 Time-­Series Analysis 563
11.3.1 Stock Price Data 563
11.3.2 Stock Price Prediction 565
Streamlit Stock Price Web App569
11.3.4 Seasonal Trend Analysis 573
11.3.5 Sound Analysis 576
11.4 Predictive Maintenance Analysis 580
11.5 Anomaly Detection and Fraud Detection 584
11.5.1 Numenta Anomaly Detection 584
11.5.2 Textile Defect Detection 584
11.5.3 Healthcare Fraud Detection 584
11.5.4 Santander Customer Transaction Prediction 584
Contents xxi

11.6 COVID-­19 Data Visualization and Analysis 585


11.7 KerasClassifier and KerasRegressor 588
11.7.1 KerasClassifier 589
11.7.2 KerasRegressor 593
11.8 SQL and NoSQL Databases 599
11.9 Immutable Database 608
11.9.1 Immudb 608
11.9.2 Amazon Quantum Ledger Database 609
11.10 Summary 610
11.11 Chapter Review Questions 610
Chapter 12 Advanced AI Computing 613
12.1 Introduction 613
12.2 AI with Graphics Processing Unit 614
12.3 AI with Tensor Processing Unit 618
12.4 AI with Intelligence Processing Unit 621
12.5 AI with Cloud Computing 622
12.5.1 Amazon AWS 623
12.5.2 Microsoft Azure 624
12.5.3 Google Cloud Platform 625
12.5.4 Comparison of AWS, Azure, and GCP 625
12.6 Web-­Based AI 629
12.6.1 Django 629
12.6.2 Flask 629
12.6.3 Streamlit 634
12.6.4 Other Libraries 634
12.7 Packaging the Code 635
Pyinstaller635
Nbconvert635
Py2Exe636
Py2app636
Auto-­Py-­To-­Exe 636
cx_Freeze637
Cython638
Kubernetes639
Docker642
PIP647
12.8 AI with Edge Computing 647
12.8.1 Google Coral 647
12.8.2 TinyML 648
12.8.3 Raspberry Pi 649
12.9 Create a Mobile AI App 651
12.10 Quantum AI 653
12.11 Summary 657
12.12 Chapter Review Questions 657
Index659
xxii Contents

This book is accompanied by bonus content! The following extra elements


can be downloaded from www.wiley.com/go/aiwithpython:
■■ MATLAB for AI Cheat Sheets
■■ Python for AI Cheat Sheets
■■ Python Deep Learning Cheat Sheet
■■ Python Virtual Environment
■■ Jupyter Notebook, Google Colab, and Kaggle
Preface

The year 2020 was a year of turmoil, conflicts, and division. The most significant
event was no doubt the COVID-­19 pandemic, which was, and still is, raging
in more than 200 countries and affecting the lives of hundreds of millions of
people. I spent a good part of the year working from home. There are many
disadvantages of remote working; however, it does have at least one advantage:
it saved me at least two hours a day traveling to and from work. This gave me
more time to think about, to plan, and to propose this book.
I am absolutely fascinated with artificial intelligence, and I have read many
artificial intelligence books. But most of the books are heavily focused on the
mathematics of artificial intelligence, which makes them difficult to understand
for people without mathematics or computer science backgrounds. I have
always wanted to write a book that could make it easier to get into the artificial
intelligence field for beginners—­people from all different disciplines. Thanks
to the countless researchers and developers around the world and their open
source code, particularly Python-­based open source code, it is much easier to
use artificial intelligence now than 10 years ago. Through this book, you will
find that you can do amazing things with just a few lines of code, and in some
cases, you don’t need to code at all.
I am a big fan of open source, and for a research field as controversial as
artificial intelligence, it is better for everyone to work together. So, I want to
express my ultimate gratitude to those who made their work available for
the benefit of others.
We are living in an era of digital revolutions and digital technologies such
as artificial intelligence, the Internet of Things, Industry 4.0, 5G technologies,
digital twin, cybersecurity, big data, cloud computing, blockchains, and, on the
horizon, quantum computing. They are all being developed at a breathtaking

xxiii
xxiv Preface

speed. In the future, the Internet of Things will provide a means to connect all
things around us and to use sensors to collect data. The industry version of the
Internet of Things is called Industry 4.0, which will connect all sorts of things for
manufacturers. Digital twin is a digital representation of a process, product, or
service updated from real-­time data. With digital twin, we can predict problems
before they even occur, prevent downtime, develop new opportunities for the
future through simulations. 5G technologies will provide a means for fast and
low-­latency communications for the data. Cybersecurity will provide a means
to protect the data. Big data will provide a means to analyze the data in large
quantity. Cloud computing will provide the storage, display, and analysis of
the data remotely, in the cloud. Blockchains will provide traceability to the data
through distributed ledgers. Quantum computing will make some of the com-
putation faster, in fact, many orders of magnitude faster. Artificial intelligence
will be right at the heart of all the technologies, which allows us to analyze the
data intelligently. As you can see, all these digital technologies are going to
become intertwined to make us work better and live smarter.
That is why I have always said to my students, you can change your future.
Your future is in your hands. The key is learning, even after graduation.
Learning is a lifelong mission. In today’s ever-­evolving world, with all the
quickly developing digital technologies, you need to constantly reinvent your-
self; you will need to learn everything and learn anything. The disadvantage
of fast-­changing technologies is that you will need to learn all the time, but
the advantage is no one has any more advantages than you; you are on the
same starting line as everyone else. The rest is up to you!
I believe artificial intelligence will be just a tool for everyone in the future,
just like software coding is today. Artificial intelligence will no doubt affect
every aspect of our lives and will fundamentally change the way we live, how
we work, and how we socialize. The more you know about artificial intelli-
gence and the more involved you are in artificial intelligence, the better you
can transform your life.
Many successful people are lifelong learners. American entrepreneur and
business magnate Elon Musk is a classic example. As the world’s richest man,
he learned many things by himself, from computer programming, Internet,
finance, to building cars and rockets. British comedian Lee Evans once said
that by the end of the day, if you have learned something new, then it is a good
day. I hope you will have a good day every day and enjoy reading this book!
Professor Perry Xiao
July 2021, London
Preface xxv

Why Buy This Book


Artificial intelligence (AI) is no doubt one of the hottest buzzwords at the
moment. AI has penetrated into many aspects of our lives. Knowing AI and
being able to use AI will bring enormous benefits to our work and lives.
However, learning AI is a daunting task for many people, largely due to the
complex mathematics and sophisticated coding behind it. This book aims to
demystify AI and teach readers about AI from scratch, by using plain language
and simple, illustrative code examples. It is divided into three parts.
In Part I, the book gives an easy-­to-­read introduction about AI, including
the history, the types of AI, the current status, and the possible future trends.
It then introduces AI development tools and Python, the most widely used
programming language for AI.
In Part II, the book introduces the machine learning and deep learning
aspects of AI. Machine learning topics include classifications, regressions,
and clustering. It also includes the most popular reinforcement learning.
Deep learning topics include convolutional neural networks (CNNs) and long
short-­term memory networks (LSTMs).
In Part III, the book introduces AI case studies; topics include image
classifications, transfer learning, recurrent neural networks, and the latest
generative adversarial networks. It also includes the state of the art of GPUs,
TPUs, cloud computing, and edge computing. This book is packed with inter-
esting and exciting examples such as pattern recognitions, image classifications,
face recognition (most controversial), age and gender detection, voice/speech
recognition, chatbot, natural language processing, translation, sentiment anal-
ysis, predictive maintenance, finance and stock price analysis, sales prediction,
customer segmentation, biomedical data analysis, and much more.

How This Book Is Organized


This book is divided into three parts. Part I introduces AI. Part II covers
machine learning and deep learning. Part III covers the case studies, or the
AI application projects. R&D developers as well as students will be inter-
ested in Part III.
Part I
Chapter 1: Introduction to AI
Chapter 2: AI Development Tools
xxvi Preface

Part II
Chapter 3: Machine Learning
Chapter 4: Deep Learning
Part III
Chapter 5: Image Classifications
Chapter 6: Face Detection and Recognition
Chapter 7: Object Detections and Image Segmentations
Chapter 8: Pose Detection
Chapter 9: GAN and Neural-­Style Transfer
Chapter 10: Natural Language Processing
Chapter 11: Data Analysis
Chapter 12: Advanced AI Computing

Example Code
All the example source code is available on the website that accompanies this
book.

Who This Book Is For


This book is intended for university/college students, as well as software and
electronic hobbyists, researchers, developers, and R&D engineers. It assumes
readers understand the basic concepts of computers and their main components
such as CPUs, RAM, hard drives, network interfaces, and so forth. Readers
should be able to use a computer competently, for example, can switch on and
off the computer, log in and log out, run some programs, copy/move/delete
files, and use terminal software such as Microsoft Windows command prompt.
It also assumes that readers have some basic programming experience,
ideally in Python, but it could also be in other languages such as Java, C/C++,
Fortran, MATLAB, C#, BASIC, R, and so on. Readers should know the basic syntax,
the different types of variables, standard inputs and outputs, the conditional
selections, and the loops and subroutines.
Finally, it assumes readers have a basic understanding of computer networks
and the Internet and are familiar with some of the most commonly used Inter-
net services such as the Web, email, file download/upload, online banking/
shopping, etc.
This book can be used as a core textbook as well as for background reading.
Preface xxvii

What This Book Is Not For


This book is not for readers to purely learn the Python programming language;
there are already a lot of good Python programming books on the market. How-
ever, to appeal to a wider audience, Chapter 2 provides a basic introduction to
Python and how to get started with Python programming, so even if you have
never programmed Python before, you can still use the book.
If you want to learn all the technical details of Python, please refer to the
following suggested prerequisite reading list and resources.

Suggested Prerequisite Readings


Computer Basics
Absolute Beginner’s Guide to Computer Basics (Absolute Beginner’s Guides
(Que)), 5th Edition, Michael Miller, QUE, 1 Sept. 2009.
ISBN-­10: 0789742535
ISBN-­13: 978-­0789742537
Computers for Beginners (Wikibooks)
https://en.wikibooks.org/wiki/Computers_for_Beginners
Python Programming
Python Crash Course (2nd Edition): A Hands-­On, Project-­Based Introduc-
tion to Programming, Eric Matthes, No Starch Press, 9 May 2019.
ISBN-­10 : 1593279280
ISBN-­13 : 978-­1593279288
Learn Python 3 the Hard Way: A Very Simple Introduction to the Terri-
fyingly Beautiful World of Computers and Code, 3rd Edition, Zed A.
Shaw, Addison-­Wesley Professional; 10 Oct. 2013.
ISBN-­10 : 0321884914
ISBN-­13 : 978-­0321884916
Head First Python 2e: A Brain-­Friendly Guide, 2nd Edition, Paul Barry,
O′Reilly; 16 Dec. 2016.
ISBN-­10 : 1491919531
ISBN-­13 : 978-­1491919538
Think Python: How to Think Like a Computer Scientist, 2nd Edition, Allen
B. Downey, O’Reilly, 25 Dec. 2015.
ISBN-­10 : 1491939362
ISBN-­13 : 978-­1491939369
xxviii Preface

Python Pocket Reference: Python in Your Pocket, 5th edition, Mark Lutz,
O’Reilly Media, 9 Feb. 2014.
ISBN-­10 : 1449357016
ISBN-­13 : 978-­1449357016
A Beginner’s Python Tutorial (Wikibooks)
https://en.wikibooks.org/wiki/A_Beginner%27s_Python_Tutorial
Python Programming (Wikibooks)
https://en.wikibooks.org/wiki/Python_Programming

Suggested Readings to Accompany the Book


Introduction to Machine Learning with Python: A Guide for Data Scien-
tists, Sarah Guido, O’Reilly Media; 25 May 2016.
ISBN-­10 : 1449369413
ISBN-­13 : 978-­1449369415
Hands-­on Machine Learning with Scikit-­Learn, Keras, and TensorFlow:
Concepts, Tools, and Techniques to Build Intelligent Systems, 2nd
Edition, Aurelien Geron, OReilly, 14 Oct. 2019.
ISBN-­10 : 1492032646
ISBN-­13 : 978-­1492032649
Deep Learning with Python, Francois Chollet, Manning Publications,
30 Nov. 2017.
ISBN-­10 : 9781617294433
ISBN-­13 : 978-­1617294433
Deep Learning (Adaptive Computation and Machine Learning Series),
Illustrated edition, Ian Goodfellow, MIT Press, 3 Jan. 2017
ISBN-­10 : 0262035618
ISBN-­13 : 978-­0262035613
Python Machine Learning: Machine Learning and Deep Learning with
Python, scikit-­learn, and TensorFlow 2, 3rd Edition, Sebastian Raschka,
Vahid Mirjalili, Packt Publishing, 12 Dec. 2019.
ISBN-­10 : 1789955750
ISBN-­13 : 978-­1789955750
Machine Learning Yearning (Andrew Ng’s free ebook)
https://www.deeplearning.ai/machine-­learning-­yearning/
Dive into Deep Learning (Free ebook)
https://d2l.ai/
Preface xxix

What You Need


In this book, you will need the following:
■■ A standard personal computer with a minimum 250 GB hard drive, 8 GB
RAM, and Intel or AMD 2 GHz processor, running a Windows operating
system (Vista/7/8/10, Internet Explorer 9 and above, or the latest Edge
browser, or Google Chrome) or a Linux operating system (such as Ubuntu
Linux 16.04 (or newer) and so on). You can also use a Mac (with Mac OS
X 10.13 and later, administrator privileges for installation, 64-­bit browser).
■■ Python software
https://www.python.org/downloads/

■■ Text editors and Python IDEs (see Chapter 2)


■■ Raspberry Pi (optional)
https://www.raspberrypi.org/

■■ Arduino NANO 33 BLE Sense (optional)


https://www.arduino.cc/en/Guide/NANO33BLESense

This book is accompanied by bonus content! The following extra


elements can be downloaded from www.wiley.com/go/aiwithpython:
■■ MATLAB for AI Cheat Sheets
■■ Python for AI Cheat Sheets
■■ Python Deep Learning Cheat Sheet
■■ Python Virtual Environment
■■ Jupyter Notebook, Google Colab, and Kaggle
Artificial Intelligence
Programming with Python®
Par t

I
Introduction

In This Part:
Chapter 1: Introduction to AI
Chapter 2: AI Development Tools
Part I gives a bird’s-­eye overview of artificial intelligence (AI) and AI development
resources.
CHAPTER

Introduction to AI
“There is no reason and no way that a human mind can keep up
with an artificial intelligence machine by 2035.”
—­Gray Scott (American futurist)

1.1 What Is AI?


1.2 The History of AI
1.3 AI Hypes and AI Winters
1.4 The Types of AI
1.5 Edge AI and Cloud AI
1.6 Key Moments of AI
1.7 The State of AI
1.8 AI Resources
1.9 Summary
1.10 Chapter Review Questions

1.1 What Is AI?


Artificial intelligence (AI) is no doubt one of the hottest buzzwords right now.
It is in the news all the time. So, what is AI, and why is it important? When you
talk about AI, the image that probably pops into most people’s heads is of a
human-­like robot that can do complicated, clever things, as shown in Figure 1.1.
AI is actually more than that.
AI is an area of computer science that aims to make machines do intelligent
things, that is, learn and solve problems, similar to the natural intelligence of
humans and animals. In AI, an intelligent agent receives information from the
environment, performs computations to decide what action to take in order to
achieve the goal, and takes actions autonomously. AI can improve its performance
with learning.

3
4 Part I ■ Introduction

For more information, see the John McCarthy’s 2004 paper titled, “What Is
Artificial Intelligence?”
https://homes.di.unimi.it/borghese/Teaching/AdvancedIntelligent­
Systems/Old/IntelligentSystems_2008_2009/Old/IntelligentSystems_
2005_2006/Documents/Symbolic/04_McCarthy_whatisai.pdf

Figure 1.1: The common perception of AI


(Source: https://commons.wikimedia.org/wiki/File:Artificial_
Intelligence_%26_AI_%26_Machine_Learning_-­_30212411048.jpg)

You may not be aware that AI has already been widely used in many aspects of
our lives. Personal assistants such as Amazon’s Alexa, iPhone’s Siri, Microsoft’s
Cortana, and Google Assistant all rely on AI to understand what you have said
and follow the instructions to perform tasks accordingly.
Online entertainment services such as Spotify and Netflix also rely on AI
to figure out what you might like and recommend songs and movies. Other
services such as Google, Facebook, Amazon, and eBay analyze your online
activities to deliver targeted advertisements. My wife once searched Arduino
boards at work during the day, and in the evening, after she got home, no matter
which websites she visited, ads for Arduino boards kept popping up!
Have you ever used the SwiftKey program on your phone or Grammarly on
your computer? They are also AI.
AI has also been used in healthcare, manufactoring, driverless cars, finance,
agriculture, and more. In a recent study, researchers from Google Health and
Imperial College London developed an algorithm that outperformed six human
Chapter 1 ■ Introduction to AI 5

radiologists in reading mammograms for breast cancer detection. Groupe Renault


is collaborating with Google Cloud to combine its AI and machine learning
capabilities with automotive industry expertise to increase efficiency, improve
production quality, and reduce the carbon footprint. Driverless cars use AI to
identify the roads, the pedestrians, and the traffic signs. The finance industry uses
AI to detect fraud and predict future growth. Agriculture is also turning to AI for
healthier crops, pest control, soil and growing conditions monitoring, and so on.
AI can affect our jobs. According to the BBC, 35 percent of today’s jobs will
disappear in the next 20 years. You can use the following BBC website to find
out how safe your workplace is:
https://www.bbc.co.uk/news/technology-­34066941

1.2 The History of AI


AI can be traced back to the 1940s, during World War II, when Alan Turing,
a British mathematician and computer scientist, developed a code-­breaking
machine called bombe in Bletchley Park, United Kingdom, that deciphered
German Enigma–encrypted messages (see Figure 1.2). The Hollywood movie
The Imitation Game (2014) has vividly captured this period of history. Turing’s
work helped the Allies to defeat the Nazis and is estimated to have shortened
the war by more than two years and saved more than 14 million lives.

Figure 1.2: The bombe machine (left) and the Enigma machine (right)
(Source: https://en.wikipedia.org/wiki/Cryptanalysis_of_the_Enigma)

In October 1950, while working at the University of Manchester, Turing pub-


lished a paper entitled “Computing Machinery and Intelligence” in the journal
Mind (Oxford University Press). In this paper, he proposed an experiment that
became known as the famous Turing test. The Turing test is often described as
a three-­person game called the imitation game, as illustrated in Figure 1.3, in
which player C, the interrogator, tries to determine which player—­A or B—­is a
6 Part I ■ Introduction

computer and which is a human. The interrogator is limited to using the responses
to written questions to make the determination. The Turing test has since been
used to test a machine’s intelligence to see if it is equivalent to a human. To
date, no computer has passed the Turing test.

Figure 1.3: The famous Turing test, also called the imitation game. Player C, the interrogator, is
trying to determine which player—­A or B—­is a computer and which is a human.

AI as a research discipline was established at a workshop at Dartmouth


College in 1956, organized by John McCarthy, a young assistant professor of
mathematics at the college (http://raysolomonoff.com/dartmouth/). The
workshop lasted about six to eight weeks, and it was essentially an extended
brainstorming session. There were about 11 mathematician attendees such as
Marvin Minsky, Allen Newell, Arthur Samuel, and Herbert Simon. They were
widely recognized as the founding fathers of AI. John McCarthy chose the term
artificial intelligence for the new research field.
The history of AI can be divided into three stages, as illustrated in Figure 1.4.
■■ 1950s–1970s, neural networks (NNs): During this period, neural networks,
also called artificial neural networks (ANNs), were developed based on
human brains that mimic the human biological neural networks. An NN
usually has three layers: an input layer, a hidden layer, and an output
layer. To use an NN, you need to train the NN with a large amount of
given data. After training, the NN can then be used to predict results for
unseen data. NNs attracted a lot of attention during this period. After the
1970s, when NNs failed to live up to their promises, known as AI hype,
funding and research activities were dramatically cut. This was called an
AI winter.
■■ 1980s–2010s, machine learning (ML): This is the period when machine
learning flourished. ML is a subset of AI and consists of a set of mathematical
Random documents with unrelated
content Scribd suggests to you:
in 1780 and a committee appointed to assist in [Sidenote: Five
establishing others. They appear to have been schools 1792]
successful; five schools were reported in 1792,
though one was about to be discontinued. Not all of the masters
were Friends.
The statement that Negroes were being [Sidenote:
educated in 1765, induces one to believe that Uwchlan]
Friends’ children were provided for. Three schools
were mentioned in 1779, in which the masters and [Sidenote:
Nantmeal School,
many of the employers were Friends. In 1789 a 1789]
school was established at Nantmeal under a
special committee of Uwchlan Meeting; it was [Sidenote: London
Grove]
reported discontinued in 1787. The meeting at
London Grove, established (1792), reported no schools in its
compass before the end of the century; although an elaborate plan
was drawn up for the establishment of school funds.
Youths’ meetings were established by Sadsbury [Sidenote:
as early as 1739 and instances in which poor Sadsbury]
children were educated are cited for 1769. The first
committee seems to have been appointed for [Sidenote: Lampeter
schools in 1779. A school was reported for boarding school]
Sadsbury in 1782, but was later discontinued for a
brief time, which cannot be definitely determined. In [Sidenote:
schools]
Three
1792 it was agreed that Lampeter Preparative
might have permission to establish a boarding school. A plan for
funds was drawn up, but no success reported in raising them until
1798. Three schools are reported established, and under the care of
Quaker masters in 1797.
The entire number of schools set up by the [Sidenote: Total,
above named meetings was eighteen or nineteen. 18 or 19 schools]
CHAPTER VIII
SCHOOLS OF DELAWARE COUNTY

The activity of the several monthly meetings in [Sidenote: The


Delaware County in the establishment of schools meetings]
will be considered under the heads of the
respective meetings in the following order, Chester, Darby, Radnor,
and Concord. These are four of the earliest monthly meetings
established in Pennsylvania, the dates of their establishment being:
Chester, 1681; and Darby, Radnor, and Concord in 1684.[648] The
aim of this chapter, as of the others dealing with the several
counties, is to present, first the source material which has been
found to have any bearing on the establishment of schools and the
attitude of the monthly meetings toward them.
Penn having come to New Castle on October 27, [Sidenote:
1682, and performed the ceremonies of taking Naming of
Chester]
possession of the province,[649] appears to have
gone thence to Upland, from whence he sent a letter to Ephriam
Harman (dated October 29, 1682) regarding summoning a court to
be held at New Castle (November 2, 1682).[650] But Upland was not
destined to remain the name of the city, as Penn’s biographers tell
us. It is stated that Penn, having arrived and being filled with emotion
at having had a successful journey, turned to a friend and said,
“What wilt thou that I should call this place?” He replied,
“Chester.”[651]
In passing it should be mentioned that an interest [Sidenote:
in education does not date entirely from the coming Education before
of the Quakers and the establishment of Penn’s coming of
Quakers]
colony. The records of the court of Upland inform
us (1679) that, without a doubt, some children received the
advantages of an education. It may have been very restricted, we
cannot determine that. The records of that date state, however, that:
“The Plt demands of this Deft 200 Gilders for teaching this Defts
children to read one yeare.”[652] There is no doubt that Friends were
not concerned with education in this case.[653]
The first meetings of Chester Monthly Meeting were held in the
Court House[654] at Chester, and meetings for worship usually
among the members at their homes, previously designated.[655] In
March, 1686, Urin Keen conveyed in trust to John Simcock, Thomas
Brassey, John Brinton, Caleb Pusey, Randall Vernon, Thomas
Vernon, Joshua Hastings, Mordecai Maddock, Thomas Martin,
Richard Few, Walter Faucet and Edward Carter, a piece of ground in
Chester
[Sidenote:
beginning at said Urin’s lot or Garding, and so Property granted
running, 60 feet along and fronting the street the meeting and
house built]
towards the prison house, thence down the
lower edge in Chester Creek—thence along the Creek 60 feet
—thence to the place of beginning ... to the use and behoof of
the said Chester—the people of God called Quakers and their
successors forever.[656]

In the year following, it was urged by the monthly meeting that


Friends agree with workmen to build a meeting house at Chester 24
feet square by 16 feet in height.[657] The first meeting house, built on
the ground above mentioned, was completed about 1793.[658]
The earliest record of schools established by [Sidenote: First
Friends dates back to about 1770. Though this is land devised for
the first record of a device of property for the schools in 1769]
purpose, and the minutes of the meeting are also [Sidenote:
negligent of educational affairs, it does not seem Hoskins wills
probable to the writer that the locality was without ground for
schools]
schools. There were probably neighborhood
schools, not subject to any organization on the part [Sidenote: Poor to
of the meeting. On December 31, 1769, Joseph be schooled]
Hoskins, a Friend, willed a lot of ground for the use of schools,[659]
and though his death did not occur till some years later, the meeting
appears to have known of the intended bequest and to have built a
school house in 1770.[660] It was further ordered by the will that the
sum of thirty pounds be paid to John Eyre and James Barton for the
schooling and education of such poor children of the inhabitants of
the borough of said Chester as the preparative meeting shall for the
time being think fit to order and direct.[661] Mr. Jordan in his history of
the county, describes the schoolhouse:

The schoolhouse was built of bricks, laid in Flemish bond,


the ends of the headers being burnt black, a style much in
vogue at that time. In the south gable large numerals, 1770,
were inserted in the wall, the figures being formed by the
black ends of the headers.[662]

The school mentioned in the committee’s report [Sidenote: School


on schools situated at Middletown,[663] was at Middletown
probably in 1740]
established by Friends in 1783, but an earlier
school existed (1740), according to Mr. Jordan,[664] [Sidenote: Land
the buildings for the same having been donated by donated by Taylor
and wife]
Thomas Yarnall and Thomas Minshall, whose
names are very prominently mentioned in Quaker records. The
meeting minutes make no mention of such a school being
established, however, and it must be understood to have been
entirely on individual initiative. In 1791, Enock Taylor and wife,
Quakers, conveyed a quarter acre of land to the use of Chester
Monthly Meeting of Friends for the use of a school.[665] Judging,
however, from the later reports of the monthly meeting we would be
led to believe that no school was established at that time.[666] On
December 20, 1791, David Hall conveyed adjoining property for the
same use.[667]
About 1778 the monthly meeting became more [Sidenote:
active in regard to its interest in schools, appointing Committees
committees to investigate conditions and report the appointed on
education]
state to its sessions.[668] In 1779 and 1781, there
appeared two reports on the condition of the [Sidenote:
Negroes and their education which are presented Subscriptions to
be started for
in another chapter.[669] In 1782 there likewise funds]
appeared a report of the committee on schools in
general.[670] This committee, appointed in accord with the
suggestions of the yearly meeting, agreed substantially that the best
way to the establishment of schools systematically, was to arrange
for a subscription which might be applied to that use at the discretion
of the monthly meeting. This was to be used for paying the master’s
salary, and to educate poor Friends’ children, where it might appear
to be of advantage to do so.[671] These suggestions were directed to
be copied and put into the hands of the members in each of the
preparative meetings.[672] Three months thereafter, the meeting
appointed a treasurer for funds and a committee for the oversight of
schools, who were to act in general accord with the suggestions
made in the first report.[673] The minute of the meeting of that date
runs as follows:

A form of subscription was proposed which might be


entered into by those who desired, and was approved by the
meeting and all urged to forward the signing of it.[674]

The work thus started was not entirely [Sidenote:


satisfactory to the committee, however. They report Qualified teachers
that “the work goes very slowly” and name, as one scarce]
cause, the great difficulty of getting suitable
teachers.[675] Provision seems to have been made for the schooling
of poor children, “such as can conveniently be sent.”[676] This
reference may mean that all such were schooled who were within
reach of a school, or that they sent all for whom they had a sufficient
fund. In 1783 they acknowledged the receipt of the most recent
advices of the yearly meeting which again recommended the serious
subject of schools to their attention. Again in 1792 we find this
minute:

The subject of schools being now resumed and the several


paragraphs contained in the extracts of 1778, 1779 and 1789
being read relative thereto, Friends, of the several preparative
meetings are desired to pay close attention to the several
repeated advises of the yearly meeting on this important
subject.[677]

In 1796 the concern of a boarding school, which we have found


was also interesting all of the other monthly meetings, in the
Philadelphia Yearly Meeting, came also to the attention of Chester.
They indicated their willingness to coöperate in the scheme by the
appointment of a committee, which appears from a minute made in
the meeting in 1793.
[Sidenote:
William Worrall, Daniel Sharpless, Josiah Subscriptions
Rhoads, Edward Fell, Mahlon Parsons, Roger promoted for
Dirks, Thomas Sharpless and Jacob Minshall boarding school]
are appointed to prepare a subscription paper and promote
Friends’ subscriptions towards the establishment and support
of the boarding school agreeable to the recommendations of
our last Yearly Meeting, and report of their care to next or a
future meeting.[678]

The general state of schools under the meeting’s jurisdiction is


made known by the following report sent in by the school committee
to the monthly meeting held on 1-27-1800.
[Sidenote: Three
The committee appointed to the care of schools under
schools report there are three kept within the Chester Meeting]
verge of this meeting under Friends care, viz.:
1. One at Springfield taught by a Friend.
2. One at Middletown, taught by a person not in
membership.
3. One at Blue Hill under similar circumstances, all of which
we trust are conducted in a good degree orderly, but that
there has been little or no addition to our fund since last year,
except what it has increased by use. The school committee
also informs that the Friends who were by the last will of our
Friend George Miller and James Turner, left trustees to the
lots at Blue Hill have conveyed the same by instruments of
writing duly executed as follows, to wit: the dwelling house
and lot to Jacob Minshall, Edward Fell, Ambrose Smedley,
Isaac Sharpless, John Hill, Jr., and Joseph Pennell, Jr., and
the schoolhouse and lot to George Miller, Edward Fell,
Ambrose Smedley, James Smedley, Isaac Sharpless, John
Hill, Jr., and Joseph Jonnell, Jr., which said conveyances
have since been recorded and are lodged with the other
writings relating thereto, in the hands of the treasurer of the
school fund which is satisfactory to the meeting.[679]

The Blue Hill School, mentioned in the above report of the


committee, no doubt dated back to a few years following 1791, in
which James Turner bequeathed his “Blue Hill Estate” to George
Miller for the use of schools established at the direction of Chester
Monthly Meeting.[680]
[Sidenote: “Blue
I give, devise and bequeath to George Miller, Hill” estate
the son of my cousin George Miller, my house bequeathed by
James Turner]
and lot of Ground situated in the Province
aforesaid (commonly called Blue Hill) with the appurtenances
to hold by him and his heirs and assigns forever.
Upon special trust and confidence, nevertheless and to and
for the use, intent and purpose hereinafter expressed,
mentioned and declared, and moreover for the use of the
society of Protestants, commonly called Quakers, of and
belonging to the Monthly Meeting of Chester for the erecting
one or more houses for the teaching and instructing youth
therein, and all necessary conveniences thereto belonging
under and subject to the rules and regulations and orders of
the said meeting for the time being forever.
Item, I give and bequeath to my Friend Jacob Minshall, all
the rest and residue of my estate in trust for the use of a
school which may at times be kept at or near my lot of ground
above mentioned, subject to the direction of the Chester
Monthly Meeting.[681]

The meeting’s schools also received a [Sidenote: Legacy


considerable assistance through a legacy of £50 from Thomas
left by Thomas Evans for the establishment and Evans]
support of a school within the verge of Chester
Monthly.[682] He makes it clear in his bequest that he has been
influenced to do this by the recommendations of the yearly meeting,
the influence of which has been instanced in many cases before this
one.
Not only to the advancement of education and enlightenment by
means of schools alone did Friends of the Chester Meeting lend their
encouragement. In a minute of 1689 we find an interesting reference
to assistance proposed for the encouragement of printing in
Philadelphia.
[Sidenote:
The business proposed to the Friends of Printing
Philadelphia concerning allowing William encouraged by
Bradford, the printer, £40 by the year to the meeting]
encourage him to continue in the art and practise of Printing.
This meeting approving the said proposal, orders for Darby
Monthly Meeting John Blunston and Joshua Fearne and for
Chester Monthly Meeting Caleb Pusey, Randall Vernon and
for Chichester Monthly Jacob Chandler and John Mendenhall
to take subscription according to proposal.[683]
We have noticed that there appeared to be very [Sidenote: An
little in the records of the monthly meeting until early attention to
about 1770 and that they contained little of education
reported by the
educational interest before that time. The records quarterly meeting]
of the Quarterly Meeting of Chester (later known as
Concord) are, however, full of suggestions which indicate that
educational interests had their attention much before that date,
though they were not under a perfected organization. As early as
1732 advances were made for the care and instruction of poor
children which would fit them to earn a living. We may mention the
financial assistance promised by Joseph Mead in that year.

Our ancient Friend Joseph Mead having by letter


communicated to this meeting his mind, signifying his
willingness to do something that might be conducive towards
a public good, and in order thereto offers to give £50 toward a
stock to be kept in this meeting for the putting of poor Friends’
children to trades or for relieving of poor or indigent Friends
which this meeting very kindly accepts of at the hand of said
Friend.[684]... and this meeting being informed that our Friend
Joseph Mead continues steadfast in his mind respecting his
donation towards pious uses, and desires he may know to
whom he may deliver the said gift. After some consideration
thereon this meeting do nominate ... Jacob Howell and John
Davis to be receivers and are by this meeting empowered to
receive the above and all such bequests ..., in behalf of and
for the use of this meeting, and to put out upon interest as
soon as they conveniently can all such money into good and
responsible hands and to render to this meeting when
required thereto or to whom the said meeting shall appoint a
true and just account of what may be delivered hereafter by
any person or persons into their hands for the uses aforesaid.
[685]

In 1739 the interest arising from this gift was withdrawn at his
request and paid to the Springfield Friends to help them build their
meeting house.[686]
In response to the yearly meeting’s urgent request of 1746 and
1750,[687] we have their action recorded in this minute of the year
1754.
[Sidenote: Report
According to a minute of the advice of the required on state
Last Yearly Meeting concerning the settling of of legacies]
schools in the country, it is agreed for the
encouragement thereof that the several and respective clerks
of the monthly meetings belonging to this quarterly meeting
do inquire and bring in a true report of all legacies, donations
or estates which have been heretofore given to their
respective meetings and of the uses to which the moneys
arising therefrom are applied, and bring the account thereof to
our next meeting.[688]

The meetings at Darby were at first usually held [Sidenote: Darby]


at the home of John Blunston, who in 1687 deeded
one acre of ground in Darby aforesaid for the use [Sidenote: Land
deeded for
of building a meeting house,[689] on which the meeting]
meeting house was begun in the following year,
[690] and finished in 1689.[691] Happily, in the case of Darby Meeting
we can point out a definite statement concerning a school
established by the meeting, and which, quite probably, was the first
school at that place. In 1692 the minutes note that,
[Sidenote: B.
Agreed at this meeting that Benjamin Clift Clift’s school]
teach school, beginning the twelfth day of the
7th month, and to continue one whole year except two weeks.
[692]

His salary for the first year is not known, but the minutes a year
later give some clue as to the amount paid.
Agreed at this meeting that Benjamin Clift teach school a
year, beginning this 20th day of this 9th month; and to have
£12/00/00.[693]

As has occurred in all other monthly meetings [Sidenote: Slight


thus far considered, there was always little done in activity before
the way of organization and supervision of school 1778]
affairs till after 1770.[694] There were however
various committees appointed from time to time, especially in the
case of legacies and donations which were quite common even at
early dates.[695] The movement towards better organization,
however, began more earnestly in 1778, with the receipt of a number
of letters from the yearly meeting, in regard to which the following
minute was made:
[Sidenote:
This meeting received a number of the Coöperation of
general epistles from the last Yearly Meeting monthly and
quarterly
held in London and also the same number of committees]
copies of an epistle from the same meeting to
our last Yearly Meeting, one of each were read at the close of
the meeting for worship, to satisfaction, and the clerk is
directed to read one of each the forepart of a first day
meeting. The remainder were distributed amongst Friends.
[696]

In the twelfth month Darby Friends received a [Sidenote:


committee appointed by the quarterly meeting Building for a
(Concord) to investigate conditions and promote school proposed]
schools among the monthly meetings.[697] John
Howe, Aaron Oakford, Isaac Lloyd, Benjamin Lobb, and Josiah
Bunting were appointed by Darby to join with the quarterly meeting’s
committee in its work.[698] The next year the question of building a
schoolhouse occupied their attention.[699] It was proposed to deal
with persons holding some land adjoining that of the meeting, that it
might be purchased as school property and a suitable building
erected thereon. Finding, however, that those holding the adjacent
property were not at the time disposed to sell, it was decided to
begin a subscription for erecting a schoolhouse on the meeting’s
land, which has been mentioned as having been left to the meeting’s
use by John Blunston.[700] The work on this building was evidently
begun between 1779 and 1781, as we may infer from the minute of
the latter year.

This meeting resuming the consideration of building a


house to accommodate a school were informed by one of the
committee that it appeared to be necessary the subscriptions
should be enlarged before the work could be completed;
therefore Abraham Bonsall, John Humphreys, and Phillip
Price are appointed with the former committee in order to
forward the work and to report what progress they have made
therein to next meeting; Benjamin Lobb requesting to be
released from the above service, Morris Truman is appointed
in his room.[701]

The tenor of a minute of the meeting next following was to the


effect that enough money had been secured for the completion of
the work.[702]
In 1784 another visit was received from the [Sidenote: State
committee of the quarterly meeting, whose purpose of school
was “the establishing and keeping up suitable satisfactory 1784]
schools,” as recommended in the several years [Sidenote: A
past.[703] The reports of the committee of the digest of report of
school at this date indicate that the status was 1790]
nearly what was expected by the yearly meeting,
respecting (1) foundation, (2) masters, (3) supervision by
committees, (4) accommodations for the master, etc.[704] In 1787,
Nathaniel Newlin one of the meeting’s representatives to the
quarterly meeting brought back a request from that body for “a
circumstantial account” of the state of schools, to be transmitted to
the quarterly meeting the next eighth month.[705] The said Nathaniel
was placed on the school committee in the eleventh month following,
[706] and later, John Bull and Benjamin Bartram were appointed in
the places of Aaron Oakford and Phillip Price who requested to be
released.[707] In the first month of the year following there was
produced a report by the committee, which in fact became the
governing document for the schools established and to be
established in Darby. There is presented here a digest of the report;
a complete statement of it may be found in Chapter II.
1. Recalling the advices of the yearly meeting, they recognize:

a. the advantages arising from established schools, and


b. the losses sustained from a want thereof.

2. Therefore it is agreed that in the future five Friends should be


appointed and called the Overseers of Darby School, three of them
to be sufficient number to transact business.
3. Their duties:

a. Visit the school.


b. Examine the progress of the scholars.
c. Inspect the teacher’s conduct.
d. Employ teachers, with the approbation of the meeting.
e. Discharge them in similar manner, if cause therefor arise.
f. Discharge unruly pupils, who will not submit to the rules
of the school.
g. Settle all differences arising between the master and any
employers.
h. Devise some plan for raising permanent funds for the
school; also to receive interest from the trustees of donations
given for education of the poor, and apply the same as
intended.
i. Aid the trustees in getting better securities for the same.
j. Minutes of their proceedings are to be kept and reports
made to the monthly meeting once a year, and at other times
if called for.[708]

In 1792 the new overseers reported they had [Sidenote: New


continued to visit the school and inspect the overseers added
learning of the children, which they did with temporarily]
satisfaction, implying that all conditions were as [Sidenote:
desired.[709] In the eleventh month four new Schoolhouse to
members were appointed to the school overseers; be built on Lobb
lot by
[710] as it is not stated that any had been released, subscription]
we are uncertain as to whether the number
required had been increased or not; quite likely [Sidenote: Not
begun until 1797
they were appointed only for temporary assistance. or 1798]
In 1793 it was reported from the school overseers
that Benjamin Lobb had agreed to grant a lot of ground on the upper
part of his plantation, to build a schoolhouse upon; the overseers
proposed that the expenses be defrayed by subscription.[711] A
subscription was started for the same, and Friends desired to
forward it, that the school might be begun.[712] The cost of this
school was estimated at £110.[713] It is not known just when this
school under Friends’ care was begun in Upper Darby but at various
stages these things are known about it. (1) On the 28th of the third
month, 1793, it was reported that Lobb had offered the ground, (2)
the cost of the building was estimated, fifth month, second, 1793, at
£110, (3) eighth month, twelfth, 1793, the Chester Quarterly Meeting
received the report that Darby was going to establish a school for
Friends, (4) in 1796 the committee of overseers reported, “our school
has been kept in good degree accordingly as desired by the yearly
meeting,”[714] (5) the committee of overseers still mention but one
school under their care and (6) eighth month, second, 1798, the
school overseers report that the schools are kept as recommended
by the yearly meeting. It would appear then that the school did not
actually begin until some time between 1797 and 1798,[715] since all
prior reports had recognized but one school.
Mr. Jordan states that in 1779 a deed set aside 24 perches of
ground in upper Darby on the Darby-Haverford Road for the use of
schools.[716] This seems to have no connection with the schools
established by the meeting; it was the first official deed for ground for
schools, but many bequests of great value had been made
previously.[717] The text of the minutes recording these bequests
follows on a later page.
The state of schools as reported by the [Sidenote: The
committee in 1797 was as follows: state of education
in 1797 and]

Our school has been kept since last accounts ... as


recommended by the Yearly Meeting; visited by the overseers
and the scholars learning inspected to a good degree of
satisfaction. There has been expended for schooling children
of Friends and others the sum of £12/10 and on settlement
there appears a balance in the treasurer’s hands of £6/15/5;
the stock remains the same as at last year. Signed ... Morris
Truman, Isaac Oakford, and John Hunt.[718]

As mentioned above, the second school in Upper [Sidenote: 1798]


Darby seems to have been put into operation by
1798. The committee’s report, summarized, is as the following.[719]

1. Schools kept as recommended by the yearly meeting


since last year.
2. Scholars’ learning has been inspected.
3. Schools have been visited.
4. Children of the poor and of others have been schooled.
5. Stock remains at £14/00/00 as last year.
Signed Truman Morris, John Hunt and Isaac Oakford.
As has been previously suggested the financial [Sidenote:
assistance to Darby schools came in a very Support of
considerable measure from legacies, left from time schools by
legacies]
to time, but it was also necessary to use
subscription and rate plans for school support. The text of one of
these bequests, as recorded in the Darby records, is given below.

Likewise I give and bequeath to my friend John Griffith,


Thomas Pearson, and Samuel Bunting, all of Darby aforesaid,
the sum of £50, nevertheless my aforesaid gift and bequest to
them is only in trust, that they the said John Griffith, Thomas
Pearson and Samuel Bunting shall reconvey and receive from
the hands of my executors aforesaid the sum of £50 and
when so received, put out the said monies to interest on good
securities with the approbation of the monthly meeting of the
people called Quakers in Darby aforesaid, and at the risk of
those benefitted thereby and so from time to time forever, with
the approbation of the said meeting for the time being. To the
intent and purpose that by and out of the interests and profits
thereof, they the said John Griffiths ... pay for the learning to
read and write of such and so many poor Friends children in
unity and church fellowship with the said people and
belonging to the said meeting, as the said meeting shall order
and appoint from time to time forever, and when any of my
said trustees shall die, it is my will and mind that the said
meeting shall appoint another to succeed and so from time to
time forever.[720]

Smith’s History of Delaware County states that [Sidenote:


as early as 1788 there was a school established at Radnor]
Radnor.[721] The first reference to a school found in [Sidenote: A
the Radnor Monthly Meeting’s records was in 1731. school mentioned
[722] At that date Richard Harrison and some in 1731]

Friends
signified to this meeting in writing that the meeting appointed
last 7th month to be kept at the said Richard’s schoolhouse
was duly and religiously kept and further requested to be
permitted to keep an afternoon meeting ... which is allowed of
and to be at four o’clock.

The school had doubtless been in existence for [Sidenote: The


at least a short time before that. Their answers to poor educated]
the fifth query in 1757 state that they are careful of
the education of the poor and find themselves clear of placing
children from among Friends.[723] They also, at that date, report
themselves free of holding slaves;[724] likewise in 1759, in regard to
both.[725] In 1768, in regard to a case of apprenticing children, this
minute is recorded by the meeting:
[Sidenote:
The meeting taking the request to reimburse Children
them the expense accruing on account of Jane apprenticed]
Atkinson, deceased, into consideration, came to
a result of paying them as soon as we can, and as there is
one of her children not put out yet, it is desired Samuel
Humphreys and William Lawrence would take some care in
putting them out....[726]

In 1759 we find that Friends are reminded by the [Sidenote: Making


monthly meeting of the “necessary duty” of making wills
their wills in time of health, and that endeavors are recommended]
used to apply public gifts to the uses intended.[727]
The only “uses intended” must have been for some of these
purposes: The support of the poor, their education, for negro support
and education, or for purely religious purposes, all of which, the last
one excepted, were, in a way, if we may judge from other meetings’
practices, educational. The suggestion of leaving bequests for public
purposes, taken in connection with the answers to the fifth and
seventh queries, and the known fact that there was a school in 1731,
lead us to believe that the Radnor Meeting was pretty well awake to
educational problems. However true that may be, it is just as certain
that any exact data on her schools are very rare for the early period
before 1778. In that year the usual declaration of the yearly meeting
at Philadelphia was received concerning the question of schools.[728]
A committee of the quarterly meeting in 1778 [Sidenote: Report
produced a report embodying certain conclusions of quarterly
arrived at, both as to causes of existing evils and meeting]
the proposed solutions. Only a digest of this report
can be given here.[729]
1. We believe it a subject of much importance.
2. Corruptions have been introduced by mingling in outside
schools.
3. It is necessary to have schools under masters and mistresses
who take care of religious education.
4. We believe it our duty to spread the work through the yearly
meeting.
The effect of the yearly and quarterly meetings’ [Sidenote:
suggestions was the appointment of Samuel Committee
Briggs, William Lawrence, Jacob Jones, John appointed education]
on
Robeson, Samuel Richards, and Daniel Maule to
attend to the affairs of education, “as may be opened in the wisdom
of truth.”[730] This last may, to our modern way of thinking, suggest
rather a blind guidance, but not so to the old time Friends. The report
to the quarterly meeting in 1779 does not suggest that any progress
has been made, as was desired, save in respect to the masters
employed in the schools.

... to attend the ensuing quarterly meeting at Philadelphia,


and report, that the ... answers are to be transmitted as nearly
our state. That some care has been taken to advise such
negroes who have been restored to freedom. That the
proposals respecting schools have been under consideration
and some essays made by employing masters who are
Friends. That small progress has been made as yet in
laboring for the pious education of the youth.[731]

The next step, as reported in 1781, was the [Sidenote:


appointment of Friends to attend each of the Preparatives
preparative meetings and to do all possible “to visited]
spread the concern” of schools and excite an [Sidenote: The
attention thereunto. No visits were as yet made to demands of the
individual families, and the general feeling of the yearly meeting]
meeting appeared to be that not much progress
had been made.[732] When reading these reports of the monthly
meetings it is well to keep in mind the chief things which the yearly
meeting had desired, (1) the establishment of permanent school
funds, (2) employment of Friends as teachers, (3) houses and
permanent lands, gardens and so forth to be provided for the
accommodation of the masters, etc. With this in mind it is easy to
see that the report of the meetings might be rather faltering even
though they were in some manner supplied with the benefits of
education. In 1781 the quarterly meeting advised those still
unsuccessful in their attempts to meet the set standards “should be
animated and encouraged to give weighty attention to this important
matter.”[733] The only success achieved by Radnor, according to
their own report, was in the employment of Friends for school
masters.[734] In 1786,

The important subjects ... relative to schools engages in


some degree the minds of Friends here but have little further
to mention at present saving that the teachers employed in
several schools appear to be those in religious profession
with Friends.[735]

In 1790 it was reported that one of the [Sidenote:


preparative meetings was considering the Purchase of
purchase of a lot of ground for the purpose of ground proposed]

schools,[736] probably that of Haverford. In July


1791 the committee on school affairs gave a pretty full report, at any
rate the best we can get, on the condition of Radnor’s schools
situated in each of the preparative meetings. The statement issued
by the committee was the following:
[Sidenote: Report
The committee on schools also produced of 1791]
their report thereon in writing as follows—We ...
take the interesting subject of schools into [Sidenote: Two
schools under
consideration, and to visit those wherein either Friends’ meeting]
our preparatives are concerned, have given
unction thereto, and find that although there are [Sidenote:
divers schools kept in the compass of the Haverford Radnor]
and

monthly meeting, two only appear subject to the


rule and direction of Friends, the one being at Haverford, kept
in a house erected in a small lot of ground belonging to that
meeting: This school we visited in company with a committee
of that preparative, which to us seems under its present
circumstances tolerably well conducted; but it does not
appear there are funds established, the salary of the master
being made up by the neighborhood subscription ... some
poor children principally are taught, the expense whereof is
defrayed out of a small annual income arising from a sum left
by a friend for such uses.—The other school is at Radnor, the
house being Friends’ property also; on a visit made to this
school in company of a committee of that preparative
meeting, we found it large at the time and under rules which
appeared pretty well adapted for the government thereof, but
the salary there, as in the aforementioned school, depends on
the transient subscription, and therefore uncertain. At Merion
and the Valley we have not discovered any progress made in
laying a foundation for schools in the way proposed by the
Yearly Meeting. After considering this weighty subject with
attention we are of the mind the several preparatives
(notwithstanding difficulties may occur) should be encouraged
to a continuance of care and exertion herein as strength may
be afforded; in order to carry into effect this desirable object
among us.—Signed on behalf of the said committee by
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookmass.com

You might also like