100% found this document useful (8 votes)
17 views

Instant Access to (Ebook) Supervised Learning with Python: Concepts and Practical Implementation Using Python by Vaibhav Verdhan ISBN 9781484261569, 1484261569 ebook Full Chapters

The document provides information about the ebook 'Supervised Learning with Python: Concepts and Practical Implementation Using Python' by Vaibhav Verdhan, which covers supervised learning algorithms and their Python implementations. It includes a detailed introduction to machine learning, regression and classification algorithms, advanced concepts, and end-to-end model development. The book is aimed at researchers, students, and professionals interested in enhancing their knowledge and skills in supervised learning.

Uploaded by

joganehmer1j
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (8 votes)
17 views

Instant Access to (Ebook) Supervised Learning with Python: Concepts and Practical Implementation Using Python by Vaibhav Verdhan ISBN 9781484261569, 1484261569 ebook Full Chapters

The document provides information about the ebook 'Supervised Learning with Python: Concepts and Practical Implementation Using Python' by Vaibhav Verdhan, which covers supervised learning algorithms and their Python implementations. It includes a detailed introduction to machine learning, regression and classification algorithms, advanced concepts, and end-to-end model development. The book is aimed at researchers, students, and professionals interested in enhancing their knowledge and skills in supervised learning.

Uploaded by

joganehmer1j
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

Download Full Version ebook - Visit ebooknice.

com

(Ebook) Supervised Learning with Python: Concepts


and Practical Implementation Using Python by
Vaibhav Verdhan ISBN 9781484261569, 1484261569

https://ebooknice.com/product/supervised-learning-with-
python-concepts-and-practical-implementation-using-
python-24688908

Click the button below to download

DOWLOAD EBOOK

Discover More Ebook - Explore Now at ebooknice.com


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

Start reading on any device today!

(Ebook) Supervised Learning with Python: Concepts and


Practical Implementation Using Python by Vaibhav Verdhan
ISBN 9781484261552, 9781484261569, 1484261550, 1484261569
https://ebooknice.com/product/supervised-learning-with-python-
concepts-and-practical-implementation-using-python-22417506

ebooknice.com

(Ebook) Computer Vision Using Deep Learning: Neural


Network Architectures with Python and Keras by Vaibhav
Verdhan ISBN 9781484266151, 1484266153
https://ebooknice.com/product/computer-vision-using-deep-learning-
neural-network-architectures-with-python-and-keras-24606292

ebooknice.com

(Ebook) Mastering Machine Learning with Python in Six


Steps: A Practical Implementation Guide to Predictive Data
Analytics Using Python by Manohar Swamynathan (auth.) ISBN
9781484228654, 9781484228661, 1484228650, 1484228669
https://ebooknice.com/product/mastering-machine-learning-with-python-
in-six-steps-a-practical-implementation-guide-to-predictive-data-
analytics-using-python-5880904
ebooknice.com

(Ebook) Unsupervised Learning with Generative AI (MEAP


V09) by Vaibhav Verdhan ISBN 9781617298721, 1617298727

https://ebooknice.com/product/unsupervised-learning-with-generative-
ai-meap-v09-56785444

ebooknice.com
(Ebook) Machine Learning Concepts with Python and the
Jupyter Notebook Environment: Using Tensorflow 2.0 by
Nikita Silaparasetty ISBN 9781484259665, 9781484259672,
1484259661, 148425967X
https://ebooknice.com/product/machine-learning-concepts-with-python-
and-the-jupyter-notebook-environment-using-tensorflow-2-0-22417452

ebooknice.com

(Ebook) Practical Machine Learning for Data Analysis Using


Python by Abdulhamit Subasi ISBN 9780128213797, 0128213795

https://ebooknice.com/product/practical-machine-learning-for-data-
analysis-using-python-11154624

ebooknice.com

(Ebook) Deep Learning with Python: Develop Deep Learning


Models on Theano and TensorFLow Using Keras by Jason
Brownlee
https://ebooknice.com/product/deep-learning-with-python-develop-deep-
learning-models-on-theano-and-tensorflow-using-keras-7295338

ebooknice.com

(Ebook) Mastering Unlabeled Data (MEAP V5) by Vaibhav


Verdhan

https://ebooknice.com/product/mastering-unlabeled-data-
meap-v5-49003820

ebooknice.com

(Ebook) Practical Explainable AI Using Python: Artificial


Intelligence Model Explanations Using Python-based
Libraries, Extensions, and Frameworks by Pradeepta Mishra
ISBN 9781484271575, 1484271572
https://ebooknice.com/product/practical-explainable-ai-using-python-
artificial-intelligence-model-explanations-using-python-based-
libraries-extensions-and-frameworks-36684612
ebooknice.com
Vaibhav Verdhan

Supervised Learning with Python


Concepts and Practical Implementation Using
Python
1st ed.

Foreword by Dr. Eli Yechezkiel Kling (PhD)


Vaibhav Verdhan
Limerick, Ireland

Any source code or other supplementary material referenced by the


author in this book is available to readers on GitHub via the book’s
product page, located at www.​apress.​com/​978-1-4842-6155-2. For
more detailed information, please visit http://​www.​apress.​com/​
source-code.

ISBN 978-1-4842-6155-2 e-ISBN 978-1-4842-6156-9


https://doi.org/10.1007/978-1-4842-6156-9

© Vaibhav Verdhan 2020

Apress Standard

The use of general descriptive names, registered names, trademarks,


service marks, etc. in this publication does not imply, even in the
absence of a specific statement, that such names are exempt from the
relevant protective laws and regulations and therefore free for general
use.

The publisher, the authors and the editors are safe to assume that the
advice and information in this book are believed to be true and
accurate at the date of publication. Neither the publisher nor the
authors or the editors give a warranty, expressed or implied, with
respect to the material contained herein or for any errors or omissions
that may have been made. The publisher remains neutral with regard
to jurisdictional claims in published maps and institutional affiliations.

Distributed to the book trade worldwide by Springer Science+Business


Media New York, 233 Spring Street, 6th Floor, New York, NY 10013.
Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-
[email protected], or visit www.springeronline.com. Apress
Media, LLC is a California LLC and the sole member (owner) is Springer
Science + Business Media Finance Inc (SSBM Finance Inc). SSBM
Finance Inc is a Delaware corporation.
To Yashi, Pakhi and Rudra.
Foreword
How safe is home birthing? That is a good question. Pause a moment
and let yourself contemplate it.
I am sure you can see how the answer to this question can affect
personal decisions and policy choices. The answer could be given as a
probability, a level classification, or an alternative cost. Another natural
reaction is “it depends.” There are many factors that could affect the
safety of home birthing.
I took you through this thought exercise to show you that you
naturally think like a data scientist. You understood the importance of
stipulating clearly the focus of the analysis and what could explain
different outcomes. The reason you are embarking on a journey
through this book is that you are not sure how to express these
instinctive notions mathematically and instruct a computer to “find”
the relationship between the “Features” and the “Target.”
When I started my career 30-odd years ago, this was the domain of
statisticians who crafted a mathematical language to describe
relationships and noise. The purpose of predictive modeling was in its
essence to be a tool for separating a signal or a pattern out of
seemingly chaotic information and reporting how well the partition
was done.
Today, machine learning algorithms harnessing computing brute
force add a new paradigm. This has created a new profession: the data
scientist. The data scientist is a practitioner who can think in terms of
statistical methodology, instruct a computer to carry out the required
processing, and interpret the results and reports.
Becoming a good data scientist is a journey that starts with
learning the basics and mechanics. Once you are done exploring this
book you might also be able to better see where you will want to
deepen your theoretical knowledge. I would like to suggest you might
find it interesting to look into the theory of statistical modeling in
general and the Bayesian paradigm specifically. Machine learning is
computational statistics after all.
Dr. Eli. Y. Kling (BSc. Eng. MSc. PHD) London, UK. June 2020.
Introduction
“It is tough to make predictions, especially about the future.”
—Yogi Berra

In 2019, MIT’s Katie Bouman processed five petabytes of data to


develop the first-ever image of a black hole. Data science, machine
learning, and artificial intelligence played a central role in this
extraordinary discovery.
Data is the new electricity, and as per HBR, data scientist is the
“sexiest” job of the 21st century. Data is fueling business decisions and
making its impact felt across all sectors and walks of life. It is allowing
us to create intelligent products, improvise marketing strategies,
innovate business strategies, enhance safety mechanisms, arrest fraud,
reduce environmental pollution, and create path-breaking medicines.
Our everyday life is enriched and our social media interactions are
more organized. It is allowing us to reduce costs, increase profits, and
optimize operations. It offers a fantastic growth and career path ahead,
but there is a dearth of talent in the field.
This book attempts to educate the reader in a branch of machine
learning called supervised learning. This book covers a spectrum of
supervised learning algorithms and respective Python
implementations. Throughout the book, we are discussing building
blocks of algorithms, their nuts and bolts, mathematical foundations,
and background process. The learning is complemented by developing
actual Python code from scratch with step-by-step explanation of the
code.
The book starts with an introduction to machine learning where
machine learning concepts, the difference between supervised, semi-
supervised, and unsupervised learning approaches, and practical use
cases are discussed. In the next chapter, we examine regression
algorithms like linear regression, multinomial regression, decision
tree, random forest, and so on. It is then followed by a chapter on
classification algorithms using logistic regression, naïve Bayes, knn,
decision tree, and random forest. In the next chapter, advanced
concepts of GBM, SVM, and neural network are studied. We are working
on structured data as well as text and image data in the book.
Pragmatic Python implementation complements the understanding. It
is then followed by the final chapter on end-to-end model development.
The reader gets Python code, datasets, best practices, resolution of
common issues and pitfalls, and pragmatic first-hand knowledge on
implementing algorithms. The reader will be able to run the codes and
extend them in an innovative manner, as well as will understand how to
approach a supervised learning problem. Your prowess as a data
science enthusiast is going to get a big boost, so get ready for these
fruitful lessons!
The book is suitable for researchers and students who want to
explore supervised learning concepts with Python implementation. It
is recommended for working professionals who yearn to stay on the
edge of technology, clarify advanced concepts, and get best practices
and solutions to common challenges. It is intended for business leaders
who wish to gain first-hand knowledge and develop confidence while
they communicate with their teams and clientele. Above all, it is meant
for a curious person who is trying to explore how supervised learning
algorithms work and who would like to try Python.
Stay blessed, stay healthy!

—Vaibhav Verdhan
Limerick,
Ireland. June 2020
Acknowledgments
I would like to thank Apress publications, Celestin John, Shrikant
Vishwarkarma, and Irfan Elahi for the confidence shown and the
support extended. Many thanks to Dr. Eli Kling for the fantastic forward
to the book. Special words for my family—Yashi, Pakhi, and Rudra—
without their support it would have been impossible to complete this
work.
Table of Contents
Chapter 1:​Introduction to Supervised Learning
What Is ML?​
Relationship Between Data Analysis, Data Mining, ML, and
AI
Data, Data Types, and Data Sources
How ML Differs from Software Engineering
ML Projects
Statistical and Mathematical Concepts for ML
Supervised Learning Algorithms
Regression vs.​Classification Problems
Steps in a Supervised Learning Algorithm
Unsupervised Learning Algorithms
Cluster Analysis
PCA
Semi-supervised Learning Algorithms
Technical Stack
ML’s Popularity
Use Cases of ML
Summary
Chapter 2:​Supervised Learning for Regression Analysis
Technical Toolkit Required
Regression analysis and Use Cases
What Is Linear Regression
Assumptions of Linear Regression
Measuring the Efficacy of Regression Problem
Example 1:​Creating a Simple Linear Regression
Example 2:​Simple Linear Regression for Housing Dataset
Example 3:​Multiple Linear Regression for Housing Dataset
Nonlinear Regression Analysis
Identifying a Nonlinear Relationship
Assumptions for a Nonlinear Regression
Challenges with a Regression Model
Tree-Based Methods for Regression
Case study:​Petrol consumption using Decision tree
Ensemble Methods for Regression
Case study:​Petrol consumption using Random Forest
Feature Selection Using Tree-Based Methods
Summary
Chapter 3:​Supervised Learning for Classification Problems
Technical Toolkit Required
Hypothesis Testing and p-Value
Classification Algorithms
Logistic Regression for Classification
Assessing the Accuracy of the Solution
Case Study:​Credit Risk
Additional Notes
Naïve Bayes for Classification
Case Study:​Income Prediction on Census Data
k-Nearest Neighbors for Classification
Case Study:​k-Nearest Neighbor
The Dataset
Business Objective
Tree-Based Algorithms for Classification
Types of Decision Tree Algorithms
Summary
Chapter 4:​Advanced Algorithms for Supervised Learning
Technical Toolkit Required
Boosting Algorithms
Using Gradient Boosting Algorithm
SVM
SVM in 2-D Space
KSVM
Case Study Using SVM
Supervised Algorithms for Unstructured Data
Text Data
Use Cases of Text Data
Challenges with Text Data
Text Analytics Modeling Process
Text Data Extraction and Management
Preprocessing of Text Data
Extracting Features from Text Data
Case study:​Customer complaints analysis using NLP
Word Embeddings
Case study:​Customer complaints analysis using word
embeddings
Image Data
Use Cases of Image Data
Challenges with Image Data
Image Data Management Process
Image Data Modeling Process
Fundamentals of Deep Learning
Artificial Neural Networks
Activation Functions
Loss Function in a Neural Network
Optimization in a Neural Network
Neural Network Training Process
Case Study 1:​Create a Classification Model on Structured Data
Case Study 2:​Image Classification Model
Summary
Chapter 5:​End-to-End Model Development
Technical Toolkit Required
ML Model Development
Step 1:​Define the Business Problem
Step 2:​Data Discovery Phase
Step 3:​Data Cleaning and Preparation
Duplicates in the Dataset
Categorical Variable Treatment in Dataset
Missing Values Present in the Dataset
Imbalance in the Dataset
Outliers in the Dataset
Other Common Problems in the Dataset
Step 4:​EDA
Step 5:​ML Model Building
Train/​Test Split of Data
Finding the Best Threshold for Classification Algorithms
Overfitting vs.​Underfitting Problem
Key Stakeholder Discussion and Iterations
Presenting the Final Model
Step 6:​Deployment of the Model
Step 7:​Documentation
Step 8:​Model Refresh and Maintenance
Summary
Index
About the Author
Vaibhav Verdhan
has 12+ years of experience in data
science, machine learning, and artificial
intelligence. An MBA with engineering
background, he is a hands-on technical
expert with acumen to assimilate and
analyze data. He has led multiple
engagements in ML and AI across
geographies and across retail, telecom,
manufacturing, energy, and utilities
domains. Currently he resides in Ireland
with his family and is working as a
Principal Data Scientist.
About the Technical Reviewer
Irfan Elahi
is a full stack customer-focused cloud
analytics specialist bearing the unique
and proven combination of diverse
consulting and technical competencies
(cloud, big data, and machine learning)
with a growing portfolio of successful
projects delivering substantial impact
and value in multiple capacities across
telecom, retail, energy, and health-care
sectors. Additionally, he is an analytics
evangelist as is evident from the
published book, Udemy courses,
blogposts, trainings, lectures, and
presentations with global reach.
© Vaibhav Verdhan 2020
V. Verdhan, Supervised Learning with Python
https://doi.org/10.1007/978-1-4842-6156-9_1

1. Introduction to Supervised Learning


Vaibhav Verdhan1
(1) Limerick, Ireland

“The future belongs to those who prepare for it today.”


— Malcom X

The future is something which always interests us. We want to


know what lies ahead and then we can plan for it. We can mold our
business strategies, minimize our losses, and increase our profits if we
can predict the future. Predicting is traditionally intriguing for us. And
you have just taken the first step to learning about predicting the
future. Congratulations and welcome to this exciting journey!
You may have heard that data is the new oil. Data science and
machine learning (ML) are harnessing this power of data to generate
predictions for us. These capabilities allow us to examine trends and
anomalies, gather actionable insights, and provide direction to our
business decisions. This book assists in developing these capabilities.
We are going to study the concepts of ML and develop pragmatic code
using Python. You are going to use multiple datasets, generate insights
from data, and create predictive models using Python.
By the time you finish this book, you will be well versed in the
concepts of data science and ML with a focus on supervised learning.
We will examine concepts of supervised learning algorithms to solve
regression problems, study classification problems, and solve different
real-life case studies. We will also study advanced supervised learning
algorithms and deep learning concepts. The datasets are structured as
well as text and images. End-to-end model development and
deployment process are studied to complete the entire learning.
In this process, we will be examining supervised learning
algorithms, the nuts and bolts of them, statistical and mathematical
equations and the process, what happens in the background, and how
we use data to create the solutions. All the codes use Python and
datasets are uploaded to a GitHub repository
(https://github.com/Apress/supervised-learning-w-
python) for easy access. You are advised to replicate those codes
yourself.
Let’s start this learning journey.

What Is ML?
When we post a picture on Facebook or shop at Amazon, tweet or
watch videos on YouTube, each of these platforms is collecting data for
us. At each of these interactions, we are leaving behind our digital
footprints. These data points generated are collected and analyzed, and
ML allows these giants to make logical recommendations to us. Based
on the genre of videos we like, Netflix/YouTube can update our playlist,
what links we can click, and status we can react to; Facebook can
recommend posts to us, observing what type of product we frequently
purchase; and Amazon can suggest our next purchase as per our pocket
size! Amazing, right?
The short definition for ML is as follows: “In Machine Learning, we
study statistical/mathematical algorithms to learn the patterns from
the data which are then used to make predictions for the future.”
And ML is not limited to the online mediums alone. Its power has
been extended to multiple domains, geographies, and use cases. We
will be describing those use cases in detail in the last section of this
chapter.
So, in ML, we analyze vast amounts of data and uncover the
patterns in it. These patterns are then applied on real-world data to
make predictions for the future. This real-world data is unseen, and the
predictions will help businesses shape their respective strategies. We
do not need to explicitly program computers to do these tasks; rather,
the algorithms take the decisions based on historical data and
statistical models.
But how does ML fit into the larger data analysis landscape? Often,
we encounter terms like data analysis, data mining, ML, and artificial
intelligence (AI). Data science is also a loosely used phrase with no
exact definition available. It will be a good idea if these terms are
explored now.

Relationship Between Data Analysis, Data Mining,


ML, and AI
Data mining is a buzzword nowadays. It is used to describe the process
of collecting data from large datasets, databases, and data lakes,
extracting information and patterns from that data, and transforming
these insights into usable structure. It involves data management,
preprocessing, visualizations, and so on. But it is most often the very
first step in any data analysis project.
The process of examining the data is termed data analysis .
Generally, we trend the data, identify the anomalies, and generate
insights using tables, plots, histograms, crosstabs, and so on. Data
analysis is one of the most important steps and is very powerful since
the intelligence generated is easy to comprehend, relatable, and
straightforward. Often, we use Microsoft Excel, SQL for EDA. It also
serves as an important step before creating an ML model.
There is a question quite often discussed—what is the relationship
between ML, AI, and deep learning? And how does data science fit in?
Figure 1-1 depicts the intersections between these fields. AI can be
thought of as automated solutions which replace human-intensive
tasks. AI hence reduces the cost and time consumed as well as
improving the overall efficiency.
Figure 1-1 Relationship between AI, ML, deep learning, and data science shows how
these fields are interrelated with each other and empower each other
Deep learning is one of the hottest trends now. Neural networks are
the heart and soul of deep learning. Deep learning is a subset of AI and
ML and involves developing complex mathematical models to solve
business problems. Mostly we use neural networks to classify images
and analyze text audio and video data.
Data science lies at the juxtaposition of these various domains. It
involves not only ML but also statistics understanding, coding
expertise and business acumen to solve business problems. A data
scientist’s job is to solve business problems and generate actionable
insights for the business. Refer to Table 1-1 to understand the
capabilities of data science and its limitations.
Table 1-1 Data Science: How Can It Help Us, Its Usages, and Limitations
-

With the preceding discussion, the role of ML and its relationship


with other data-related fields should be clear to you. You would have
realized by now that “data” plays a pivotal role in ML. Let’s explore
more about data, its types and attributes.

Data, Data Types, and Data Sources


You already have some understanding of data for sure. It will be a good
idea to refresh that knowledge and discuss different types of datasets
generated and examples of it. Figure 1-2 illustrates the differentiation
of data.
Figure 1-2 Data can be divided between structured and unstructured. Structured
data is easier to work upon while generally deep learning is used for unstructured
data
Data is generated in all the interactions and transactions we do.
Online or offline: we generate data every day, every minute. At a bank, a
retail outlet, on social media, making a mobile call: every interaction
generates data.
Data comes in two flavors: structured data and unstructured data.
When you make that mobile call to your friend, the telecom operator
gets the data of the call like call duration, call cost, time of day, and so
on. Similarly, when you make an online transaction using your bank
portal, data is generated around the amount of transaction, recipient,
reason of transaction, date/time, and so on. All such data points which
can be represented in a row-column structure are called structured
data . Most of the data used and analyzed is structured. That data is
stored in databases and servers using Oracle, SQL, AWS, MySQL, and so
on.
Unstructured data is the type which cannot be represented in a
row-column structure, at least in its basic format. Examples of
unstructured data are text data (Facebook posts, tweets, reviews,
comments, etc.), images and photos (Instagram, product photos),
audio files (jingles, recordings, call center calls), and videos
(advertisements, YouTube posts, etc.). All of the unstructured data can
be saved and analyzed though. As you would imagine, it is more
difficult to analyze unstructured data than structured data. An
important point to be noted is that unstructured data too has to be
converted into integers so that the computers can understand it and
can work on it. For example, a colored image has pixels and each pixel
has RGB (red, green, blue) values ranging from 0 to 255. This means
that each image can be represented in the form of matrices having
integers. And hence that data can be fed to the computer for further
analysis.

Note We use techniques like natural language processing, image


analysis, and neural networks like convolutional neural networks,
recurrent neural networks, and so on to analyze text and image data.
A vital aspect often ignored and less discussed is data quality . Data
quality determines the quality of the analysis and insights generated.
Remember, garbage in, garbage out.
The attributes of a good dataset are represented in Figure 1-3.
While you are approaching a problem, it is imperative that you spend a
considerable amount of time ascertaining that your data is of the
highest quality.

Figure 1-3 Data quality plays a vital role in development of an ML solution; a lot of
time and effort are invested in improving data quality

We should ensure that data available to us conforms to the


following standards:
Completeness of data refers to the percentage of available
attributes. In real-world business, we find that many attributes are
missing, or have NULL or NA values. It is advisable to ensure we
source the data properly and ensure its completeness. During the
data preparation phase, we treat these variables and replace them or
drop them as per the requirements. For example, if you are working
on retail transaction data, we have to ensure that revenue is
available for all or almost all of the months.
Data validity is to ensure that all the key performance indicators
(KPI) are captured during the data identification phase. The inputs
from the business subject matter experts (SMEs) play a vital role in
ensuring this. These KPIs are calculated and are verified by the SMEs.
For example, while calculating the average call cost of a mobile
subscriber, the SME might suggest adding/deleting few costs like
spectrum cost, acquisition cost, and so on.
Accuracy of the data is to make sure all the data points captured are
correct and no inconsistent information is in our data. It is observed
that due to human error or software issues, sometimes wrong
information is captured. For example, while capturing the number of
customers purchasing in a retail store, weekend figures are mostly
higher than weekdays. This is to be ensured during the exploratory
phase.
Data used has to be consistent and should not vary between systems
and interfaces. Often, different systems are used to represent a KPI.
For example, the number of clicks on a website page might be
recorded in different ways. The consistency in this KPI will ensure
that correct analysis is done, and consistent insights are generated.
While you are saving the data in databases and tables, often the
relationships between various entities and attributes are not
consistent or worse may not exist. Data integrity of the system
ensures that we do not face such issues. A robust data structure is
required for an efficient, complete, and correct data mining process.
The goal of data analytics is to find trends and patterns in the data.
There are seasonal variations, movements with respect to
days/time and events, and so on. Sometimes it is imperative that we
capture data of the last few years to measure the movement of KPIs.
The timeliness of the data captured has to be representative enough
to capture such variations.
Most common issues encountered in data are missing values,
duplicates, junk values, outliers, and so on. You will study in detail how
to resolve these issues in a logical and mathematical manner.
By now, you have understood what ML is and what the attributes of
good-quality data are to ensure good analysis. But still a question is
unanswered. When we have software engineering available to us, why
do we still need ML? You will find the answer to this question in the
following section.

How ML Differs from Software Engineering


Software engineering and ML both solve business problems. Both
interact with databases, analyze and code modules, and generate
outputs which are used by the business. The business domain
understanding is imperative for both fields and so is the usability. On
these parameters, both software engineering and ML are similar.
However, the key difference lies in the execution and the approach
used to solve the business challenge.
Software writing involves writing precise code which can be
executed by the processor, that is, the computer. On the other hand, ML
collects historical data and understands trends in the data. Based on
the trends, the ML algorithm will predict the desired output. Let us look
at it with an easy example first.
Consider this: you want to automate the opening of a cola can.
Using software, you would code the exact steps with precise
coordinates and instructions. For that, you should know those precise
details. However, using ML, you would “show” the process of opening a
can to the system many times. The system will learn the process by
looking at various steps or “train” itself. Next time, the system can
open the can itself. Now let’s look at a real-life example.
Imagine you are working for a bank which offers credit cards. You
are in the fraud detection unit and it is your job to classify a transaction
as fraudulent or genuine. Of course, there are acceptance criteria like
transaction amount, time of transaction, mode of transaction, city of
transaction, and so on.
Let us implement a hypothetical solution using software; you might
implement conditions like those depicted in Figure 1-4. Like a decision
tree, a final decision can be made. Step 1: if the transaction amount is
below the threshold X, then move to step 2 or else accept it. In step 2,
the transaction time might be checked and the process will continue
from there.

Figure 1-4 Hyphothetical software engineering process for a fraud detection


system. Software engineering is different from ML.
However using ML, you will collect the historical data comprising
past transactions. It will contain both fraudulent and genuine
transactions. You will then expose these transactions to the statistical
algorithm and train it. The statistical algorithm will uncover the
relationship between attributes of the transaction with its
genuine/fraud nature and will keep that knowledge safe for further
usage.
Next time, when a new transaction is shown to the system, it will
classify it fraudulent or genuine based on the historical knowledge it
has generated from the past transactions and the attributes of this new
unseen transaction. Hence, the set of rules generated by ML algorithms
are dependent on the trends and patterns and offer a higher level of
flexibility.
Development of an ML solution is often more iterative than
software engineering. Moreover, it is not exactly accurate like software
is. But ML is a good generalized solution for sure. It is a fantastic
solution for complex business problems and often the only solution for
really complicated problems which we humans are unable to
comprehend. Here ML plays a pivotal role. Its beauty lies in the fact that
if the training data changes, one need not start the development
process from scratch. The model can be retrained and you are good to
go!
So ML is undoubtedly quite useful, right! It is time for you to
understand the steps in an ML project. This will prepare you for a
deeper journey into ML.

ML Projects
An ML project is like any other project. It has a business objective to be
achieved, some input information, tools and teams, desired accuracy
levels, and a deadline!
However, execution of an ML project is quite different. The very
first step in the ML process is the same, which is defining a business
objective and a measurable parameter for measuring the success
criteria. Figure 1-5 shows subsequent steps in an ML project.

Figure 1-5 An ML project is like any other project, with various steps and process.
Proper planning and execution are required for an ML project like any other project.

The subsequent steps are


1. Data discovery is done to explore the various data sources which
are available to us. Dataset might be available in SQL server, excel
files, text or .csv files, or on a cloud server.

2. In the data mining and calibration stage, we extract the relevant


fields from all the sources. Data is properly cleaned and processed
and is made ready for the next phase. New derived variables are
created and variables which do not have much information are
discarded.

3. Then comes the exploratory data analysis or EDA stage. Using


analytical tools, general insights are generated from the data.
Trends, patterns, and anomalies are the output of this stage, which
prove to be quite useful for the next stage, which is statistical
modeling.

4. ML modeling or statistical modeling is the actual model


development phase. We will discuss this phase in detail throughout
the book.

5. After modeling, results are shared with the business team and the
statistical model is deployed into the production environment.

Since most of the data available is seldom clean, more than 60%–
70% of the project time is spent in data mining, data discovery,
cleaning, and data preparation phase.
Before starting the project, there are some anticipated challenges.
In Figure 1-6, we discuss a few questions we should ask before starting
an ML project.
Figure 1-6 Preparations to be made before starting an ML project. It is imperative
that all the relevant questions are clear and KPIs are frozen.
We should be able to answer these questions about the data
availability, data quality, data preparation, ML model prediction
measurements, and so on. It is imperative to find the answers to these
questions before kicking off the project; else we are risking stress for
ourselves and missing deadlines at a later stage.
Now you know what is ML and the various phases in an ML project.
It will be useful for you to envisage an ML model and what the various
steps are in the process. Before going deeper, it is imperative that we
brush up on some statistical and mathematical concepts. You will also
agree that statistical and mathematical knowledge is required for you
to appreciate ML.

Statistical and Mathematical Concepts for ML


Statistics and mathematics are of paramount importance for complete
and concrete knowledge of ML. The mathematical and statistical
algorithms used in making the predictions are based on concepts like
linear algebra, matrix multiplications, concepts of geometry, vector-
space diagrams, and so on. Some of these concepts you would have
already studied. While studying the algorithms in subsequent chapters,
Exploring the Variety of Random
Documents with Different Content
millions of dollars at stake, depending upon your judicial decisions?
Really, Judd, if you expect things like that to happen, you are as big
a dunce as your industrial masters think you!
It happens that I once knew intimately a very “big” judge; he was a
member of the Court of Appeals of the State of New Jersey, which is
to say he was one of the five highest judges in a state which was
extremely important, because many of our biggest corporations were
formed under its safe and easy laws. At the same time the “big”
judge was a “big” corporation lawyer on the other side of the
Hudson River, in New York state; in fact, he was the highest paid
corporation lawyer in the city, which was surely going some; he was
the author of “Dill on Corporations,” the standard text-book in every
law-school in the country. I have sat in James B. Dill’s library many
an evening, and watched him smoke big black cigars, and listened to
him pour out his soul. I will tell you the first story of his career, and
then I will tell you the last.
A young law-graduate, he got a job in the law department of a big
railroad, I think he said the New York Central; he was to defend
accident suits, and the lawyer who took him in charge pulled open a
drawer in his desk and took out a list of the judges of the state. “You
will notice that some of these names are checked,” said the man.
“When we have cases, get them before one of those judges. Those
are our judges.” Said Dill to me: “That was a young man’s first
introduction to the law.” I asked: “Is it as bad as that now?” He
answered, “There are twenty-two judges of the supreme court in
New York state, and nineteen of them are crooked. I can say to each
one, ‘I know whose man you are,’ and not one will dare contradict
me.”
And then the last story. Dill had just been appointed to his high post
in New Jersey, and the day after the news was published, one of his
old college friends came to see him, and brought him an offer from
E. H. Harriman, railroad magnate, to retain his services in New York
for fifty thousand dollars a year, “and you needn’t do any work.” Dill
said to his friend, “What case has Harriman got before the Jersey
courts?” The friend replied that it was just general principles, the
great magnate liked to have friends on the bench. Dill answered,
“You tell Harriman—being a fisherman you can explain what I mean
—that a fat trout does not rise to a fly.”
Men do not change their skins when they put on black silk robes and
mount the judicial bench. A hard-boiled, hard-fisted attorney for
labor-smashing employers’ associations, such as Butler of
Minneapolis, whose whole political career was an expression of the
hateful arrogance of class-greed—when such a man is raised to the
United States Supreme Court, he does not alter his nature a particle,
but goes right on at his old fighting job and in his old fighting spirit;
only now he has the terrible power to say that acts of Congress are
null and void. The Constitution gives no such power to nullify the will
of the people; and you don’t have to be a “big” lawyer to verify that
—you can read the Constitution for yourself, and see. And then
watch the use which these ex-corporation-lawyers make of this
stolen power! To protect the sacred right of great manufacturing
corporations to employ child slaves! And likewise the right of
employers to underpay their women slaves! And likewise the right of
stock dividends to escape taxation! And likewise the right of judges’
salaries to escape taxation!
But on the other hand, when the rich pass laws in their own interest,
and these laws are in contradiction to the Constitution, what
happens then? The answer is that the courts uphold these laws—and
it matters not how explicit the provisions of the Constitution may be.
The supposed-to-be sacred Constitution of the United States
provides that “the right of the people to keep and bear arms shall
not be infringed”; and yet the legislature of New York state passed a
law forbidding a man to keep a revolver in his home, and a New
York lawyer fought that law to the highest courts, and was beaten.
Here in California the Constitution provides that “every citizen may
freely speak, write, and publish his sentiments on all subjects, being
responsible for the abuse of that right; and no law shall be passed to
restrain or abridge the liberty of speech or of the press.” How could
words be more explicit? And yet we have a “criminal syndicalism”
law, under which seventy men are now in jail for their political
opinions, no other offense having been even charged against them.
I personally, as you know, was arrested and held “incommunicado”
under that law; my offense being that I started to read the
Constitution of the United States, while standing upon private
property with the written permission of the owner, and after notice
to the authorities that I intended to exercise my constitutional right.
Let me tell you a curious detail, in connection with that incident. The
day after I came out of jail I happened to meet on the street one of
the highest judges in this state—I know him because I play in tennis
tournaments with his son. The old gentleman patted me on the back
and said: “Go to it, my boy, you are absolutely right!” But when I
asked him to say that publicly, he didn’t think it would be proper;
and when I asked him to join the Civil Liberties Union, and help to
protect all citizens in such rights, he didn’t think that would be
proper, either. You see how even the most liberal of judges is bound
by red-tape and precedent, and leaves it to others to defend the law.
I have seen in Los Angeles a magazine office raided without warrant
of law, and the editor, a war veteran, manhandled and thrown into
jail—all because the authorities objected to what this editor was
publishing. And not only did the courts permit this, they tried the
man, and would have convicted him if he had not run away. All over
the country such things were done, with the full sanction of the
courts. In New York City federal agents arrested a man and held him
in a room in an office building for three weeks “incommunicado,” and
tortured him until he flung himself out of the window and was
smashed on the pavement below. Two other men began holding
meetings of protest against this outrage, and they were “framed” on
a charge of murder, and the labor movement has so far raised and
spent about a quarter of a million dollars to keep them from being
hanged. That is the Sacco-Vanzetti case, and you may learn about
many as bad or worse from the American Civil Liberties Union, 100
Fifth Avenue, New York.
And how it is with ordinary civil litigation, in which the poor seek
justice against the rich? Here I do not have to ask you to take my
word, for the scandal is so notorious that even capitalist authorities
have been forced to admit it. You see, there are eminent legal
gentlemen, occupied in crushing the poor in major ways—the tariff,
the trusts, the banking graft, “tight money,” child labor, and so on—
but when it comes to a poor widow seeking justice against an
employer who withholds her wages, these gentlemen think that the
law ought to preserve an aspect of impartiality; it ought not be too
obvious that there is one law for the rich and another for the poor.
For example, a majestic plutocrat like ex-president Taft, now chief
justice of our Supreme Court; when such a weighty personage
denounces capitalist justice, you surely will believe what he says!
Here he is, speaking before the Virginia Bar Association: “We must
make it so that the poor man will have as nearly as possible an
equal opportunity in litigating as the rich man, and, under present
conditions, ashamed as we may be of it, this is not the fact.”
Notice the delicacy of the phrasing, Judd: “as nearly as possible!”
There is nothing “utopian” about our chief justice! Just how possible
it is for impotence to be equal to power, is something which has not
yet been shown to us; but evidently there is some limit to the
possibility, for Dean Pound of the Harvard Law School speaks of the
attitude of the law to the poor as “this neglect which disgraces
American justice.”
For my part, you understand, I do not expect the poor ever to get
equal justice against the rich; it seems to me absurd to imagine such
a thing happening. The existence of riches in the world, at the same
time as poverty, is in itself the sum of all injustices; and so, if we
really care about justice, we must either make the rich as poor as
the poor, or else make the poor as rich as the rich, or else strike a
happy medium between the two. This last is my solution and I hope
to show you how it can be done.
LETTER X
My dear Judd:
We have seen the poor struggling to protect themselves against the
rich in the field of politics, and meeting with no great success. There
is another place where they struggle—in the labor market. Let us
see what happens to them there.
Seeing the employers combining into larger and larger organizations,
it naturally occurred to the workers to combine, and sell their labor
as a unit. At first the employers made this action a crime, and a
great many working men went to jail, before the right of labor
combination was granted. Even now, it is only grudgingly granted;
the employers in their hearts are still certain that anything which
reduces their profits is a crime, and through their courts they hedge
the labor unions about with all sorts of restrictions. The doctrine of
the present hour is briefly this: that labor organization is all right,
provided it does not accomplish anything.
You, Judd, are a non-union man. You grew up in small places, and
live now in a suburban neighborhood which is like a small place, in
that everybody knows everybody else, and the people you work for
are not much better off than you are. You can leave your job any
time you don’t like it, and that gives you a sense of freedom. But
suppose, Judd, you had been raised in the slums of a city, and had
to do your carpentering on great buildings, under a firm of
contractors; and suppose you found that your freedom to leave your
job involved the necessity of hunting another job, under some
contractor who belonged to the same employers’ association, and
paid the same scale, and followed the same working rules as your
previous boss? You must see that this would make quite a difference
in your sense of “freedom.”
Or suppose you had grown up in some industrial center, and worked
for the coal trust, or the steel trust, or the beef trust. You have read
“The Jungle,” and know how the wage-slaves of Packingtown lived
twenty years ago. Well, Judd, they are living exactly the same way
today. I said concerning “The Jungle” that “I aimed at the public’s
heart, and by accident I hit it in the stomach”; the public insisted
that some pretense be made that their meat was better, but no one
even pretended that the workers were helped. And the same thing is
true of the slaves of “King Coal”; it did not trouble the American
people to learn that the men who dug their coal were living in
privately-owned empires, where the elemental rights of American
citizens, and even of human beings, had no existence.
In such places the only hope of the workers is to organize, and
present a solid front to their masters, and extort better terms by the
threat of withholding their labor. For a hundred years the workers
have been forging that weapon, and trying it out. There are about
four million of them organized, out of the forty-two million wage-
earners of the country, and that seems a pitiful few; but you know
about the leaven in the dough, Judd. Perhaps it never occurred to
you to realize the influence which the organized carpenters—some
315,000 of them—exercise upon the lives of unorganized carpenters
like yourself. They set a standard, that would otherwise be unknown
in the carpenter world; they make it certain that no boss can get a
really big job done at lower than the union scale—first, because it is
hard to get a lot of skilled men together except through the unions,
and second, because of the constant threat that a union organizer
will get in among them. It is strange to see a man like yourself,
rather suspicious of unions, because of all the poison you absorb
from the capitalist press—and yet at the same time profiting every
working hour of your life from the sacrifices made by union men!
Also it is strange to see employers who fight the unions, and
denounce them, and boast of the contentment of their non-union
workers—and make that contentment by paying the union scale,
which otherwise neither the employer nor the men would ever have
dreamed of! Once let the “open shop” bosses have their way, Judd,
and then see how a “free” carpenter’s wages will drop!
We have seen that there is in America a law for the rich, and quite a
different law for the poor; and that state of affairs is well known to
organized labor, you may be sure. The unions never get far in their
effort to raise their members’ standards, without encountering the
iron fist of the government. I have shown you how the rich defy the
laws they do not like; but let no workingman, union or non-union,
ever make the mistake of trying that! There are jails and prisons,
and also there is the hideous “third degree,” with torture-chambers
where workingmen are taught their “place”—of subjection and
impotence.
Let me give you an illustration, Judd, right here at home, in this
paradise of the “open shop.” We have a group of employers’
federations, with an iron-clad policy of class warfare. An employer
who “panders to the union element” cannot get any business, he
cannot get credit with the banks—they smash him as you would a
louse. And, of course, they keep a card list of men who belong to
unions, they follow a man up—the grim device known as the
“blacklist.” And all this quite openly, it is the industrial policy of Los
Angeles, and its boast. And do you hear anything about its being a
violation of law? Do you see the publisher of the Los Angeles
“Times” being sent to jail for advising employers not to hire
members of the carpenters’ union? No, Judd, you do not see that!
So, naturally, the idea occurred to the workers that two could play at
this game. If the employers could refuse to do business with them,
obviously they could refuse to do business with the employers. So
they tried it; and then what happened? Why then there appeared
suddenly a new crime in the calendar of the law; a monstrous form
of wickedness known as the “boycott!” It was a “conspiracy,” a plot
to ruin a business man and deprive him of his property; and the
judges were called upon to forbid it, and they did so. For violation of
such a judge-made “law,” the Danbury hatters—union workingmen
of Connecticut—were fined $240,000; and the United States
Supreme Court upheld that decision. Afterwards union labor
succeeded in getting a law in their favor through Congress, and now
the courts are engaged in paring that down to nothing. Workingmen
may boycott their own employers, but not other employers! But do
you ever see employers limited to blacklisting their own
workingmen?
I have shown you the judges taking by force the right to annul laws
of Congress. Confronting the emergencies of labor strife, these
judges proceeded to invent another weapon, known as the
“injunction”; which means in brief that any ex-corporation-lawyer on
the bench will issue an order forbidding workingmen to do anything
that the corporations do not want them to do; and the workingmen
have to obey that order, or else the judge will send them to jail for
any length of time that the corporation may desire; and there is no
jury trial, and no defense, and no redress—the workingmen just go
to jail!
What these injunction judges have forbidden labor to do makes a
catalog over which you might have a good laugh, if you could forget
all the heartbreak and agony of the poor that is summed up in the
preposterous sentences. All the hopes that were blasted, the pitiful
hopes of a little better food for a sick wife, of a chance to keep the
children in school! Such things are the meaning of a strike to
workingmen; and suddenly a grim personage in a black silk robe lifts
a club and smashes these hopes over the head! As I write, some
clothing workers of New York are on strike, and a judge has issued
an injunction, forbidding them, not merely to picket the shops of
their boss, but to go within ten blocks of the place! In the West
Virginia coal fields, they are now forbidding mass-meetings,
forbidding the use of money in unionizing the mines, and even the
use of tent-colonies for the families of miners who have been
ejected from company houses! In Oklahoma they recently forbade
miners to pray! In Minneapolis I talked with a labor man who had
spent six months in jail for violating an injunction, and he gave me
the thing to read, a list of prohibitions that would fill a couple of
pages of this book; as the man said, “I’d have broken the law if I’d
waked up in the night and disliked my boss.”
And every year they are encroaching a little farther on the rights of
the workers, and of all citizens. They are trying to set up the
principle that it is a conspiracy against the public welfare to interfere
with “essential industries.” Thirty years ago, when Grover Cleveland
sent in Federal troops over the head of Governor Altgeld of Illinois,
and smashed the strike of the railwaymen, and threw Gene Debs
into jail, it was considered quite a startling action. But now we have
got used to things like that, and in 1922 they imprisoned eight
railway leaders in Los Angeles, calling their strike “a conspiracy to
interfere with the mail.” Now President Coolidge, in his message to
Congress, is calling for a law to forbid all such strikes, and take off
the shoulders of the judges the embarrassment of having to create
the law!
And so, once more, Judd, do you see why the rich are growing richer
and the poor poorer? Do you see why the index figures of a
university professor revealed that the wage-earners of America,
taken as a whole, were five per cent poorer today than in 1890? I
told you that riches and poverty are not caused by the Will of God,
nor yet by any implacable Economic Law, but purely and simply by
the actions of men, driven by the basest of all human impulses,
which is greed. And here you see, Judd, exactly what these actions
are. Every time an ex-corporation-lawyer on the bench issues an
injunction which smashes a strike, he is reducing the average real
wages of the workers of America; he is taking away a little more
from the poor, and handing it to the rich—and that is the job for
which the rich set him up in office, and bought him his black silk
robe!
LETTER XI
My dear Judd:
I don’t know whether you ever played poker, but I did a few times in
my naughty youth. I recall a game known as “freeze-out”; you
played till you lost all your money, and the game ended entirely
when one man got all the chips. That is our social system—a
colossal game of “freeze-out,” with winter and disease and death to
clear the players from the board. Those who lose at the game are
the workers of the world.
You, Judd, must realize that you are in an unusual position for a
worker grown old; you own two lots and three houses, and can live
partly on the rent. But how many others are there like that?
Consider the statement given out this month by the Industrial
Accident Commission of California: “One million men and women of
America suffered disabling accidents in industries this year.”
Assuming that a workingman puts in forty years, as you have done,
what are his chances of getting off without a disabling accident?
There being forty-two million people gainfully employed, the chances
would appear to be one in twenty; but of course only part of the
disabling is permanent—the victims get well, and go back to be
disabled again. The number of accidents increased 30 per cent in
1924, so you see your chances grow less and less.
The worst you got, Judd, was a rupture. But suppose you had been
one of the 21,232 to be killed; or suppose you were of the 105,629
who suffered “permanent partial disability” last year; or suppose that
you had eight or ten children, instead of one or two; or that your
wife, instead of dying in an accident as she did, had been crippled,
and left upon your hands for life. Do you think you or your heirs
would still have the two lots, and the three houses, and the fine
American sense of security?
Look, old friend, here are some figures worked out from insurance
tables by the National City Bank of New York, the richest bank in the
country. They are trying to persuade people to take out insurance,
so that the money will come back to Wall Street for them to use in
stock gambling. Taking 100 people 25 years old, they ask what will
be the position of these same people at the age of 65; and they say
1 will be independent, 4 will be well to do, 5 will be working for a
meagre living, 36 will be dead, “many of them for want of attention
that money would have secured,” and 54 will be dependent upon
others. “Out of the entire 100, only 5 will be in satisfactory
circumstances.” There you have a picture of what the richest nation
in the world has been able to achieve in the way of sound human
happiness!
Our Mother Nature is a wasteful parent, who creates many millions
of salmon eggs in order to produce one salmon. It is the same way
with human life also in its dark beginnings; history is a tale of mighty
empires arising only to be destroyed again, and of populations wiped
out by plague and famine and slaughter. But now the light of reason
is beginning to dawn; a few of us have the idea that human energies
might be rationally guided, and that men might cease to spend their
time digging holes in the sand and filling them up again.
Consider war. Women bear children with much pain, and raise them
with loving care, and then send them out, at the very prime of their
lives, to be blown to pieces by shot and shell. Other men in
factories, who might be making the means of human happiness—
automobiles and radio sets and books and music—these men are
making explosives to wipe out whole cities, and gases to poison the
inhabitants. In the late war we destroyed 30,000,000 human beings
and $300,000,000,000 worth of treasure, the product of a whole
generation of useful toil.
They promised us that this war was to be the last, but what are the
prospects? In 1912 our government spent for defense nearly a
quarter of a billion dollars, and our 1926 budget for the same
purpose is more than three times that amount. In 1920 the Bureau
of Standards analyzed our budget and found that expenses for wars,
past and future, composed 93 per cent thereof. Think of it, Judd, a
great government spending one dollar to save life and property, and
thirteen dollars to destroy it! Of course, the military men will say
that the thirteen dollars are to prevent other nations from destroying
us, but the obvious fact is that when we spend this money on
armaments we cause other nations to do the same, so we might as
well do our own destruction and have it over with.
Or consider child labor. We take a million children out of school and
put them into factories and mines, thus stunting them in body and
spirit, and when they grow up into cripples, defectives, criminals and
grafters, we pay ten or a hundred times what we got out of their
childhood labor! Or consider crime, which is caused by the presence
of extreme poverty alongside extreme wealth. Including criminals
and those who catch them, this factor of waste keeps more than
700,000 persons out of productive work. Or take prostitution, caused
by poverty and low wages of women in industry. There are over a
quarter of a million women in our country who live by spreading vice
and disease, and the American Social Hygiene Association estimates
that this costs us $628,000,000 every year.
Or consider adulteration, the putting of worthless goods and
poisonous foods upon the market, all for profits, of course. Or the
wastes of advertising—the seekers of profits spending a billion and a
quarter dollars a year, and keeping more than 600,000 people busy
all the time, in order to persuade us to stop buying the worthy
products of Jones and to buy the unworthy products of Smith. This
is civil war within our industry, and one of its weapons is fashion, the
making of imbecile changes in our goods every season, in order that
we may be ashamed to wear our perfectly good clothes after the
first year.
Or take the wastes of mismanagement of industry. The so-called
“Hoover Committee” of the American Engineering Societies made an
elaborate study of this field, and it is interesting to notice that this
employers’ body attributes 50 per cent of the blame to management
and only 25 per cent to labor. They estimate the percentage of
waste in a few great industries: Metal trades, 28 per cent; boots and
shoes, 40 per cent; textiles, 49 per cent; building, 53 per cent;
printing, 57 per cent; men’s clothing, 63 per cent. Notice that figure
for building, Judd, and be sure you get what it means: out of 40
years you put in at carpentering, 21 years went to no purpose,
because those who directed your labor were making money instead
of making houses!
One great form of industrial waste is men and women willing to
work, and able to work but unable to find work to do. I regard this
as the basic evil, the cause of most of the others, and I believe that
it is an essential part of our present profit system, without which
that system would break down. First, let us see exactly how
widespread the evil is.
I point out, Judd, that nowhere in these letters have I given you any
Socialist figures about anything; in each case I go to the most
“respectable” authorities, those who are least favorable to my point
of view. In this case of unemployment I consult a volume prepared
and published with money derived from the estate of one of the
richest landlords and money-lenders that ever died in the city of New
York. I refer to the Russell Sage Foundation, and here is the
sentence in which they sum up their final figures on unemployment:
“To conclude that, averaging good and bad years, from 10 to 12 per
cent of all workers are idle all of the time, is probably an
understatement of the situation.” The book calculates the number
gainfully employed at 42,000,000, and 12 per cent of that is over
5,000,000.
When you talk about five million people out of work it doesn’t mean
much, because we haven’t the mental power to grasp such a thing.
Let us say one person out of work, and see what it means. It so
happens that before I sat down to my typewriter this morning the
postman brought a letter from such a person; twelve miles away
from us, in the great rich city of Los Angeles, a war hero is begging
a job, and his wife and children are starving. This hero encloses a
visiting card, reading, “D. S. C.”—that means “Distinguished Service
Cross”—and down in the corner is “Chevalier Legion d’ Honneur;
Croix de Guerre,” the decorations prized above all things in France.
And on the back of the card he has written: “Ex-soldier, bonus-pest,
charity-dependent.” He encloses newspaper clippings: “Top-sergeant
in the suicide squad of machine gunners,” left for dead on the field,
taken to base hospital, returned to front, made lieutenant, more
hospitals and medals—regular hero stuff, you see, and here he has
been hunting any sort of job for months, and tells me how it goes:
“Louise the baby is low from malnutrition. Virginia, the oldest, the
invalid around whom my book is written, coughs all night
incessantly. We are making our last stand. As completely isolated as
though in the heart of the Sahara. Today I received my first offer of
a good job in weeks, but it necessitates my providing at least $22 of
special tools. It’s on tractor transmission; I built them shortly after
the armistice, but when I entered Stanford University I was through
with mechanics, and gave away my kit. I took my D. S. C. and other
war junk down to my favorite pawnbroker Saturday but they
wouldn’t bring carfare to Pasadena now.”
So here, you see, is one of the victims of our great game of “freeze-
out”; and what was his weakness that caused him to lose in the
game? The answer is plain enough—he believed the propaganda of
our war profiteers and went over to France and risked his life and
ruined his health and fortune—while 23,000 able business gentlemen
stayed at home and made themselves into millionaires! “What price
Glory,” Judd!
LETTER XII
My dear Judd:
I have said that unemployment is a disease of the profit system,
incurable under that system. I am now going to show why, and I
consider these facts the most important in the whole world for a
workingman to understand. They are perfectly simple—any child can
grasp them; yet they are never mentioned in any newspaper, and
never taught in any school. The reason is equally simple—any editor
who publishes them, or any teacher who teaches them, immediately
loses his job.
I put them into a series of short sentences for you to paste all
around the rim of your hat and study while you are sawing timbers
and mixing cement. First, then:

The boss is not in business for his health. Ask him!

And then, equally easy to verify:

The boss will make no more goods than he can sell at a profit.

And so, plainly enough:

Profits for the boss, wages for the workingman; no profits for
the boss, starvation and death for the workingman.

So far, every business man will agree; in fact, this is the doctrine
they hammered into your head during the Coolidge campaign, and it
got them seven million plurality. All right, then; and now let us
suppose, just for the sake of arguing, that the Coolidge
administration believed in allowing the rich to charge as high prices
as they pleased for goods, and to break strikes and beat down the
wages of the poor; what would happen then? Why, obviously the
poor wouldn’t have the money to buy so much goods or to furnish
so much profits for the bosses; it would be only the rich who had the
money, and goods would be more and more for the rich, and less
and less for the poor. Take notice, Judd, the Secretary of the
Treasury estimated that in 1919 the amount spent for luxuries in our
country was $22,700,000,000—and with millions of families lacking
bread!
But with the flood of goods pouring out from the machines, the rich
find it harder and harder to consume the product; they take to
reinvesting their money, that is, using it to make more machines, to
turn out more goods, to be sold for more profits. But already there
are more goods than can be sold; there are no longer enough profits
to supply the demands of the great mass of heaped-up capital. So
comes a glut of goods, and factories have to shut down, and we
have “hard times.” Just what are “hard times,” Judd? Paste this in
your hat now:

Hard times are tenant farmers starving because they have


raised too much food!

And again:

Hard times are weavers in rags, because they have made too
much clothing!

And again:

Hard times are carpenters homeless, because they have built


too many houses!

And finally:

Hard times are workingmen who have finished making the world
for their masters, and are ordered to move on to some other
planet!
You will say, Judd, that such absurd things could never happen. To
that I answer, very simply:

They are happening right now to several million Americans who


are hunting jobs and not finding them!

This insanity of “hard times” comes periodically in our affairs, in


great waves known as “business cycles”; they are due at intervals of
from seven to ten years, and are just as inevitable as the tides of the
sea. Learned economists study the history of these tides of ruin and
make charts and diagrams of them; but if you state the cause, you
become an outcast from the business world; and so naturally
nobody does state it—except a few outcasts like myself.
The professors of economics admit that this trouble is caused by
“over-production,” and we must get straight exactly what that
means. It doesn’t mean that we have produced more than we need;
on the contrary, we have millions living below the wage level of
common decency—our average wage is $1,200 a year, and the cost
of keeping a family on the bare necessities is $2,000. But it doesn’t
matter how much people need; the thing that counts is what they
can buy. I give you another slogan, and next time you meet a
professor of economics, ask him about it:

If you’ve got the price, you’re a consumer; if you haven’t got


the price, you’re a bum.

Well, since we American consumers can’t buy our own product, the
owners of the product—that is, the rich—have to look elsewhere for
customers, and so comes the hunt for “foreign markets.” Understand
me, I do not object to our going abroad for the things we can’t raise
at home; to exchange automobiles and moving pictures for bananas
and coffee—that is normal business. What I am talking about is a
glut of goods that we can’t sell at home, but must sell abroad, under
penalty of seeing our workers turned off to starve. We don’t take
goods in exchange—oh no, that would break down our home
industries, and we protect them by a high tariff wall. What we take
are paper promises to pay us at some future date; we go on
continually selling more than we buy, and filling our bank vaults with
these paper promises, and that is called a “favorable balance of
trade.”
But all the highly developed nations, Britain and France and
Germany and Italy and Japan, are in exactly the same plight as
ourselves; they also have more goods than their half-starved
workers can purchase; they also are looking for foreign markets, to
save their business system from collapse. Each finds its chance of
salvation in selling to the backward nations, which cannot yet do
their own manufacturing. So we run upon this curious situation:

The existence of American industry depends upon our selling


cotton shirts to Chinamen, who are so poor they can’t afford but
one shirt at a time.

And now, see the next step! Trying to save our own business
system, we threaten ruin to the business system of some other
country, say Japan. Naturally, the business men of Japan don’t like
that; so we have trade rivalry, and out of that we have war. The
cause of modern war may be put into one sentence—and I beg you
to realize that it’s no joke, but the grimmest of grim realities:

If we don’t go to war with other nations, they will take away


from us the chance to sell to Chinamen those cotton shirts of
which our workers have produced so many that they have to go
in rags.

I could go on like that indefinitely, making funny sentences about


this funny system. I could tell the hilarious story of how Britain and
Germany went to war to take away from each other the chance to
sell shirts to Chinamen—and to Hindoos and Persians and Arabs and
Turks, of course. When they had destroyed 30,000,000 human lives
and $300,000,000,000 worth of goods you might think they would
have cured their “over-production” for quite a while; but they had
made a miscalculation, and fought too long, and borrowed too much
money from us, and so their governments are burdened with
enormous fixed charges, and there is chronic unemployment in both
Britain and Germany, and almost a collapse in France.
And how about us? We have that “favorable balance of trade,” so
ardently desired by the prosperity boosters; indeed, we have got
such a bellyful of it that for the first time we are forced to realize
that it’s nothing but wind. Europe owes us, in one form or another,
some $19,000,000,000, and can’t even pay the interest; they made
no pretense of trying—until they had to borrow some more! Italy
came, bowing low and grinning behind its cap, agreeing to pay
several billions in the course of 65 years—on condition that we lend
another $200,000,000 right off! Germany did the same thing, and
France will be doing it, probably before these words see the light of
day. Our great financiers accept these paper pledges, for the reason
that they are stuck with $19,000,000,000 of them already, and can’t
contemplate what will happen when the whole thing turns out to be
wind. We go on adding about a billion a year, because the only way
we can keep our factories going is to ship our surplus goods abroad
—and take nothing back, because that would stop the factories!
We promised our people “prosperity,” you remember, if only they
would vote for Coolidge; and they did so, good, patient souls; so
now we have to deliver it. The way of “prosperity” is to keep them
working to feed and clothe Frenchmen and Germans and Italians
and Chinamen and Guatemalans and Haytians—anybody who will
send us a beautiful engraved sheet of paper promising to pay us 65
years from now! To be exact, Judd, they don’t even have to engrave
the paper; we do that in Wall Street, and they send us a “mission” of
white or yellow or black gentlemen in frock coats, to sign opposite
the red seal. So here, Judd, you have this wonderful jazz system in
its final, delirium stage—our whole people starving themselves on
half wages, and sending the surplus abroad, so that our rich men
may fill their vaults with pieces of paper which they dare not permit
to be redeemed! We already have more than half the gold in the
world, and far from taking any more, we have to ship some abroad
now and then, to keep some debtor nation from going bankrupt!
Don’t you wish, Judd, that you could find some benevolent
storekeeper to do business with you on this ultra-modern jazz basis?
Never, never can he be persuaded to take your money, but takes
only checks, and does not cash them for 65 years; and if at any time
you need money, you threaten to go broke, and immediately he
gives you cash and takes some more checks; and if ever you try to
send him a truckload of goods, to pay off at least part of the debt,
he holds up his hands in a fit of high-tariff horror and says he
couldn’t think of taking goods, it would ruin the people inside his
store who have the jobs of making that same thing! “For God’s sake,
take away your truck,” he exclaims. “Just mail me another paper
promise, and anything in the place is yours!”
I conclude with one more sentence for you to learn, Judd:

Our present system of “high finance” is a soap-bubble, which


differs from other soap-bubbles in just one respect—it is as big
as the world.
LETTER XIII
My dear Judd:
The essence of our industrial system is the private ownership of the
means of production; with profit for the private owner as the motive
power of industry. The capitalist produces the goods we need, and in
order to get them we pay him everything above the bare means of
keeping us alive and enabling us to raise the next generation. If this
system should break down, it is obvious that we must change to
some form of social ownership of the means of production; instead
of having the capitalist produce for us, we must do it for ourselves,
and the motive power will be, not the desire of the capitalist for
profit, but our own desire for the goods.
What difference will that make in the industrial system? At first you
might see no difference at all. The worker will go to the factory,
where he will find foremen and superintendents in charge, and a
time-clock keeping tab on him. On Saturday night he will get his pay
envelope, and will take the money and spend it at the stores. The
goods produced in the factory will be shipped to all parts of the
world, to people who pay for them by checks, which go through
banks and a clearing-house—you might follow the whole process,
and fail to realize there had been any change. At only one place
would the difference appear—inside the pay envelopes. There being
no longer any absentee owners, drawing off rent, interest and
profits, those who do the work, whether of hand or brain, will now
be the only people to draw anything out; and consequently there will
be considerably more in each pay envelope.
Wall Street propagandists are fond of figuring how much goes to
labor and how much to capital, and proving that to wipe out the
capitalist would add only a small percentage, say ten per cent, to the
share of each worker. This is a trick, for the reason that a great part
of the capitalist’s share appears, not as profits, but as various forms
of “fixed charges” against the industry: the interest on bonds, the
rent of land, the royalties to owners of various privileges. To give
just one illustration, the New York Central Railroad crosses a bridge
near Albany, and a private concern owns that bridge, and the
railroad pays one cent for every passenger, a small fortune every
year. Our whole industrial system is a tangle of grafts such as that;
the railroads are plundered by right-of-way companies, sleeping-car
companies, refrigerator-car companies; industrial concerns are
plundered by private railway lines, owned by “insiders,” or by
companies having a “cinch” on repairs or materials or accessories.
Just the bookkeeping on such rights is a vast industry, and the
adjusting of them supplies a living for thousands of lawyers and their
clerks. To wipe all that out will be to dump a mountain’s weight off
the back of production.
But even suppose it was as the Wall Street propagandists argue—
that capital got only ten per cent—would that be the only gain for
labor? No, Judd, it would not; and here is the most important point
that I have to get across to you in these letters. The proposition may
seem difficult, but I beg you to put your mind on it and get it
straight, for it is not too much to say that all freedom and happiness
for the workingman in our time depend upon his understanding
these matters, so that the clever hired writers of privilege cannot
befuddle his mind.
Whatever may be the percentage that goes to capital—whether ten
per cent, as Wall Street claims, or thirty or forty per cent, as I could
prove—nevertheless it is this percentage which causes our industrial
ills today. It is this surplus which, drawn off and re-invested in more
means of production, causes the glut of goods which we know as
“hard times”; it is this surplus which causes speculation and panics,
and turns the worker out to join the ranks of the “unemployed,” and
to beat down the wages of his fellows; it is this surplus which causes
the search for foreign markets, and draws the great industrial
nations into war. Figure to yourself a body having an iron ring
riveted about it. At first this ring makes no difference, but as the
body grows it causes strangulation, and the time comes when for all
the agonies of that body there is but one remedy, to cut the ring.
Cutting the ring is simply this: to take the surplus product away from
capital and give it to labor; so instantly you have remedied the evil
and relieved the pain. How so? Because labor now becomes able to
consume the entire product of industry. Labor can consume it,
because labor has the money to buy it. Before this, as we have
seen, labor got only part of the money, and so could buy only part of
the product; the rest had to be either wasted by the rich, or sold
abroad. But give labor the full value, the actual equivalent in
purchasing power of the amount of goods produced, and so
consumption balances production, and the factories can work
merrily, as many hours as we desire, turning out for each and every
one of us as much goods as we care to consume. The only
restriction is the basic law of social justice—that before any man
consumes anything he must render to the community an equivalent
service.
The hired men of the exploiters do all they can to confuse this
argument; I hear them laugh that I have some kind of deluded
horror of a surplus. We ought to save, they insist, and provide
against a “rainy day”! Yes, of course—and not merely against rain,
but against famine and earthquake and tornado. I have no objection
whatever to a surplus; the question is, who is to own that surplus—
those who do the work, or those who live as parasites? That makes
all the difference; for when a workingman has made too much
wealth for his master, the workingman is out of a job; but when the
workingman has made too much wealth for himself, the workingman
is on a vacation.
Here is this great rich country of ours, with all its natural resources,
its marvelous machines, its willing and clever workers; and when we
have broken the iron ring we can produce goods for ourselves, and
consume and enjoy them, and stay quietly within our own
boundaries. No longer do we keep our workers on starvation wages,
and ship all our surplus products abroad, to be consumed by
Frenchmen and Italians and Turks and Chinamen and Hindoos, in
return for paper promises to pay money to our capitalists! No longer
do we have to go to war, to seize foreign markets from other
capitalists! The workers now own the factories, and also they own
the working capital, and they produce goods for use, and if we have
foreign trade it is because we want things from abroad, and not
because we have to get rid of our surplus product under penalty of
starving. This is what I describe as a Free Society, Judd; I say that in
such a society, with production rationally planned, and all wastes
removed, we should produce wealth in such quantities, so quickly
and so easily—well, you would think I was joking. But leading
engineers have told us that we have, in our machine power, the
constant labor of three billion slaves. In thirteen industries, figured
by the capitalist, Mr. Babson, we have 88 times the productive power
we used to have by hand labor. Just think what that ought to mean!
Or look at it another way. Twenty years ago Sidney A. Reeve, an
engineering expert, calculated how much we wasted by the
competitive production of goods, and in a big book full of tables and
charts, he worked out the figure of 70 per cent waste. We have seen
the Hoover Committee, considering merely the wastes inside each
industry, giving figures as high as 60 per cent of waste. Mr. Stuart
Chase, in his wonderful book, “The Tragedy of Waste,” figures 50 per
cent as the minimum. Well, let us take the minimum, for a start.
What does it mean? I answer:

In a free society what we now have will cost us four hours labor
a day.

And more than that, Judd—something absolutely vital to every poor


man in our country:

In a free society every man may work as many hours as he


wants to work, and get the full value of what he produces.
So now we can make what would have seemed at the beginning a
bold claim:

From a free society involuntary poverty will be banished.

And finally—one sentence more—and I beg you to learn this one:

The end of involuntary poverty means the end of most


prostitution and crime, and of all war between civilized peoples.
LETTER XIV
My dear Judd:
It is an interesting thing to study the development of human society
through a long period of history. Men began in small tribes, in which
they were very much alike, and stood on an equal footing. These
tribes fought, and absorbed one another, and grew more complex,
with greater differences among the members; dukedoms and
principalities arose, and then kingdoms, and at last great empires,
with rulers and subjects ranged in classes, and the class lines rigidly
drawn.
It was against such a form of society that our ancestors revolted;
they had a new theory of government, and established a new form—
a republic, owned and run by its citizens, all standing on an equal
plane. The process of evolution in the political world is still going on,
and some day we shall see a world-wide federation of republics, in
which the human race will share equal rights.
It is fascinating to realize that this same process is going on in the
world of industry. Here also we see the various enterprises
struggling, and some winning and absorbing the others, until today
we have industrial monarchies and empires. It is not merely a figure
of speech when we talk about coal barons and steel kings and
emperors of finance, for these men occupy the same positions and
hold the same kind of power as the rulers of old days. And just as
we saw revolutions in the field of politics, so we shall see them in
industry. In fact, the first of these great revolutions has taken place
before our eyes; the workers of Russia are now trying to show us
that a government of industry by the citizens of industry is a possible
thing and a step in progress. Our capitalist newspapers are sure that
they must fail; but even if they did, that would not upset the
argument, for the first political revolution in England failed, and the
first two in France; but that has not kept a whole string of other
countries from turning into republics.
The way human beings learn is by trying; and we are in the stage of
history where men are getting ready to try democracy in industry.
There will be mistakes, and a great deal of waste and suffering;
nevertheless, we shall press on, and in the end we shall achieve a
higher type of society than anything conceivable under industrial
monarchy, or imperialism such as we have today.
You remember King Louis of France, the “grand monarch,” who said,
“The state, it is I”; well, imagine the scoffing you would have met
with, if you had talked with some haughty marquis of that court, and
tried to tell him how some day in France the common “riff-raff”
would have votes, and choose parliaments, and decide the issues of
war and diplomacy. He would have been quite sure they could never
do it; and as a matter of fact, they don’t, Judd—but they will; yes,
even here in the United States the people will some day decide!
Today our great captains of industry are no less certain that common
workingmen cannot possibly have intelligence enough to run
factories, to say nothing of deciding the broad policies of business.
The masters have won the money fight, and got the power, and they
mean to hold on to it, and train their descendants and found great
money-dynasties. But the same thing happens that we saw two
hundred years ago with the French kings—the new generations
become enervated and worthless, and the wealth of the community
flows into the lap of idlers and parasites, who squander it in
dissipation and display; the poor become discontented and
rebellious, and the rumble of the approaching deluge is heard.
Our capitalist newspapers never get tired of harping upon the
failures of government ownership, the waste and the graft. Private
ownership is the way to efficiency! Well, Judd, there is a lot of
present-day efficiency which I am ready to do without, beginning
from this very hour. For example, efficiency in maiming and killing
workers—which caused one million in our country to be disabled in
1925! Labor today works under the lash of the slave-driver, and I am
willing to see industry slow down, so that workingmen may be
human beings. And then, I examine the graft under public
ownership, and what do I find? Private owners seeking private
profits out of government! Here is a slogan, Judd:

The cause of graft is not public ownership of industry, but


private ownership of politicians!

How can we stop that? We have tried the plan of sending the
grafters to jail, but that doesn’t work, for the reason that the
grafters buy the prosecuting officials and the judges; in the few
cases where we get them into jail, they buy the jailers. So I suggest
a new plan—that we take away the motive to graft, by making it
impossible for any man to exploit the labor of his fellows, or to
monopolize those things which are necessary to the life of all.
Learning industrial democracy is like learning to swim. You stick one
foot into the water, and you see that it sinks, and so you draw it out
in a hurry, and decide, it is impossible for you to stay on top of the
water. And then along comes a man who says: “Yes, you can swim,
but not until you go all the way in.” It seems an absurdity at first, yet
it is the literal truth about government ownership; you can own and
run it all, but you can’t own and run a small part!
At present private ownership is making all the big profits, and so, of
course, it is paying all the big salaries, and getting most of the
competent men. Not content with that, it is undermining the
competition of government, using its huge resources to buy the
political parties, and nominate incompetent men to public office.
That is no wild statement, but a fact of big business policy. Our
masters, who control the political parties, are afraid to have
competent men in public office, for fear they might take up a notion
to do something real for the public welfare. They prefer a man who
can’t kick over the traces, because he is too feeble. That is why at
the last nominating convention they turned down a really competent
and loyal servant of theirs, Mr. Herbert Hoover, and gave us poor,
shy, pitiful Mr. Coolidge, who can never by any possibility do
anything, for the reason that he doesn’t know what to do.
When you and I, Judd, and the rest of the useful workers of
America, get ready to run our own business, we can do it. We shall
do it, if for no other reason, because we have to—because we need
food in our cities, and machinery on our farms. We shall hire the
best experts to run our industries; and many of them will be the
very men who are running them now—they will be just as well
content to work for the American people as for Johnny Coaloil, who
is now taking a yachting trip with a dozen chorus girls on the Riviera,
or for Mrs. Silly Splash, who is setting the new fashion in diamond-
embroidered bathing suits at Palm Beach. Yes, Judd, we shall find
ways to run our business without these elegant idlers; and whatever
waste there may be won’t be so bad as having them corrupt a whole
generation of our young people by their vicious folly. If there is graft,
we’ll find ways to stop it, and if more efficiency is needed, we’ll get it
—because it will be our business, and our loss if we fail.
I’ll go even further, Judd; I’ll assert that the amount of waste
inherent in capitalism is so frightful, that no amount of inefficiency
under a free system can approach it. Remember the “iron ring,” and
what it will mean to us to get into the factories, with the right to run
them for ourselves! Remember our figures on the wastes of
competition! Let us have a “slogan,” for you to paste in your hat and
learn, Judd:

To compare the productive powers of a free system with those


of capitalism, is to compare a normal human being with a
vicious maniac.

Just a sentence or two, Judd, to remind us what this maniac has


done:

Capitalism, between 1914 and 1918, deliberately destroyed


30,000,000 human lives, and $300,000,000,000 worth of
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!

ebooknice.com

You might also like