Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (1 vote)
8 views

Python deeper insights into machine learning leverage benefits of machine learning techniques using Python a course in three modules Hearty - Download the ebook and explore the most detailed content

The document provides an overview of various Python-based machine learning resources available for download at textbookfull.com, including titles that cover practical applications, advanced techniques, and interview preparation. It outlines a structured learning path consisting of three modules aimed at enhancing skills in machine learning using Python. Additionally, it emphasizes the importance of understanding machine learning systems and offers guidance on necessary tools and prerequisites for learners.

Uploaded by

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

Python deeper insights into machine learning leverage benefits of machine learning techniques using Python a course in three modules Hearty - Download the ebook and explore the most detailed content

The document provides an overview of various Python-based machine learning resources available for download at textbookfull.com, including titles that cover practical applications, advanced techniques, and interview preparation. It outlines a structured learning path consisting of three modules aimed at enhancing skills in machine learning using Python. Additionally, it emphasizes the importance of understanding machine learning systems and offers guidance on necessary tools and prerequisites for learners.

Uploaded by

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

Explore the full ebook collection and download it now at textbookfull.

com

Python deeper insights into machine learning


leverage benefits of machine learning techniques
using Python a course in three modules Hearty

https://textbookfull.com/product/python-deeper-insights-
into-machine-learning-leverage-benefits-of-machine-learning-
techniques-using-python-a-course-in-three-modules-hearty/

OR CLICK HERE

DOWLOAD EBOOK

Browse and Get More Ebook Downloads Instantly at https://textbookfull.com


Click here to visit textbookfull.com and download textbook now
Your digital treasures (PDF, ePub, MOBI) await
Download instantly and pick your perfect format...

Read anywhere, anytime, on any device!

Python Real World Machine Learning: Real World Machine


Learning: Take your Python Machine learning skills to the
next level 1st Edition Joshi
https://textbookfull.com/product/python-real-world-machine-learning-
real-world-machine-learning-take-your-python-machine-learning-skills-
to-the-next-level-1st-edition-joshi/
textbookfull.com

Advanced Data Analytics Using Python: With Machine


Learning, Deep Learning and NLP Examples Mukhopadhyay

https://textbookfull.com/product/advanced-data-analytics-using-python-
with-machine-learning-deep-learning-and-nlp-examples-mukhopadhyay/

textbookfull.com

Practical Machine Learning for Data Analysis Using Python


1st Edition Abdulhamit Subasi

https://textbookfull.com/product/practical-machine-learning-for-data-
analysis-using-python-1st-edition-abdulhamit-subasi/

textbookfull.com

Data Science and Machine Learning Interview Questions


Using Python Second Edition Vishwanathan Narayanan

https://textbookfull.com/product/data-science-and-machine-learning-
interview-questions-using-python-second-edition-vishwanathan-
narayanan/
textbookfull.com
Python for Probability Statistics and Machine Learning
José Unpingco

https://textbookfull.com/product/python-for-probability-statistics-
and-machine-learning-jose-unpingco/

textbookfull.com

Mastering Machine Learning with Python in Six Steps: A


Practical Implementation Guide to Predictive Data
Analytics Using Python 1st Edition Manohar Swamynathan
(Auth.)
https://textbookfull.com/product/mastering-machine-learning-with-
python-in-six-steps-a-practical-implementation-guide-to-predictive-
data-analytics-using-python-1st-edition-manohar-swamynathan-auth/
textbookfull.com

Thoughtful machine learning with Python a test driven


approach First Edition Kirk

https://textbookfull.com/product/thoughtful-machine-learning-with-
python-a-test-driven-approach-first-edition-kirk/

textbookfull.com

Machine Learning Concepts with Python and the Jupyter


Notebook Environment: Using Tensorflow 2.0 Nikita
Silaparasetty
https://textbookfull.com/product/machine-learning-concepts-with-
python-and-the-jupyter-notebook-environment-using-
tensorflow-2-0-nikita-silaparasetty/
textbookfull.com

Statistical Methods for Machine Learning: Discover How to


Transform Data into Knowledge with Python Jason Brownlee

https://textbookfull.com/product/statistical-methods-for-machine-
learning-discover-how-to-transform-data-into-knowledge-with-python-
jason-brownlee/
textbookfull.com
Python: Deeper Insights
into Machine Learning
Leverage benefits of machine learning techniques
using Python

</>

LEARNING PATH
Python: Deeper Insights into
Machine Learning

Leverage benefits of machine learning


techniques using Python

A course in three modules

BIRMINGHAM - MUMBAI
Python: Deeper Insights into Machine Learning

Copyright © 2016 Packt Publishing

All rights reserved. No part of this course may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.

Every effort has been made in the preparation of this course to ensure the accuracy
of the information presented. However, the information contained in this course
is sold without warranty, either express or implied. Neither the authors, nor Packt
Publishing, and its dealers and distributors will be held liable for any damages
caused or alleged to be caused directly or indirectly by this course.

Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this course by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.

Published on: August 2016

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham B3 2PB, UK.

ISBN 978-1-78712-857-6

www.packtpub.com
Credits

Authors Content Development Editor


Sebastian Raschka Amrita Noronha
David Julian
John Hearty Production Coordinator
Arvindkumar Gupta

Reviewers
Richard Dutton
Dave Julian
Vahid Mirjalili
Hamidreza Sattari
Dmytro Taranovsky
Dr. Vahid Mirjalili
Jared Huffman
Ashwin Pajankar
Preface
Machine learning and predictive analytics are becoming one of the key strategies for
unlocking growth in a challenging contemporary marketplace .It is one of the fastest
growing trends in modern computing and everyone wants to get into the field of
machine learning. In order to obtain sufficient recognition in this field, one must be
able to understand and design a machine learning system that serves the needs of a
project. The idea is to prepare a Learning Path that will help you to tackle the real-
world complexities of modern machine learning with innovative and cutting-edge
techniques. Also, it will give you a solid foundation in the machine learning design
process, and enable you to build customized machine learning models to solve
unique problems

What this learning path covers


Module 1, Python Machine Learning, discusses the essential machine algorithms for
classification and provides practical examples using scikit-learn. It teaches you to
prepare variables of different types and also speaks about polynomial regression
and tree-based approaches. This module focuses on open source Python library that
allows us to utilize multiple cores of modern GPUs.

Module 2, Designing Machine Learning Systems with Python, acquaints you with large
library of packages for machine learning tasks. It introduces broad topics such
as big data, data properties, data sources, and data processing .You will further
explore models that form the foundation of many advanced nonlinear techniques.
This module will help you in understanding model selection and parameter tuning
techniques that could help in various case studies.

[i]
Preface

Module 3, Advanced Machine Learning with Python, helps you to build your skill
with deep architectures by using stacked denoising autoencoders. This module is a
blend of semi-supervised learning techniques, RBM and DBN algorithms .Further
this focuses on tools and techniques which will help in making consistent working
process.

What you need for this learning path


Module 1, Python Machine Learning will require an installation of Python 3.4.3 or
newer on Mac OS X, Linux or Microsoft Windows. Use of Python essential libraries
like SciPy, NumPy, scikit-Learn, matplotlib, and pandas. is essential.

Before you start, Please refer:

• The direct link to the Iris dataset would be: https://raw.


githubusercontent.com/rasbt/python-machine-learning-book/
master/code/datasets/iris/iris.data
• We've added some additional notes to the code notebooks mentioning the
offline datasets in case there are server errors. https://www.dropbox.com/
sh/tq2qdh0oqfgsktq/AADIt7esnbiWLOQODn5q_7Dta?dl=0
• Module 2, Designing Machine Learning Systems with Python, will need an
inclination to learn machine learning and the Python V3 software, which you
can download from https://www.python.org/downloads/.
• Module 3, Advanced Machine Learning with Python, leverages openly
available data and code, including open source Python libraries and
frameworks.

Who this learning path is for


This title is for Data scientist and researchers who are already into the field of
Data Science and want to see Machine learning in action and explore its real-world
application. Prior knowledge of Python programming and mathematics is must with
basic knowledge of machine learning concepts.

Reader feedback
Feedback from our readers is always welcome. Let us know what you think about
this course—what you liked or disliked. Reader feedback is important for us as it
helps us develop titles that you will really get the most out of.

[ ii ]
Preface

To send us general feedback, simply e-mail feedback@packtpub.com, and mention


the course's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support
Now that you are the proud owner of a Packt course, we have a number of things to
help you to get the most from your purchase.

Downloading the example code


You can download the example code files for this course from your account at
http://www.packtpub.com. If you purchased this course elsewhere, you can visit
http://www.packtpub.com/support and register to have the files e-mailed directly
to you.

You can download the code files by following these steps:

1. Log in or register to our website using your e-mail address and password.
2. Hover the mouse pointer on the SUPPORT tab at the top.
3. Click on Code Downloads & Errata.
4. Enter the name of the course in the Search box.
5. Select the course for which you're looking to download the code files.
6. Choose from the drop-down menu where you purchased this course from.
7. Click on Code Download.

You can also download the code files by clicking on the Code Files button on the
course's webpage at the Packt Publishing website. This page can be accessed by
entering the course's name in the Search box. Please note that you need to be logged
in to your Packt account.

Once the file is downloaded, please make sure that you unzip or extract the folder
using the latest version of:

• WinRAR / 7-Zip for Windows


• Zipeg / iZip / UnRarX for Mac
• 7-Zip / PeaZip for Linux

[ iii ]
Preface

The code bundle for the course is also hosted on GitHub at https://github.com/
PacktPublishing/Python-Deeper-Insights-into-Machine-Learning.

Errata
Although we have taken every care to ensure the accuracy of our content, mistakes
do happen. If you find a mistake in one of our courses—maybe a mistake in the text
or the code—we would be grateful if you could report this to us. By doing so, you
can save other readers from frustration and help us improve subsequent versions
of this course. If you find any errata, please report them by visiting http://www.
packtpub.com/submit-errata, selecting your course, clicking on the Errata
Submission Form link, and entering the details of your errata. Once your errata are
verified, your submission will be accepted and the errata will be uploaded to our
website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/


content/support and enter the name of the course in the search field. The required
information will appear under the Errata section.

Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across all
media. At Packt, we take the protection of our copyright and licenses very seriously.
If you come across any illegal copies of our works in any form on the Internet, please
provide us with the location address or website name immediately so that we can
pursue a remedy.

Please contact us at copyright@packtpub.com with a link to the suspected


pirated material.

We appreciate your help in protecting our authors and our ability to bring you
valuable content.

Questions
If you have a problem with any aspect of this course, you can contact us at
questions@packtpub.com, and we will do our best to address the problem.

[ iv ]
Course Module 1: Python Machine Learning

Chapter 1: Giving Computers the Ability to Learn from Data 3


Building intelligent machines to transform data into knowledge 4
The three different types of machine learning 4
An introduction to the basic terminology and notations 10
A roadmap for building machine learning systems 12
Using Python for machine learning 15
Summary 17
Chapter 2: Training Machine Learning Algorithms
for Classification 19
Artificial neurons – a brief glimpse into the early history of
machine learning 20
Implementing a perceptron learning algorithm in Python 26
Adaptive linear neurons and the convergence of learning 35
Summary 49
Chapter 3: A Tour of Machine Learning Classifiers
Using Scikit-learn 51
Choosing a classification algorithm 51
First steps with scikit-learn 52
Modeling class probabilities via logistic regression 58
Maximum margin classification with support vector machines 71
Solving nonlinear problems using a kernel SVM 77
Decision tree learning 82

[i]
Table of Contents

K-nearest neighbors – a lazy learning algorithm 94


Summary 98
Chapter 4: Building Good Training Sets – Data Preprocessing 101
Dealing with missing data 101
Handling categorical data 106
Partitioning a dataset in training and test sets 110
Bringing features onto the same scale 112
Selecting meaningful features 114
Assessing feature importance with random forests 126
Summary 128
Chapter 5: Compressing Data via Dimensionality Reduction 129
Unsupervised dimensionality reduction via principal
component analysis 130
Supervised data compression via linear discriminant analysis 140
Using kernel principal component analysis for nonlinear mappings 150
Summary 169
Chapter 6: Learning Best Practices for Model Evaluation
and Hyperparameter Tuning 171
Streamlining workflows with pipelines 171
Using k-fold cross-validation to assess model performance 175
Debugging algorithms with learning and validation curves 181
Fine-tuning machine learning models via grid search 187
Looking at different performance evaluation metrics 191
Summary 200
Chapter 7: Combining Different Models for Ensemble Learning 201
Learning with ensembles 201
Implementing a simple majority vote classifier 205
Evaluating and tuning the ensemble classifier 215
Bagging – building an ensemble of classifiers from
bootstrap samples 221
Leveraging weak learners via adaptive boosting 226
Summary 234
Chapter 8: Applying Machine Learning to Sentiment Analysis 235
Obtaining the IMDb movie review dataset 235
Introducing the bag-of-words model 238
Training a logistic regression model for document classification 246
Working with bigger data – online algorithms and out-of-core learning 248
Summary 252

[ ii ]
Table of Contents

Chapter 9: Embedding a Machine Learning Model into a


Web Application 253
Serializing fitted scikit-learn estimators 254
Setting up a SQLite database for data storage 257
Developing a web application with Flask 259
Turning the movie classifier into a web application 266
Deploying the web application to a public server 274
Summary 278
Chapter 10: Predicting Continuous Target Variables with
Regression Analysis 279
Introducing a simple linear regression model 280
Exploring the Housing Dataset 281
Implementing an ordinary least squares linear regression model 287
Fitting a robust regression model using RANSAC 293
Evaluating the performance of linear regression models 296
Using regularized methods for regression 299
Turning a linear regression model into a curve – polynomial
regression 300
Summary 311
Chapter 11: Working with Unlabeled Data – Clustering Analysis 313
Grouping objects by similarity using k-means 314
Organizing clusters as a hierarchical tree 328
Locating regions of high density via DBSCAN 336
Summary 342
Chapter 12: Training Artificial Neural Networks for
Image Recognition 343
Modeling complex functions with artificial neural networks 344
Classifying handwritten digits 352
Training an artificial neural network 367
Developing your intuition for backpropagation 374
Debugging neural networks with gradient checking 375
Convergence in neural networks 381
Other neural network architectures 383
A few last words about neural network implementation 386
Summary 387

[ iii ]
Table of Contents

Chapter 13: Parallelizing Neural Network Training with Theano 389


Building, compiling, and running expressions with Theano 390
Choosing activation functions for feedforward neural networks 403
Training neural networks efficiently using Keras 410
Summary 416

Course Module 2: Designing Machine Learning


Systems with Python

Chapter 1: Thinking in Machine Learning 421


The human interface 422
Design principles 425
Summary 453
Chapter 2: Tools and Techniques 455
Python for machine learning 456
IPython console 456
Installing the SciPy stack 457
NumPY 458
Matplotlib 464
Pandas 468
SciPy 471
Scikit-learn 474
Summary 481
Chapter 3: Turning Data into Information 483
What is data? 484
Big data 484
Signals 500
Cleaning data 502
Visualizing data 504
Summary 507
Chapter 4: Models – Learning from Information 509
Logical models 509
Tree models 517
Rule models 521
Summary 528

[ iv ]
Table of Contents

Chapter 5: Linear Models 529


Introducing least squares 530
Logistic regression 538
Multiclass classification 544
Regularization 545
Summary 548
Chapter 6: Neural Networks 549
Getting started with neural networks 549
Logistic units 551
Cost function 556
Implementing a neural network 559
Gradient checking 565
Other neural net architectures 566
Summary 567
Chapter 7: Features – How Algorithms See the World 569
Feature types 570
Operations and statistics 571
Structured features 574
Transforming features 574
Principle component analysis 583
Summary 585
Chapter 8: Learning with Ensembles 587
Ensemble types 587
Bagging 588
Boosting 594
Ensemble strategies 601
Summary 604
Chapter 9: Design Strategies and Case Studies 605
Evaluating model performance 605
Model selection 610
Learning curves 613
Real-world case studies 615
Machine learning at a glance 626
Summary 627

[v]
Table of Contents

Course Module 3: Advanced Machine


Learning with Python

Chapter 1: Unsupervised Machine Learning 631


Principal component analysis 632
Introducing k-means clustering 637
Self-organizing maps 648
Further reading 654
Summary 655
Chapter 2: Deep Belief Networks 657
Neural networks – a primer 658
Restricted Boltzmann Machine 663
Deep belief networks 679
Further reading 685
Summary 686
Chapter 3: Stacked Denoising Autoencoders 687
Autoencoders 687
Stacked Denoising Autoencoders 696
Further reading 705
Summary 705
Chapter 4: Convolutional Neural Networks 707
Introducing the CNN 707
Further Reading 729
Summary 730
Chapter 5: Semi-Supervised Learning 731
Introduction 731
Understanding semi-supervised learning 732
Semi-supervised algorithms in action 733
Further reading 756
Summary 757
Chapter 6: Text Feature Engineering 759
Introduction 759
Text feature engineering 760
Further reading 783
Summary 784
Chapter 7: Feature Engineering Part II 785
Introduction 785
Creating a feature set 786

[ vi ]
Table of Contents

Feature engineering in practice 805


Further reading 829
Summary 830
Chapter 8: Ensemble Methods 831
Introducing ensembles 832
Using models in dynamic applications 851
Further reading 863
Summary 864
Chapter 9: Additional Python Machine Learning Tools 865
Alternative development tools 866
Further reading 875
Summary 875
Chapter 10: Chapter Code Requirements 879
Biblography 881

[ vii ]
Module 1

Python Machine Learning

Leverage benefits of machine learning techniques using Python


Giving Computers the Ability
to Learn from Data
In my opinion, machine learning, the application and science of algorithms that makes
sense of data, is the most exciting field of all the computer sciences! We are living in
an age where data comes in abundance; using the self-learning algorithms from the
field of machine learning, we can turn this data into knowledge. Thanks to the many
powerful open source libraries that have been developed in recent years, there has
probably never been a better time to break into the machine learning field and learn
how to utilize powerful algorithms to spot patterns in data and make predictions
about future events.

In this chapter, we will learn about the main concepts and different types of machine
learning. Together with a basic introduction to the relevant terminology, we will lay
the groundwork for successfully using machine learning techniques for practical
problem solving.

In this chapter, we will cover the following topics:

• The general concepts of machine learning


• The three types of learning and basic terminology
• The building blocks for successfully designing machine learning systems
• Installing and setting up Python for data analysis and machine learning

[3]
Giving Computers the Ability to Learn from Data

Building intelligent machines to


transform data into knowledge
In this age of modern technology, there is one resource that we have in abundance: a
large amount of structured and unstructured data. In the second half of the twentieth
century, machine learning evolved as a subfield of artificial intelligence that involved
the development of self-learning algorithms to gain knowledge from that data in
order to make predictions. Instead of requiring humans to manually derive rules
and build models from analyzing large amounts of data, machine learning offers a
more efficient alternative for capturing the knowledge in data to gradually improve
the performance of predictive models, and make data-driven decisions. Not only is
machine learning becoming increasingly important in computer science research but
it also plays an ever greater role in our everyday life. Thanks to machine learning,
we enjoy robust e-mail spam filters, convenient text and voice recognition software,
reliable Web search engines, challenging chess players, and, hopefully soon, safe and
efficient self-driving cars.

The three different types of


machine learning
In this section, we will take a look at the three types of machine learning: supervised
learning, unsupervised learning, and reinforcement learning. We will learn about the
fundamental differences between the three different learning types and, using
conceptual examples, we will develop an intuition for the practical problem
domains where these can be applied:

[4]
Chapter 1

Making predictions about the future with


supervised learning
The main goal in supervised learning is to learn a model from labeled training data
that allows us to make predictions about unseen or future data. Here, the term
supervised refers to a set of samples where the desired output signals (labels) are
already known.

Considering the example of e-mail spam filtering, we can train a model using a
supervised machine learning algorithm on a corpus of labeled e-mail, e-mail that are
correctly marked as spam or not-spam, to predict whether a new e-mail belongs to
either of the two categories. A supervised learning task with discrete class labels, such
as in the previous e-mail spam-filtering example, is also called a classification task.
Another subcategory of supervised learning is regression, where the outcome signal is
a continuous value:

Classification for predicting class labels


Classification is a subcategory of supervised learning where the goal is to
predict the categorical class labels of new instances based on past observations.
Those class labels are discrete, unordered values that can be understood as the
group memberships of the instances. The previously mentioned example of
e-mail-spam detection represents a typical example of a binary classification
task, where the machine learning algorithm learns a set of rules in order to
distinguish between two possible classes: spam and non-spam e-mail.

[5]
Giving Computers the Ability to Learn from Data

However, the set of class labels does not have to be of a binary nature. The predictive
model learned by a supervised learning algorithm can assign any class label that was
presented in the training dataset to a new, unlabeled instance. A typical example of
a multi-class classification task is handwritten character recognition. Here, we could
collect a training dataset that consists of multiple handwritten examples of each letter
in the alphabet. Now, if a user provides a new handwritten character via an input
device, our predictive model will be able to predict the correct letter in the alphabet
with certain accuracy. However, our machine learning system would be unable to
correctly recognize any of the digits zero to nine, for example, if they were not part
of our training dataset.

The following figure illustrates the concept of a binary classification task given 30
training samples: 15 training samples are labeled as negative class (circles) and 15
training samples are labeled as positive class (plus signs). In this scenario, our dataset
is two-dimensional, which means that each sample has two values associated with
it: x1 and x2 . Now, we can use a supervised machine learning algorithm to learn a
rule—the decision boundary represented as a black dashed line—that can separate
those two classes and classify new data into each of those two categories given its x1
and x2 values:

Regression for predicting continuous outcomes


We learned in the previous section that the task of classification is to assign
categorical, unordered labels to instances. A second type of supervised learning is
the prediction of continuous outcomes, which is also called regression analysis. In
regression analysis, we are given a number of predictor (explanatory) variables and a
continuous response variable (outcome), and we try to find a relationship between
those variables that allows us to predict an outcome.

[6]
Chapter 1

For example, let's assume that we are interested in predicting the Math SAT
scores of our students. If there is a relationship between the time spent studying
for the test and the final scores, we could use it as training data to learn a model
that uses the study time to predict the test scores of future students who are
planning to take this test.

The term regression was devised by Francis Galton in his article


Regression Towards Mediocrity in Hereditary Stature in 1886. Galton
described the biological phenomenon that the variance of height
in a population does not increase over time. He observed that
the height of parents is not passed on to their children but the
children's height is regressing towards the population mean.

The following figure illustrates the concept of linear regression. Given a predictor
variable x and a response variable y, we fit a straight line to this data that minimizes
the distance—most commonly the average squared distance—between the sample
points and the fitted line. We can now use the intercept and slope learned from this
data to predict the outcome variable of new data:

[7]
Giving Computers the Ability to Learn from Data

Solving interactive problems with


reinforcement learning
Another type of machine learning is reinforcement learning. In reinforcement
learning, the goal is to develop a system (agent) that improves its performance
based on interactions with the environment. Since the information about the current
state of the environment typically also includes a so-called reward signal, we can
think of reinforcement learning as a field related to supervised learning. However, in
reinforcement learning this feedback is not the correct ground truth label or value,
but a measure of how well the action was measured by a reward function. Through
the interaction with the environment, an agent can then use reinforcement learning
to learn a series of actions that maximizes this reward via an exploratory
trial-and-error approach or deliberative planning.

A popular example of reinforcement learning is a chess engine. Here, the agent decides
upon a series of moves depending on the state of the board (the environment), and the
reward can be defined as win or lose at the end of the game:

Discovering hidden structures with


unsupervised learning
In supervised learning, we know the right answer beforehand when we train
our model, and in reinforcement learning, we define a measure of reward for
particular actions by the agent. In unsupervised learning, however, we are dealing
with unlabeled data or data of unknown structure. Using unsupervised learning
techniques, we are able to explore the structure of our data to extract meaningful
information without the guidance of a known outcome variable or reward function.

[8]
Chapter 1

Finding subgroups with clustering


Clustering is an exploratory data analysis technique that allows us to organize a
pile of information into meaningful subgroups (clusters) without having any prior
knowledge of their group memberships. Each cluster that may arise during the
analysis defines a group of objects that share a certain degree of similarity but are
more dissimilar to objects in other clusters, which is why clustering is also sometimes
called "unsupervised classification." Clustering is a great technique for structuring
information and deriving meaningful relationships among data, For example, it
allows marketers to discover customer groups based on their interests in order to
develop distinct marketing programs.

The figure below illustrates how clustering can be applied to organizing unlabeled
data into three distinct groups based on the similarity of their features x1 and x2 :

Dimensionality reduction for data compression


Another subfield of unsupervised learning is dimensionality reduction. Often we are
working with data of high dimensionality—each observation comes with a high
number of measurements—that can present a challenge for limited storage space
and the computational performance of machine learning algorithms. Unsupervised
dimensionality reduction is a commonly used approach in feature preprocessing
to remove noise from data, which can also degrade the predictive performance of
certain algorithms, and compress the data onto a smaller dimensional subspace
while retaining most of the relevant information.

[9]
Giving Computers the Ability to Learn from Data

Sometimes, dimensionality reduction can also be useful for visualizing data—for


example, a high-dimensional feature set can be projected onto one-, two-, or
three-dimensional feature spaces in order to visualize it via 3D- or 2D-scatterplots
or histograms. The figure below shows an example where non-linear dimensionality
reduction was applied to compress a 3D Swiss Roll onto a
new 2D feature subspace:

An introduction to the basic terminology


and notations
Now that we have discussed the three broad categories of machine
learning—supervised, unsupervised, and reinforcement learning—let us have
a look at the basic terminology that we will be using in the next chapters. The
following table depicts an excerpt of the Iris dataset, which is a classic example in
the field of machine learning. The Iris dataset contains the measurements of 150 iris
flowers from three different species: Setosa, Versicolor, and Virginica. Please check if
this is replaced. Here, each flower sample represents one row in our data set, and the
flower measurements in centimeters are stored as columns, which we also call the
features of the dataset:

[ 10 ]
Chapter 1

To keep the notation and implementation simple yet efficient, we will make use of
some of the basics of linear algebra. In the following chapters, we will use a matrix
and vector notation to refer to our data. We will follow the common convention to
represent each sample as separate row in a feature matrix X , where each feature is
stored as a separate column.

The Iris dataset, consisting of 150 samples and 4 features, can then be written as a
150 × 4 matrix X ∈ 150×4 :

[ 11 ]
Giving Computers the Ability to Learn from Data

For the rest of this book, we will use the superscript (i) to refer to the ith
training sample, and the subscript j to refer to the jth dimension of the
training dataset.
We use lower-case, bold-face letters to refer to vectors ( x ∈ R ) and
n×1

upper-case, bold-face letters to refer to matrices, respectively ( X ∈  n×m ) .


To refer to single elements in a vector or matrix, we write the letters in
(n) (n)
italics ( x or x( m ) , respectively).
For example, x1150 refers to the first dimension of flower sample 150, the
sepal length. Thus, each row in this feature matrix represents one flower
(i ) 1×4
instance and can be written as four-dimensional row vector x ∈  ,
(i ) (i ) (i ) (i ) (i )
x =  x1 x2 x3 x4  .
Each feature dimension is a 150-dimensional column vector x j ∈ 150×1 ,
for example:

 x j (1) 
 ( 2) 
 x 
xj =  j 
  
 x (150) 
 j .
Similarly, we store the target variables (here: class labels) as a
 y (1) 
 
150-dimensional column vector y =  …  ( y ∈ {Setosa, Versicolor, Virginica} ) .
 y (150) 
 

A roadmap for building machine learning


systems
In the previous sections, we discussed the basic concepts of machine learning and the
three different types of learning. In this section, we will discuss other important parts
of a machine learning system accompanying the learning algorithm. The diagram
below shows a typical workflow diagram for using machine learning in predictive
modeling, which we will discuss in the following subsections:

[ 12 ]
Another Random Document on
Scribd Without Any Related Topics
CHAPTER XIX.
NED IS ASTONISHED.

He felt about, and soon made out that the chimney was made of
rough stone, with rather wide interstices between each boulder. It
was an easy matter to clamber up it, and soon Ned was on his way
toward the stars framed by the top of the structure. But when he
had reached a height of some ten feet above the cellar floor, a
strange thing happened. One of his feet struck a part of the
chimney, which gave out a hollow sound. Moreover, the sound was
that of wood.
“Guess that there must be a fireplace opening there,” thought the
Dreadnought Boy; “evidently, they had it boarded up for the
summer, or maybe the chimney was never finished. Guess that must
be it. Now, the question is, what lies beyond that board?”
As if in answer to his unspoken thought, he heard, at that moment,
a distinct groan coming from the other side of the board.
“That must be Mr. Lockyer,” was the boy’s instant thought; “wonder
how tight this board is?”
A hearty kick soon solved the question. The board flew outward into
the room with a clatter, and the next instant Ned beheld the face of
Channing Lockyer once more. The inventor was seated at a table in
a room which, apparently, contained no other furniture beside that
and the chair to which, in a close view, it became apparent he was
tightly bound. In one corner of the place a lamp, on a high shelf,
shed a sickly light.
“Mr. Lockyer!” cried the boy.
The inventor met his gaze with a half-dazed look that somehow sent
a creepy feeling through the boy. Crossing the room in a few steps
he shook the other’s shoulder.
“Mr. Lockyer? I’ve come to save you. What is it? What’s the matter?”
A hollow groan was the response, and the inventor, who had,
seemingly, been partially roused when the chimney-board fell in, let
his head sink forward on the table once more.
“By George!” exclaimed Ned, with a sudden remembrance; “I
recollect now. Those fellows did say something about having
drugged him. The stuff seems to be still working. Whatever will I
do? They’ll be back before long, and we ought to be out of here.”
Reasoning that it would be probably his best course of action to cut
the inventor loose, Ned drew his knife, of which his captors had not
bothered to deprive him, and slashed the ropes that bound Channing
Lockyer to the chair. As his bonds relaxed, the inventor slid heavily
forward and sank in a heap on the floor.
“Well, if this isn’t tough luck,” groaned Ned; “what am I to do? I
can’t carry him far, that’s certain. Guess I’ll open the door and see if
the fresh air will revive him.”
He swiftly was at the portal. But it would not yield to his tugs.
“Locked on the outside!” exclaimed Ned; “I’ll try the window.”
That, too, was locked in some way he could not discover. But Ned
was not one to be beaten by trifles like that. Picking up the chair, he
swung it against the casement, carrying away sash and all. The blast
of keen sea air that swept in seemed, to Ned’s delight, to revive Mr.
Lockyer. He stirred like a man awakening from a long sleep.
“Come, sir, come!” cried Ned, lifting him; “can’t you stand?”
“I—what has happened?” asked the inventor thickly. He stared about
him with a blank look.
“You’ve been drugged by rascals, but I’m going to get you out of
here,” rejoined Ned; “come, sir; rouse up. Ah, that’s better,” as the
inventor, with the lad’s aid, got to his feet. He stood staggeringly,
and then Ned, as gently as he could, half-dragged, half-carried him
to the window.
“Have to lift him through,” thought Ned, as Mr. Lockyer gazed
blankly about him. Evidently he had little knowledge of what was
happening.
Putting his strong, young arms about the inventor’s slight form, Ned
lifted him through the window. Then he followed.
“A fighting chance,” he breathed, as, gathering up Lockyer in his
arms, he began a staggering run across the heavy sands. Coarse
grass grew upon the island, which bothered him a good deal, but in
the emergency before him, Ned seemed endowed with superhuman
strength.
“A fighting chance,” he breathed, as,
gathering up Lockyer in his arms, he began
a staggering run across the heavy sands.
As one direction seemed as good as another, he did not pay much
heed to where he was going. Before long he reached the margin of
the island. At least, he could hear the ripple of tiny waves on the
beach.
“Good land,” breathed the lad to himself, setting down Mr. Lockyer’s
limp form, “it will be child’s play to find us now. If only there were
some way to escape from the island, but I guess there isn’t, and
we’re out of the frying pan into the fire.”
It was a bitter pill to swallow. To have come so far and surmounted
such obstacles only for this! For Ned, against all manner of reason,
perhaps, had treasured, deep down in his heart, a hope that, after
all, what he thought an island might turn out to be a part of the
mainland. He realized that there was no use dwelling in this fool’s
paradise any longer.
As he stood there under the stars, without a hope left, a sudden
sound was borne to his ears. It was as ominous an interruption to
the hush of the night as could be imagined.
The swift, sharp chug-chug of a motorboat’s exhaust.
To Ned, it meant only one thing. Ferriss and his companions were
returning. In a few minutes they would have discovered the escape
and then would scatter and search the island. In that case, their
recapture was inevitable.
“Well, Ned Strong,” said the Dreadnought Boy half-aloud, “this looks
like the beginning of a particularly lively end.”
But to Ned’s stark astonishment, the next instant a familiar sound
came over the water from the direction in which the approaching
chug-chug was manifest.
“Jer-us-o-hos-o-phat, shipmates, my advice is ter cruise back to the
submarine. Wherever them varmints has taken Ned Strong and Mr.
Lockyer, we won’t be able to find ’em. Not to-night, anyhow.”
“Which is just where you’re wrong, Tom Marlin!” hailed Ned, his
voice fairly aquiver with gladness.
“A-h-o-y!” came an amazed hail from the water. “Ned Strong, my
hearty, are you there, or is it your ghost?”
“It’s me, dear old Tom; but hurry and get alongside there. Is Herc
with you, and young Sim?”
“Here safe and sound, Ned,” shouted the well-known voice of the
red-headed lad; “thank goodness, we’ve found you.”
“And Mr. Lockyer, too,” shouted back Ned, in response to the glad
shouts that came in a perfect torrent from the other boat.
“What! How on earth——?”
“Never mind that now. Never mind anything now but getting that
boat in here as close as you can. They’ll be coming back before
long.”
Not stopping to ask who “they” might be, the boat was run close in
to the shore till not more than a foot of water was between her keel
and the bottom. Then Ned, picking up the still half-dazed inventor,
waded out to her and, presently, they were safe aboard.
“Say!” exclaimed the reporter, as Ned swiftly told his story, “let’s stay
here and give those rascals a fight.”
“I’d like to,” said Herc wistfully; “maybe we could arrest them and
land them where they belong, which is in jail.”
But Ned vetoed the proposition. For one thing, it was important to
get Mr. Lockyer back to where he could have medical attention, for
whatever kind of stuff the rascals had given him, it seemed to have
completely overcome him. He sat in the bottom of the launch with a
vacant look on his face. The little craft was, accordingly, put about
and headed for Grayport. As they chugged along Herc told how they
came to happen along at such an opportune moment for Ned.
After they had heard the auto speed off, they had given chase for a
while, but had finally desisted when they saw it was useless. Then
they began to look about for Ned, and discovered that he was gone.
For a time they were at a despairing standstill, but, after a lot of
discussion, it was agreed to head up the Inlet toward the islands, as
Reporter Hargraves recollected having heard the ruffians, who had
abducted Lockyer, mention the islands in their talk in the summer
house. They had been cruising around for some time among the
deserted summer colony of bungalows and islands, and were about
ready to give up the search when they heard Ned’s hail.
On the way back to Grayport they encountered something which
was to have played an important part in Ferriss’s plans. This was the
drifting boat in which Gradbarr had rowed Lockyer ashore. Drifting
about, bottom up as she was, they almost ran her down in the
darkness. On turning her over, they found that Anderson had carried
out his instructions to the letter, for under one of the thwarts was Mr.
Lockyer’s hat.
“Gracious!” exclaimed Herc, with a shudder, “suppose we had not
found you and had encountered this boat on our way back? We
would have given up Mr. Lockyer for lost for certain, and your fate
would have been a mystery to us.”
No time was lost in reporting on board the Lockyer, where anxiety
and apprehension were naturally at fever heat. Lieutenant Parry and
Midshipman Stark had returned some hours before, but they were
pacing the deck, on the lookout for news of some sort, when the
launch, with the returned adventurers, arrived.
Warm, indeed, were the congratulations showered upon the lads and
the reporter, who had aided them so materially. Mr. Lockyer was
placed in a bunk, and Lieutenant Parry, who had some knowledge of
medicine, administered some remedies to him. Such good effect did
they have that when a doctor came from the shore in the morning
there was not much for him to do, except to look profound and
recommend rest.
The police were communicated with, and a force of men sent to the
island on which Mr. Lockyer had been imprisoned. Evidences of a
hasty flight were found there. Evidently, Ferriss and his companions
had returned, and finding that in some mysterious way their
prisoners had escaped, had not deemed it wise to linger.
The auto had been hired, it was discovered, from a reputable garage
in the town. As for the bungalow, that had been rented by Ferriss
some days before. He had represented himself as an invalid anxious
to try the fresh-air cure, and the real estate agent who rented the
place to him had had no suspicion of the real purposes for which he
wanted it. Although a “general alarm” was sent out for all who had
taken part in the dastardly night’s work, no trace was discovered of
them in Grayport or the vicinity.
“I guess they’ve fired their last gun,” commented Ned, when this
information was brought off to the submarine that evening. But in
this the Dreadnought Boy was mistaken. Such men as Ferriss do not
accept defeat kindly. It only enrages their degraded natures and
makes them hungry for vengeance on those who they deem have
thwarted their ends.
CHAPTER XX.
TOM’S VERY THICK FOG.

From being a place which had little existence besides a name on the
map, Grayport had suddenly blossomed out into quite a celebrated
spot. Naturally, Hargraves’s story of the attack on the submarine
experimenters, and the stories of the other men concerning the
interesting tests, excited a great deal of attention. All sorts of people
began to flock to Grayport. Among them came several cranks. All
day long quite a flotilla of small boats maneuvered about the
submarine as she lay at anchor, but nobody was allowed aboard.
Even the newspaper correspondents, after they had been given that
first story, were barred.
For two days following the adventures of the night of Mr. Lockyer’s
abduction, the Lockyer lay idle at her moorings. But within her steel
shell, things were anything but idle. Incessant work was going
forward on the engines, getting them to the highest possible state of
efficiency. The reason for this was, at present, a mystery to the
boys, but it lay in the fact that Lieutenant Parry’s report had been so
favorable that the Government had decided to send a special board
to Grayport to investigate the little diving vessel.
So it came about, that on the morning of the third day, when Mr.
Lockyer was completely recovered, and his usual active, nervous self
once more, a trim-looking gunboat steamed into Grayport harbor,
and cast anchor not far from the little vessel. Lieutenant Parry,
calling his crew together, then made an announcement which thrilled
them all. That evening, in all probability, they would start on a long
trial spin with the members of the board as passengers. He
impressed them all that he wished the Lockyer to be put through her
best paces. Mr. Lockyer thanked him with a look for his words. So
far, the submarine had done all that she should, but the crucial test,
under keen, impartial eyes, remained.
Shortly afterward, Lieutenant Parry, in a shore boat, left the Lockyer
for the gunboat—the Louisville. He was on his way to pay his
respects to Captain McGill, the president of the testing board, and
his brother officers. When he returned on board again before noon,
it was with the five officers comprising the party of investigation. All
wore their uniforms and made an imposing array.
The Lockyer, too, with the naval members of her crew in blue
uniform, was decked out like a fighting ship. From her stern fluttered
the Stars and Stripes. From her forward mooring-bits, to the last bolt
on her keelson plate, she had been scoured and polished.
“A smart-looking little craft,” commented Captain McGill, after he had
been introduced to Mr. Lockyer. The inventor colored with pleasure.
“I hope to prove to you, sir, that she is as smart as she looks,” he
rejoined.
The officers now took possession of the cabin, and the boys and the
remainder of the crew were banished to the engineers’ quarters.
They were rather cramped, and Ned was not sorry when it came to
the turn of himself and Herc to take watch on deck.
They were kept busy enough up there, answering questions and
fending off too-inquisitive boats, whose occupants were eager to
come on board. After an inspection of the vessel, the naval party
went ashore in the gunboat’s launch to send some despatches to
Washington. This done, they embarked once more to take council
with Captain McGill on board the Louisville.
This afforded the men left on board more freedom, and they took
turns at coming on deck for a bit of fresh air. Toward the middle of
the afternoon—to the boys’ consternation—a heavy fog came rolling
in. It began to look as if the distance cruise that night might have to
be abandoned. Old Tom gazed at the wreaths of vapor as they came
drifting in from the Sound, wrapping the waters about the Lockyer in
a white obscurity.
“If this don’t lift by sundown it’s good for all night,” he remarked.
“Say,” he went on suddenly, “did I ever tell you lads about the time I
was in a fog in the English Channel on board the old wind-jammer
Wampus?”
The boys shook their heads.
“Well, here goes for the yarn, then,” said old Tom. “The Wampus
was one of them bluff-bowed old craft that they used to build by the
mile, and sell by the foot. I was on board her on a voyage from
Brest to Boston. All went well till we got in the English Channel,
when a thick, pea-soup-kind of a fog shut down on us. It was so bad
that you couldn’t see the forecastle from the stern.
“It was my trick at the wheel that afternoon, and for company I had
the skipper, an old Maine Yankee. He was so plum nervous that all
he could do was to pace up and down and cuss the fog. The English
Channel is crowded with shipping, and every now and then——
“M-o-o-o-o-o-m! would go some fog horn off in the smother.
“All to once, we both give a jump. Right dead ahead of us we heard
a fog horn start up.
“M-o-o-o-o-o-o-o-o-m!
“I tell you, it gave me the shivers to hear it. ‘Hard over!’ bawls the
skipper, and I spun that wheel round like a squirrel, I tell you. Well,
her head swung off, but it didn’t seem to be no good.
“M-o-o-o-o-o-o-m! come that sound again, and it seemed ter be jest
ther same place as it was before.
“‘Confound them, are they tagging us?’ shouts Captain Wellfleet.
“‘Looks like it, sir,’ says I, swinging her over and going off on the
other tack. But no sooner was we headed the other way than I’m
blessed if that same old horn didn’t start up again.
“M-o-o-o-o-m!
“‘It’s the Flying Dutchman!’ declares the skipper, who was one of the
old-school, hard-shell sailormen, and believed in Adamaster and all
them things. By that time, although I didn’t take much stock in such
yarns as that, I began to think there was something out of the
ordinary in the wind. Well, sir, for half an hour or more we swung to
and fro, and always we’d have that same old ‘M-o-o-o-o-o-m!’ dead
ahead of us.
“And so it kept up till it came time to change watches. The fog was
just as thick as ever, and we didn’t see my relief coming from for’ard
till he reached the waist. By this time the skipper was jumping about
from one foot to the other, pretty nearly daffy. And still, every now
and then, we’d hear that ‘M-o-o-o-o-m!’ right off our bow. It was
fairly uncanny, I’m telling you, the way it chased us.
“‘Send the cook aft, and tell him to make me a cup of tea,’ roars the
skipper, as my relief comes up. ‘My nerves is knocked plum galley-
west.’
“‘Sorry, sir,’ says the man; ‘the cook is doctoring the cow.’
“‘Doctoring the cow?’ bellows the skipper.
“‘Aye, aye, sir,’ says my mate; ‘she’s ate suthin’ that disagreed with
her an’ she’s got a tummy-ache. Hark!’
“He held up his finger, and we hears that fog horn noise again.
“‘M-o-o-o-o-o-m!’
“‘Is that the horn-swoggled cow?’ roars the skipper, fair beside
himself.
“‘Aye, aye, sir!’ says my mate, touching his cap; ‘she’s bin’ bellering
that way fer an hour or more.’
“‘Great shades of Neptune!’ yells the skipper, ‘and we’ve bin tagging
all over the Channel, trying ter git away from the beller of our own
cow.’
“And that,” concluded old Tom solemnly, “was the worst fog I was
ever in, boys. They do say, too, that bovine made fine corned beef,
and they used the tin cow—condensed milk—for the rest of that ’ere
voyage.”
“Say, Tom, do you expect us to believe that?” asked Herc, with a
wink at Ned, after their laughter had subsided.
“Of course,” said the old man-o’-warsman indignantly. “If there’s any
insulting doubt in your mind I’ll tell you the year and date of the
month.”
“Ahoy, Lockyer!” came a hail through the fog at this moment.
“Ahoy!” hailed Ned, “what boat’s that?”
“Lockyer!” came the answer.
Ned knew at once from this, though the fog hid the boat, that it was
Lieutenant Parry and his party returning.
As commander pro tem of the submarine, Lieutenant Parry had
answered to Ned’s hail by giving the boat’s name. This—under Navy
usage—signified that he was the captain. Other commissioned
officers would have hailed: “Aye, aye.” Enlisted men would have
replied: “Halloo!”
The short flight of steel steps, which did duty as an officer’s
gangway, was hastily lowered from the starboard side of the
submarine, and the party received on board in Navy style.
“Doesn’t look much like a cruise to-night, Lockyer, I’m afraid.” Ned,
standing at attention by the gangway, heard Lieutenant Parry remark
this to the inventor as they went below.
But good fortune was to favor the submarine after all. At sundown a
brisk breeze sprung up, before which the fog rapidly melted away.
By dusk the skies were clear, and outside the harbor a sharp wind
was kicking up white-caps in dancing water-rows. It was ideal
weather for cruising, and when, after supper, the order came to up
anchor, the command was obeyed with alacrity.
But smart as the Lockyer had been in hastening to make ready for
her start after the fog had lifted, another boat in the harbor was
ahead of her in getting to sea. This was a largish catboat, which had
come in that morning. Some time before the order came to “up
anchor” on their own craft, the crew of the Lockyer had watched the
catboat, on which were two men, slip from her moorings and,
heeling gracefully before the breeze, run out of the harbor. Soon she
was skipping across the Sound, bobbing about like a dancer in a
quadrille. The dying light glowed goldenly on her big, single sail.
“Those fellows are off for a night’s cruise, too,” commented Herc, as
he watched the white canvas glimmering more and more dimly in
the gathering dusk.
“Guess they’re reaching off for a run to Bridgeport,” rejoined Ned.
But in this surmise he came far—very far—from guessing the real
object of the catboat’s cruise.
CHAPTER XXI.
THE SHIPWRECKED MEN—AND A BOX.

It was an exhilarating experience—this of racing through the wind-


torn water. As Ned and Herc, who had been posted on deck-watch,
for so long as the submarine cruised on the surface, stood in the lee
of the conning-tower, muffled up in their warm reefers, they fairly
chuckled with delight. Urged forward by her three propellers, the
submarine’s form slipped through the tumble of waters like a swift,
gliding thing endowed with life.
“Wonder when we are going to dive?” said Ned, as on and on,
through the dark, raced the little craft, her rounded steel sides
gleaming wet with flung spray.
“Hope they don’t forget us when they make up their minds to go
under,” said Herc, with a grin; “it’s pretty dusty on the water to-
night.”
“No danger of our being forgotten,” rejoined Ned, with a laugh.
“Wow, but they are speeding her up. I suppose they want to show
that official outfit of big bugs what she can do.”
This was the case. In the conning-tower, crowded closely together in
that narrow space, were the naval officers. Their faces fairly shone
as the Lockyer plunged through the heaving water-rows.
“This craft beats anything we have in the service up to date!”
exclaimed Commander McGill enthusiastically.
“And I think you’ll find she is as capable under the water as she is on
the surface,” put in Mr. Lockyer, his first apprehensive nervousness
now gone. His boat was behaving magnificently. He felt that he
could ask no more of any bit of machinery.
“Shall we prepare for a dive, sir?” inquired Lieutenant Parry.
“Not now, Parry,” rejoined the Navy captain, glancing at his watch. “I
want to keep this up for at least an hour. It is a severe test——”
“But she’ll stand it. You’ll see,” interrupted Mr. Lockyer eagerly.
On and on rushed the Lockyer, her decks gleaming wetly as her bow
threw back clouds of spray. The boys on deck were wet through, but
in the exhilaration of the moment they did not feel it. This sensation
of hissing through the water, fairly in the midst of the rolling waves,
was a blood-stirring one.
Suddenly, Ned seized Herc’s arm, and pointed out ahead.
“Look—look there, Herc!” he exclaimed.
The other, following the direction of his comrade’s arm, instantly
perceived, not more than half a mile off, the lights of a boat of some
kind.
“They’re coming straight for us,” cried Herc; “what do they want to
do? Run us down?”
“No danger of that,” laughed Ned; “our sailing lights are on. I guess
they’re holding that tack till it’s time to go about. She’s a sailing craft
of some sort. I can see the black outline of her sail.”
For a few moments more they watched, and then Herc gave a cry.
“It’s that catboat.”
“What? The one we saw leave Grayport to-night?”
“That’s right.”
“Stay here a minute, Herc,” exclaimed Ned; “I’m going forward to
see if our sailing lights are all right.”
The catboat was only a few hundred feet from them now, and still
she had not altered her course. Ned slipped forward, through the
water that swirled about on the decks as high as his knees. The side
lights, elevated on iron frames, were found to be burning brightly
and undimmed. His supposition that they had gone out and that the
catboat had not sighted them was, therefore, untenable.
Hastening back, Ned placed his lips to a speaking-tube at the side of
the tower and shouted in to the helmsman:
“Catboat off the starboard bow, sir, and making dead for us.”
“Aye, aye,” came back the hail from Midshipman Stark, who had the
wheel. “We see her. Can you make out if she’s going about?”
Ned placed his hands to his mouth funnel-wise and hailed the
oncoming craft.
“Catboat ahoy!”
Then down the wind there came a flung reply:
“Aye, aye. Keep on your course. We’ll tack directly.”
“They’d better hurry up, then,” thought Ned; “if they don’t they’ll be
into us before you can say ‘knife.’”
For a brief, nerve-tingling space of time they kept their eyes glued
on the little craft. So near was she now that they could almost have
thrown any object from the submarine’s deck upon hers.
“See, they’re going to tack!” cried Herc; “they’re drawing the sheet
tight and——They’re over!”
“Good heavens!” burst from Ned, as the sailing craft seemed to leap
up into the wind for an instant, and then, without the slightest
warning, capsized on her side.
Instantly the top of the conning-tower was thrown open by those
inside who had witnessed the accident at the same moment.
Life-belts were hastily thrown out, and Ned, giving a strong heave,
hurled one in the direction of the capsized catboat. Herc did the
same. Both buoys were of the Navy type, carrying a small receptacle
of chemical substances.
The chemicals, when they struck the water, ignited and burst into a
steady blue flame. They illuminated the water with a ghastly
radiance. In the weird glare those on the submarine could see two
black objects struggling in the water alongside the catboat. The next
instant the castaways were perceived to crawl out of the water and
climb painfully up on to the keel of the capsized boat. They clung
there, shouting, while Midshipman Stark maneuvered the Lockyer
alongside.
Save for a few sharp words of command, none of the Navy party
had shown the least trace of excitement. Trained to accept any
emergency with stiff upper lips, Uncle Sam’s sailors, be they officers
or men, don’t waste words. But what they lack in hysterics, they
make up in action. In less time than it takes to tell it, the submarine
was alongside the capsized boat, and Ned and Herc were reaching
out their arms to the two men on her keel. One of them, they
noticed, clutched a box tightly in his arms.
“Jump,” urged Ned; “we’ll catch you.”
The man with the box made a leap and slipped flounderingly on the
wet steel plates of the diving vessel’s side. He almost dropped his
burden, but recovered it instantly. The other, however, seemed in no
hurry. He was apparently fumbling with something at his waist.
“Hanged if he hasn’t got on a life-belt,” exclaimed Herc, as the first
of the survivors was hurried below.
“That’s right,” exclaimed Ned; “when, on earth, did he have time to
put one on?”
In fact, it did seem impossible, so suddenly had the catboat
capsized, that her occupants would have had time to strap on the
safety devices. Did they then know that she was going to capsize
before she went over?
But Ned had not time to revolve the puzzling question in his mind.
The remaining man now made a clumsy jump, and almost missed
the submarine, but strong arms caught him, and he was hauled on
board. As he was dragged over the rail, however, something fell from
his pocket which struck the steel deck with a metallic ring. It went
bounding off, and vanished with a splash.
“A revolver!” gasped Ned; “now, what does a man, out for a sail in a
catboat, want with a revolver?”
Both the rescued men were hurried below, and as Lieutenant Parry,
who had emerged on deck, had noted by this time the drenched
condition of Ned and Herc, he ordered them also below to change
their uniforms and put on dry clothing. They entered one of the
small staterooms to do so. As it happened, it was one adjoining the
room into which the two rescued men had been ushered by the
submarine’s officers for the same purpose.
Although the staterooms appeared to be separated by thick, steel
bulkheads, as a matter of fact these partitions were not so solid as
they appeared. At the top of each was a lattice-work strip, through
which air could circulate while the submarine was under the water.
Evidently, the rescued men were not aware of this, for they took no
care to sink their voices as they talked, and their conversation was
not of a kind, so the boys judged, anyway, that they would have
wished to blurt out from the housetops.
As the voices came floating through the lattice-work at the top of
the bulkheads, Ned gripped Herc’s arm to enjoin absolute silence. He
did not, of course, wish to betray, by the slightest sound, the fact
that they were there.
“Well, Ignacio,” came one voice, “the first part of our task is
accomplished. It was easier than I thought it would have been. For a
moment I almost lost the box. A good thing they didn’t try to
examine it.”
“That is right, Guiseppi,” was the reply; “these fools on the
submarine fell into the trap very neatly. However, the hardest part of
our duty lies still before us.”
“Yes, but the reward makes it well worth the risk. If we are detected
it will be easy to say that we were ignorant and wished to examine
the machinery. They will never suspect. These Americans have the
heads of wood and the senses of stone.”
The other laughed aloud, which brought an angry caution from his
friend.
“Not so loud,” he enjoined; “it would not sound natural for
shipwrecked men to be laughing. Play your part well, Ignacio. We
must assume the sorrowful faces of men who have met with a
serious accident.”
“Do not fear for me, my friend. I can assume the doleful pose to
perfection,” rejoined the other. “Come, you have your dry clothes
on?”
“Yes. I am already invested in my American uniform,” rejoined the
other, with a chuckle. “If they knew what we were on board for do
you think they would treat us with such hospitality?”
“I think they would show us the hospitality of throwing us
overboard, my dear Guiseppi,” chuckled Ignacio.
The listening boys heard the door open and close, and the next
instant, out in the cabin, they could hear the two castaways giving a
woeful narration of their disaster to Lieutenant Parry.
“Signor Captain,” one was saying, “the tiller jammed so hard that
before the poor boat could come about—poof!—the wind had blown
her over and, behold, if it had not been for your extreme kindness,
we would have been drowned.”
“And, in my opinion, that would have been a fitting fate for the
rascals,” muttered Ned, viciously poking his head into a dry shirt as
he spoke.
“Then you have made up your mind that it was all a trick?” asked
Herc. “A plan hatched up to get a chance to board the Lockyer?”
“Isn’t that evident from the way they were talking?” inquired Ned. “I
mean to lose no time in communicating with Lieutenant Parry; those
fellows will bear watching.”
“It looks to me as if it is all part of the scheme to discredit the
Lockyer boats with the Government,” said Herc.
“That’s the way it strikes me, too. Are you through changing? Yes—
so am I. Come on, we’ll get Lieutenant Parry aside and tell him
about it.”
When they emerged into the cabin once more the two rescued men
were seated on a divan, talking to the naval officer. Ned noticed that
they were both dark, foreign-looking fellows, one of whom had a
particularly sinister face, the evil expression of which was not
relieved by a livid scar running down one side of his countenance,
from his temple to his chin.
Both looked the very picture of dejection. Just as miserable and
forlorn-appearing as two men might have been expected to be who
had just lost a valuable boat. The better to act their part, they were
speaking about demanding damages as the boys came up. Nor had
they forgotten to express a proper amount of surprise at finding
themselves on board a submarine craft.
But, as our readers will suppose, their plight created no sympathy in
the hearts of Ned and Herc. In fact, it was all the red-headed lad
could do—he admitted afterward—to restrain himself from jumping
on the scarred man and giving him a sound thrashing.
“Can we speak to you a moment, sir?” asked Ned, saluting as they
came up.
“Certainly, Strong,” said the officer, facing around and looking rather
surprised; “what is it?”
“Something to do with the machinery, sir. Can you step this way a
minute?”
Seeing by the look in Ned’s eyes that he had something of
importance to communicate, the officer followed the boys across the
cabin and through the bulkhead door separating it from the engine
room.
“Now, Strong, what is it?” he asked as Ned carefully closed the door
behind them and led the way to a leather-covered divan, on which
the engineer was wont to sit in the intervals of his duty. Just now,
however, both he and his crew were busy about the engines, and
paid little attention to the intruders in their realm.
“It’s about those two men, sir.”
“Those two poor Italians, you mean?”
“Poor Italians, nothing—that is, I beg your pardon, sir,” burst out
Herc; “but if we are not mistaken, they are two precious rascals who
have the destruction or injury of the submarine in their black hearts.”
“What!” exclaimed the amazed officer; “explain yourself at once,
Taylor.”
But it was Ned who told the story. The red-headed Herc was too
explosive with indignation to relate it coherently. The officer listened
attentively, but in silence. When Ned had quite finished he spoke:
“You have been of inestimable service to-night, boys,” he said;
“there is no doubt in my mind, from what you have told me, that
those ruffians have some scheme in mind. But what can it be? They
cannot hope to harm the engines or any of the machinery, for it is all
closely guarded while we are cruising.”
“It occurred to me, sir,” said Ned soberly, “that it might be a good
idea to get hold of and examine that box they brought on board. It
didn’t look just natural, sir, for a man, whose boat has capsized, to
have presence of mind enough to still retain possession of a box in
the way those fellows did.”
“That’s right, my boy,” responded the officer; “but the question is,
how are we going to get a chance to examine it? We cannot seize
these men by force on the mere suspicion that they are ruffians—
although I think that fact is pretty well established. Then, too, any
sort of disturbance on board on this critical night would interfere
with the tests and, perhaps, ruin our friend Lockyer’s chances to
dispose of his boats.”
“That is so,” agreed Ned soberly; “but, sir, I’ve been thinking of a
plan by which we can get access to the box. Taylor and I have the
graveyard watch at eight bells (midnight). You will be in charge of
the vessel at that hour. Now, if I give an alarm that the boat is
sinking, we can get those fellows out of their cabin, and while they
are outside, Taylor and I can slip in and examine that box.”
“A splendid idea, Strong; but how are we to avoid waking the
others?”
“We will only pound on their door, sir. They will naturally imagine
that the others have also been called.”
“Strong, it seems to me that your plan is a perfect one. In case there
is nothing in the box we can say that it was a false alarm that
roused us out.”
“And in case there is?” asked Ned solemnly.
“The United States Navy has a way of dealing with such men,” was
the grim reply.
“Oh, Mr. Parry!” came a hail from the conning-tower at this moment.
“Yes, sir,” rejoined the officer, springing to the foot of the steel
ladder, as he recognized Captain McGill’s voice.
“The hour on the surface is up. Will you have the necessary orders
given for submersion?”
“Aye, aye, sir!” came the brisk response.
Instantly sharp commands rang out through the submarine. There
was a clamor of metal and a hissing of intake valves as the salt
water rushed into the submersion tanks. In the engine room, speed
was reduced almost to the neutral point as the diving vessel sank.
As her floors slanted and the downward, forward rush began, the
dial hand on the wall of the cabin began to move.
Ten—twelve—twenty—forty—fifty—sixty, seventy—one hundred
fathoms, and still it crawled round the gauge.
“We are going lower than we ever have before,” exclaimed Ned to
Herc, as the two met and passed in the cabin on their way to their
different stations.
“Gosh!” laughed Herc; “I hope we come up again.”
The two men on the divan exchanged a significant look.
“You’ll come up again,” muttered the one called Guiseppi, “but the
days of the Lockyer are numbered, so make the most of her while
she lasts.”
CHAPTER XXII.
AN INFERNAL MACHINE.

“What depth, Mr. Stark?”


Captain McGill, standing by the side of the young middy, asked the
question. They were still running under water, but the air, which had
just been changed, was as fresh as if they were on the surface. A
heavy vibration was noticeable though as the powerful engines
forced the cigar-shaped craft through the tremendous pressure of
the lower waters.
“Hundred fathoms, sir,” was the rejoinder. The naval officer glanced
at his watch. Then his eyes fell on the distance recorder.
“We’ve run forty miles at that depth,” he said, “but keep her
submerged. This was to be a thorough test.”
“She’s having it, sir,” ventured the midshipman; “we must be out of
the Sound and under the Atlantic by this time.”
“Well, we left Block Island some miles to our stern quite a little while
ago,” was the reply. “It’s a queer thing to think that there may be
some big liner’s keel right above us at this moment.”
“It is, indeed, sir,” agreed Mr. Stark. Just then, Mr. Lockyer and
Lieutenant Parry, with other members of the testing party who had
been below examining the engines, entered the conning-tower. They
reported everything as working to the pitch of satisfaction.
“Well, Mr. Lockyer, I congratulate you, sir,” said Captain McGill
ponderously. “I think that your craft will prove a magnificent success.
There is only one thing now to test her at, and that is to ascertain
how she stands the vibrations set up by torpedo firing.”
“If we could run across a derelict——,” began Midshipman Stark.
“Good gracious, young man, I hope we do no such thing,” laughingly
exclaimed Captain McGill; “at this depth, and at ten miles an hour,
we would never reach the surface to tell the tale. However, that does
not prevent me from admitting that I’m exceedingly sleepy.
Gentlemen, it is almost eight bells. Suppose we turn in for a nap. We
can be called if anything occurs.”
“This traveling under water seems to affect one’s wakefulness,”
yawned one of the board. “I think your suggestion is an excellent
one, captain.”
Soon afterward, leaving orders to be summoned at once if anything
out of the way occurred, the officers composing the board retired to
their staterooms. Quarters were close on the Lockyer, but room had
been found for all. The two apparent castaways had gone to their
stateroom some time before.
“Ding-ding! Ding-ding! Ding-ding! Ding-ding!”
The ship’s bell clock sounded out eight bells. Ned and Herc, on
watch in the conning-tower, exchanged significant glances.
Midshipman Stark was at the wheel, but knowing nothing of the
plans on foot, the chiming of the hour meant nothing to him, but
that the night was slipping by extremely slowly.
As the last strokes of the bell died away, a hail of “all’s well” came
from the engine room.
It was echoed from the conning-tower, where the boys stood with
beating hearts. The hour that was to witness their ruse had struck.
Presently Lieutenant Parry’s foot sounded on the rounds of the steel
ladder.
“Strong and Taylor, come below,” he ordered, in a sharp voice. His
tones were low, however.
Both boys instantly obeyed. Their hearts beat a little faster than
usual as they descended into the cabin. They were about to attempt
a somewhat risky bit of business. Both the supposed plotters were
desperate-looking men, and the conversation the lads had overheard
did not lead them to suppose that the additions to the Lockyer’s
company were any less bad than they looked.
“Now, I’ll go to the door,” said the officer, as the two young blue-
jackets faced him, “and give the alarm. Then you leave the rest to
me, but the instant the cabin is empty, you dive in there and
examine the box.”
The boys nodded.
“Aye, aye, sir!” they said, as if they had received a routine order of
some sort.
The officer crossed the cabin floor in a couple of strides. Going to
the door of the two Italians, he turned the handle. It was unlocked.
Fortune favored him then. He could arouse them without awakening
anyone else. But as he opened the door a strange thing happened.
One of the men sprang suddenly upright and, for an instant, seemed
to be about to spring at the officer’s throat. The next instant he
subsided with a low laugh.
“Pardon, sir; I——.”
“Yes, yes, I know,” burst out Lieutenant Parry, in an excited voice,
which was excellently assumed; “never mind that now. Get up!
Quick! The submarine is in peril!”
“In peril! Santa Maria!”
The fellow sprang from his bunk. It could then be seen that he was
fully dressed. His companion, also, must have been feigning sleep,
for he, too, was up in an instant. He, likewise, was fully dressed.
“Oh, sir, we are in danger?” he gasped.
“The greatest. Come quick!”
Lieutenant Parry seized both the men in an iron grasp and rushed
them out of the cabin. He was afraid if they lingered they might stop
to pick up the box.
“This way! This way! Quick! Pray heaven we are not too late!” he
cried, as he hustled them through the engine-room door, closing it
behind them with a loud clang.
“Now!” exclaimed Ned, “we’ve not a minute to lose.”
Followed by Herc, he darted forward like a hound that has just
picked up a hot scent.
Another instant and they were in the cabin lately occupied by the
two Italians. Ned thrust an arm under the lower bunk. As he had
expected, the box was there—a stout, black receptacle, bound at the
corners with brass.
It had a lock on, but drawing his marlin-spike knife, Ned had it burst
open in an instant. As he broke the lock there was a loud snap and a
queer sound like the ticking of a loud clock was heard.
Tick-tock! Tick-tock!
Ned threw back the lid, and as the contents of the box lay before
him, he gave a gasp. At first sight the interior of the thing looked not
unlike the works of a clock. It was this machinery that was ticking.
In one corner was a tiny hammer, raised above what seemed to be a
percussion cap. Below this cap was a thick, gelatinous-looking stuff.
As he saw this latter, Ned gave a cry, and thrusting his hand into the
box, tore the machinery out of it and hurled it clean across the
cabin.
“An infernal machine!” he gasped.
“What!” almost screamed Herc.
“Don’t you see,” shouted Ned excitedly; “this yellow stuff is nitro-
glycerine. Enough to blow this boat to pieces. That clockwork, when
set going, would, in due time, bring the hammer down on the
percussion cap, touching off the diabolical affair, and——”
Before he could utter another word something sprang on him,
encircling his neck, ape-like, with long arms. Ned saw a bright thing
flash above him. Instinctively, he knew that it was a knife. Swiftly he
threw up one arm and caught the descending blade in the nick of
time. At the same instant, a scream of baffled rage rang out, as
strong arms seized Guiseppi, who had sprung upon him, and
dragged him off the Dreadnought Boy’s back.
In the doorway of the engine room Ignacio struggled, foaming and
blaspheming, in Engineer Bowler’s grip, but the husky ex-foreman
held him fast.
“Don’t squirm too lively, you bloomin’ dago,” he muttered, “or I
might get nervous and tap you on the head with a wrench.”
Held tightly by Lieutenant Parry and two members of the engine-
room crew, Guiseppi, who had made the murderous attempt on Ned,
writhed and flung himself about with equal vehemence.
“I had hardly gotten them into the engine room,” explained the
young officer, giving the recalcitrant Guiseppi’s arm a twist, “before
they discovered it was all a trick. I suppose they knew, in a flash,
the object of it, for before I could stop him, this ruffian here had
darted through the door and sprang upon your back.”
“You were just in time, sir,” said Ned; “I could hear that knife whistle
as he plunged it down. He fairly had me in chancery, too.”
“I fancy you were just in time, too, Ned,” said the young officer
warmly.
He shuddered as he spoke. But now stateroom doors began to fly
open, and heads were poked out. Presently, the entire naval board
was hearing the story, while Midshipman Stark, at the wheel,
strained his ears to hear what he could of it. For he had heard the
disturbance, but, of course, could not leave his post. It was his duty
to stick at the wheel, even if he had known that the submarine was
about to be blown up.
“It seems to me,” said Captain McGill, when he had heard Lieutenant
Parry’s story, “that these two lads are entitled to a great deal of
credit for the part they played in this affair. They not only acted
bravely, but with discretion, which is better than mere courage. You,
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!

textbookfull.com

You might also like