100% found this document useful (3 votes)
21 views

(Ebook) Beginning Anomaly Detection Using Python-Based Deep Learning: Implement Anomaly Detection Applications with Keras and PyTorch by Suman Kalyan Adari and Sridhar Alla ISBN 9798868800078, 8868800071instant download

The document is an overview of the ebook 'Beginning Anomaly Detection Using Python-Based Deep Learning' by Suman Kalyan Adari and Sridhar Alla, which covers the implementation of anomaly detection applications using Keras and PyTorch. It includes various chapters on topics such as data science, machine learning, deep learning, and specific algorithms for anomaly detection. The ebook is available in multiple editions and formats, and it provides practical insights and examples for readers interested in the field.

Uploaded by

hurychpilro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
21 views

(Ebook) Beginning Anomaly Detection Using Python-Based Deep Learning: Implement Anomaly Detection Applications with Keras and PyTorch by Suman Kalyan Adari and Sridhar Alla ISBN 9798868800078, 8868800071instant download

The document is an overview of the ebook 'Beginning Anomaly Detection Using Python-Based Deep Learning' by Suman Kalyan Adari and Sridhar Alla, which covers the implementation of anomaly detection applications using Keras and PyTorch. It includes various chapters on topics such as data science, machine learning, deep learning, and specific algorithms for anomaly detection. The ebook is available in multiple editions and formats, and it provides practical insights and examples for readers interested in the field.

Uploaded by

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

(Ebook) Beginning Anomaly Detection Using

Python-Based Deep Learning: Implement Anomaly


Detection Applications with Keras and PyTorch by
Suman Kalyan Adari and Sridhar Alla ISBN
9798868800078, 8868800071 download
https://ebooknice.com/product/beginning-anomaly-detection-using-
python-based-deep-learning-implement-anomaly-detection-
applications-with-keras-and-pytorch-58356254

Explore and download more ebooks at ebooknice.com


We have selected some products that you may be interested in
Click the link to download now or visit ebooknice.com
for more options!.

(Ebook) Beginning Anomaly Detection Using Python-Based Deep


Learning, 2nd Edition by Suman Kalyan Adari , Sridhar Alla ISBN
9798868800078, 8868800071

https://ebooknice.com/product/beginning-anomaly-detection-using-python-
based-deep-learning-2nd-edition-54693456

(Ebook) Beginning Anomaly Detection Using Python-Based Deep


Learning: With Keras and PyTorch by Sridhar Alla, Suman Kalyan
Adari ISBN 9781484251768, 9781484251775, 1484251768, 1484251776

https://ebooknice.com/product/beginning-anomaly-detection-using-python-
based-deep-learning-with-keras-and-pytorch-10795944

(Ebook) Beginning Anomaly Detection Using Python-Based Deep


Learning by Suman Kalyan Adari and Sridhar Alla

https://ebooknice.com/product/beginning-anomaly-detection-using-python-
based-deep-learning-54818762

(Ebook) Beginning MLOps with MLFlow : Deploy Models in AWS


SageMaker, Google Cloud, and Microsoft Azure by Sridhar Alla;
Suman Kalyan Adari ISBN 9781484265499, 1484265491

https://ebooknice.com/product/beginning-mlops-with-mlflow-deploy-models-in-
aws-sagemaker-google-cloud-and-microsoft-azure-21976300
(Ebook) Beginning MLOps with MLFlow: Deploy Models in AWS
SageMaker, Google Cloud, and Microsoft Azure by Sridhar Alla,
Suman Kalyan Adari ISBN 9781484265482, 9781484265499,
1484265483, 1484265491
https://ebooknice.com/product/beginning-mlops-with-mlflow-deploy-models-in-
aws-sagemaker-google-cloud-and-microsoft-azure-22417650

(Ebook) Finding Ghosts in Your Data: Anomaly Detection


Techniques with Examples in Python by Kevin Feasel ISBN
9781484288696, 1484288696

https://ebooknice.com/product/finding-ghosts-in-your-data-anomaly-
detection-techniques-with-examples-in-python-47213874

(Ebook) Finding Ghosts in Your Data: Anomaly Detection


Techniques with Examples in Python by Kevin Feasel ISBN
9781484288702, 148428870X

https://ebooknice.com/product/finding-ghosts-in-your-data-anomaly-
detection-techniques-with-examples-in-python-47435122

(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

(Ebook) Control Charts and Machine Learning for Anomaly


Detection in Manufacturing by Kim Phuc Tran ISBN 9783030838188,
3030838188

https://ebooknice.com/product/control-charts-and-machine-learning-for-
anomaly-detection-in-manufacturing-34603960
Beginning Anomaly
Detection Using
Python-Based Deep
Learning
Implement Anomaly Detection
Applications with Keras and PyTorch
Second Edition

Suman Kalyan Adari


Sridhar Alla
Beginning Anomaly Detection Using Python-Based Deep Learning: Implement
Anomaly Detection Applications with Keras and PyTorch, Second Edition
Suman Kalyan Adari Sridhar Alla
Tampa, FL, USA Delran, NJ, USA

ISBN-13 (pbk): 979-8-8688-0007-8 ISBN-13 (electronic): 979-8-8688-0008-5


https://doi.org/10.1007/979-8-8688-0008-5

Copyright © 2024 by Suman Kalyan Adari, Sridhar Alla


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Celestin Suresh John
Development Editor: James Markham
Coordinating Editor: Gryffin Winkler
Cover designed by eStudioCalamar
Cover image by Tony [email protected]
Distributed to the book trade worldwide by Apress Media, LLC, 1 New York Plaza, New York, NY 10004,
U.S.A. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [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.
For information on translations, please e-mail [email protected]; for reprint,
paperback, or audio rights, please e-mail [email protected].
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub (https://github.com/Apress). For more detailed information, please visit
https://www.apress.com/gp/services/source-code.
Paper in this product is recyclable
Table of Contents
About the Authors���������������������������������������������������������������������������������������������������� ix

About the Technical Reviewers������������������������������������������������������������������������������� xi


Acknowledgments������������������������������������������������������������������������������������������������� xiii

Introduction�������������������������������������������������������������������������������������������������������������xv

Chapter 1: Introduction to Anomaly Detection��������������������������������������������������������� 1


What Is an Anomaly?��������������������������������������������������������������������������������������������������������������������� 1
Anomalous Swans������������������������������������������������������������������������������������������������������������������� 1
Anomalies as Data Points�������������������������������������������������������������������������������������������������������� 4
Anomalies in a Time Series����������������������������������������������������������������������������������������������������� 6
Categories of Anomalies������������������������������������������������������������������������������������������������������������� 12
Data Point–Based Anomalies������������������������������������������������������������������������������������������������� 12
Context-Based Anomalies����������������������������������������������������������������������������������������������������� 13
Pattern-Based Anomalies������������������������������������������������������������������������������������������������������ 14
Anomaly Detection���������������������������������������������������������������������������������������������������������������������� 14
Outlier Detection�������������������������������������������������������������������������������������������������������������������� 15
Noise Removal����������������������������������������������������������������������������������������������������������������������� 15
Novelty Detection������������������������������������������������������������������������������������������������������������������ 16
Event Detection��������������������������������������������������������������������������������������������������������������������� 16
Change Point Detection��������������������������������������������������������������������������������������������������������� 16
Anomaly Score Calculation���������������������������������������������������������������������������������������������������� 17
The Three Styles of Anomaly Detection�������������������������������������������������������������������������������������� 17
Where Is Anomaly Detection Used?�������������������������������������������������������������������������������������������� 18
Data Breaches����������������������������������������������������������������������������������������������������������������������� 18
Identity Theft�������������������������������������������������������������������������������������������������������������������������� 19
Manufacturing����������������������������������������������������������������������������������������������������������������������� 20

iii
Table of Contents

Networking���������������������������������������������������������������������������������������������������������������������������� 21
Medicine�������������������������������������������������������������������������������������������������������������������������������� 21
Video Surveillance����������������������������������������������������������������������������������������������������������������� 22
Environment�������������������������������������������������������������������������������������������������������������������������� 22
Summary������������������������������������������������������������������������������������������������������������������������������������ 22

Chapter 2: Introduction to Data Science����������������������������������������������������������������� 23


Data Science������������������������������������������������������������������������������������������������������������������������������� 24
Dataset���������������������������������������������������������������������������������������������������������������������������������� 24
Pandas, Scikit-Learn, and Matplotlib������������������������������������������������������������������������������������� 27
Data I/O���������������������������������������������������������������������������������������������������������������������������������� 28
Data Manipulation����������������������������������������������������������������������������������������������������������������� 33
Data Analysis������������������������������������������������������������������������������������������������������������������������� 75
Visualization�������������������������������������������������������������������������������������������������������������������������� 79
Data Processing�������������������������������������������������������������������������������������������������������������������� 85
Feature Engineering and Selection��������������������������������������������������������������������������������������� 96
Summary���������������������������������������������������������������������������������������������������������������������������������� 103

Chapter 3: Introduction to Machine Learning������������������������������������������������������� 105


Machine Learning��������������������������������������������������������������������������������������������������������������������� 106
Introduction to Machine Learning��������������������������������������������������������������������������������������� 106
Data Splitting����������������������������������������������������������������������������������������������������������������������� 111
Modeling and Evaluation����������������������������������������������������������������������������������������������������� 112
Overfitting and Bias-Variance Tradeoff�������������������������������������������������������������������������������� 121
Hyperparameter Tuning������������������������������������������������������������������������������������������������������� 130
Validation���������������������������������������������������������������������������������������������������������������������������������� 132
Summary���������������������������������������������������������������������������������������������������������������������������������� 134

Chapter 4: Traditional Machine Learning Algorithms������������������������������������������� 135


Traditional Machine Learning Algorithms���������������������������������������������������������������������������������� 136
Isolation Forest�������������������������������������������������������������������������������������������������������������������� 136
One-Class Support Vector Machine������������������������������������������������������������������������������������� 159
Summary���������������������������������������������������������������������������������������������������������������������������������� 182

iv
Table of Contents

Chapter 5: Introduction to Deep Learning������������������������������������������������������������ 183


Introduction to Deep Learning�������������������������������������������������������������������������������������������������� 185
What Is Deep Learning?������������������������������������������������������������������������������������������������������ 185
The Neuron�������������������������������������������������������������������������������������������������������������������������� 187
Activation Functions������������������������������������������������������������������������������������������������������������ 189
Neural Networks������������������������������������������������������������������������������������������������������������������ 203
Loss Functions�������������������������������������������������������������������������������������������������������������������� 210
Gradient Descent and Backpropagation������������������������������������������������������������������������������ 213
Loss Curve��������������������������������������������������������������������������������������������������������������������������� 224
Regularization��������������������������������������������������������������������������������������������������������������������� 227
Optimizers��������������������������������������������������������������������������������������������������������������������������� 228
Multilayer Perceptron Supervised Anomaly Detection�������������������������������������������������������� 238
Simple Neural Network: Keras��������������������������������������������������������������������������������������������� 243
Simple Neural Network: PyTorch����������������������������������������������������������������������������������������� 251
Summary���������������������������������������������������������������������������������������������������������������������������������� 260

Chapter 6: Autoencoders�������������������������������������������������������������������������������������� 261


What Are Autoencoders?����������������������������������������������������������������������������������������������������������� 262
Simple Autoencoders���������������������������������������������������������������������������������������������������������������� 264
Sparse Autoencoders���������������������������������������������������������������������������������������������������������������� 281
Deep Autoencoders������������������������������������������������������������������������������������������������������������������� 284
Convolutional Autoencoders����������������������������������������������������������������������������������������������������� 286
Denoising Autoencoders����������������������������������������������������������������������������������������������������������� 294
Variational Autoencoders���������������������������������������������������������������������������������������������������������� 304
Summary���������������������������������������������������������������������������������������������������������������������������������� 320

Chapter 7: Generative Adversarial Networks������������������������������������������������������� 321


What Is a Generative Adversarial Network?������������������������������������������������������������������������������ 322
Generative Adversarial Network Architecture���������������������������������������������������������������������� 325
Wasserstein GAN����������������������������������������������������������������������������������������������������������������� 327
WGAN-GP����������������������������������������������������������������������������������������������������������������������������� 329
Anomaly Detection with a GAN�������������������������������������������������������������������������������������������� 330
Summary���������������������������������������������������������������������������������������������������������������������������������� 343
v
Table of Contents

Chapter 8: Long Short-Term Memory Models������������������������������������������������������� 345


Sequences and Time Series Analysis���������������������������������������������������������������������������������������� 346
What Is an RNN?����������������������������������������������������������������������������������������������������������������������� 349
What Is an LSTM?��������������������������������������������������������������������������������������������������������������������� 350
LSTM for Anomaly Detection����������������������������������������������������������������������������������������������������� 355
Examples of Time Series����������������������������������������������������������������������������������������������������������� 377
art_daily_no_noise.csv������������������������������������������������������������������������������������������������������� 378
art_daily_nojump.csv���������������������������������������������������������������������������������������������������������� 379
art_daily_jumpsdown.csv��������������������������������������������������������������������������������������������������� 381
art_daily_perfect_square_wave.csv����������������������������������������������������������������������������������� 384
art_load_balancer_spikes.csv�������������������������������������������������������������������������������������������� 386
ambient_temperature_system_failure.csv�������������������������������������������������������������������������� 387
ec2_cpu_utilization.csv������������������������������������������������������������������������������������������������������� 389
rds_cpu_utilization.csv������������������������������������������������������������������������������������������������������� 390
Summary���������������������������������������������������������������������������������������������������������������������������������� 392

Chapter 9: Temporal Convolutional Networks������������������������������������������������������ 393


What Is a Temporal Convolutional Network?����������������������������������������������������������������������������� 394
Dilated Temporal Convolutional Network���������������������������������������������������������������������������������� 399
Anomaly Detection with the Dilated TCN����������������������������������������������������������������������������� 404
Encoder-Decoder Temporal Convolutional Network������������������������������������������������������������������ 421
Anomaly Detection with the ED-TCN����������������������������������������������������������������������������������� 424
Summary���������������������������������������������������������������������������������������������������������������������������������� 441

Chapter 10: Transformers������������������������������������������������������������������������������������� 443


What Is a Transformer?������������������������������������������������������������������������������������������������������������� 443
Transformer Architecture����������������������������������������������������������������������������������������������������� 446
Transformer Encoder����������������������������������������������������������������������������������������������������������� 447
Transformer Decoder����������������������������������������������������������������������������������������������������������� 452
Transformer Inference��������������������������������������������������������������������������������������������������������� 455
Anomaly Detection with the Transformer���������������������������������������������������������������������������� 455
Summary���������������������������������������������������������������������������������������������������������������������������������� 480

vi
Table of Contents

Chapter 11: Practical Use Cases and Future Trends of Anomaly Detection ��������� 481
Anomaly Detection�������������������������������������������������������������������������������������������������������������������� 482
Real-World Use Cases of Anomaly Detection���������������������������������������������������������������������������� 485
Telecom������������������������������������������������������������������������������������������������������������������������������� 485
Banking������������������������������������������������������������������������������������������������������������������������������� 487
Environmental��������������������������������������������������������������������������������������������������������������������� 488
Health Care�������������������������������������������������������������������������������������������������������������������������� 490
Transportation��������������������������������������������������������������������������������������������������������������������� 493
Social Media������������������������������������������������������������������������������������������������������������������������ 494
Finance and Insurance�������������������������������������������������������������������������������������������������������� 495
Cybersecurity���������������������������������������������������������������������������������������������������������������������� 496
Video Surveillance��������������������������������������������������������������������������������������������������������������� 499
Manufacturing��������������������������������������������������������������������������������������������������������������������� 500
Smart Home������������������������������������������������������������������������������������������������������������������������� 503
Retail����������������������������������������������������������������������������������������������������������������������������������� 504
Implementation of Deep Learning–Based Anomaly Detection�������������������������������������������������� 504
Future Trends���������������������������������������������������������������������������������������������������������������������������� 506
Summary���������������������������������������������������������������������������������������������������������������������������������� 508

Index��������������������������������������������������������������������������������������������������������������������� 511

vii
About the Authors
Suman Kalyan Adari is currently a machine learning research engineer. He obtained a
B.S. in computer science at the University of Florida and an M.S. in computer science,
specializing in machine learning, at Columbia University. He has been conducting
deep learning research in adversarial machine learning since his freshman year at the
University of Florida and has presented at the IEEE Dependable Systems and Networks
workshop on Dependable and Secure Machine Learning held in Portland, Oregon,
USA in June 2019. Currently, he works on various anomaly detection tasks spanning
behavioral tracking and geospatial trajectory modeling.
He is quite passionate about deep learning, and specializes in various fields ranging
from video processing to generative modeling, object tracking, time-series modeling,
and more.

Sridhar Alla is the co-founder and CTO of Bluewhale, which helps organizations big
and small in building AI-driven big data solutions and analytics, as well as SAS2PY, a
powerful tool to automate migration of SAS workloads to Python-based environments
using Pandas or PySpark. He is a published author of books and an avid presenter
at numerous Strata, Hadoop World, Spark Summit, and other conferences. He also
has several patents filed with the US PTO on large-scale computing and distributed
systems. He has extensive hands-on experience in several technologies, including Spark,
Flink, Hadoop, AWS, Azure, TensorFlow, Cassandra, and others. He spoke on anomaly
detection using deep learning at Strata SFO in March 2019 and at Strata London in
October 2019. He was born in Hyderabad, India, and now lives in New Jersey with his
wife, Rosie, his daughters, Evelyn and Madelyn, and his son, Jayson. When he is not busy
writing code, he loves to spend time with his family and also training, coaching, and
organizing meetups.

ix
About the Technical Reviewers
Puneet Sinha has accumulated more than 12 years of work
experience in developing and deploying end-to-end models
in credit risk, multiple marketing optimization, A/B testing,
demand forecasting and brand evaluation, profit and price
analyses, anomaly and fraud detection, propensity modeling,
recommender systems, upsell/cross-sell models, modeling
response to incentives, price optimization, natural language
processing, and OCR using ML/deep learning algorithms.

Shubho Mohanty is a product thinker and creator, bringing


two decades of experience in the “concept-to-­market”
life cycle of some of the unique, innovative, and highly
successful industry-first products and platforms in the data
and security spaces.
Shubho holds 12+ US patents in data, analytics, and
cloud security. He has also been awarded IDG CIO100, 2020
for strategizing and developing a technology innovation
ecosystem.
He currently serves as the Chief Product Officer at Calibo, where he leads the
product vision, strategy, innovation, and development of Calibo’s enterprise PaaS. Prior
to Calibo, Shubho was the Global VP of Product & Engineering at CDK Global (formerly,
ADP Inc). He has also served in various product leadership roles in organizations like
Symantec and Microsoft. He also co-founded Ganos, a B2B data start-up.
He received his B.Tech. in Electrical Engineering from National Institute of
Technology (NIT), India. He is a mentor to many high-repute start-up programs where
he guides young entrepreneurs to solve some of the most pressing challenges. He is also
an influential speaker at leading technology and industry forums.

xi
Acknowledgments
Suman Kalyan Adari
I would like to thank my parents, Krishna and Jyothi, my sister, Niha, and my loving dog,
Pinky, for supporting me throughout the entire process of writing this book as well as my
various other endeavors.

Sridhar Alla
I would like to thank my wonderful, loving wife, Rosie Sarkaria, and my beautiful,
loving children, Evelyn, Madelyn, and Jayson, for all their love and patience during the
many months I spent writing this book. I would also like to thank my parents, Ravi and
Lakshmi Alla, for their blessings and all the support and encouragement they continue
to bestow upon me.

xiii
Introduction
Congratulations on your decision to explore the exciting world of anomaly detection
using deep learning!
Anomaly detection involves finding patterns that do not adhere to what is
considered as normal or expected behavior. Businesses could lose millions of dollars
due to abnormal events. Consumers could also lose millions of dollars. In fact, there are
many situations every day where people’s lives are at risk and where their property is at
risk. If your bank account gets cleaned out, that’s a problem. If your water line breaks,
flooding your basement, that’s a problem. If all flights at an airport get delayed due to a
technical glitch in the traffic control system, that’s a problem. If you have a health issue
that is misdiagnosed or not diagnosed, that’s a very big problem that directly impacts
your well-being.
In this book, you will learn how anomaly detection can be used to solve business
problems. You will explore how anomaly detection techniques can be used to address
practical use cases and address real-life problems in the business landscape. Every
business and use case is different, so while we cannot copy and paste code and build a
successful model to detect anomalies in any dataset, this book will cover many use cases
with hands-on coding exercises to give you an idea of the possibilities and concepts
behind the thought process. All the code examples in the book are presented in Python
3.8. We choose Python because it is truly the best language for data science, with a
plethora of packages and integrations with scikit-learn, deep learning libraries, etc.
We will start by introducing anomaly detection, and then we will look at legacy
methods of detecting anomalies that have been used for decades. Then we will look
at deep learning to get a taste of it. Then we will explore autoencoders and variational
autoencoders, which are paving the way for the next generation of generative models.
Following that, we will explore generative adversarial networks (GANs) as a way to detect
anomalies, delving directly into generative AI.
Then we’ll look at long short-term memory (LSTM) models to see how temporal data
can be processed. We will cover temporal convolutional networks (TCNs), which are
excellent for temporal data anomaly detection. We will also touch upon the transformer

xv
Introduction

architecture, which has revolutionized the field of natural language processing as


another means for temporal anomaly detection. Finally, we will look at several examples
of anomaly detection in various business use cases.
In addition, all coding examples will be provided in TensorFlow 2/Keras, with
accompanying PyTorch equivalents, on the GitHub repository for this book. You will
combine all this extensive knowledge with hands-on coding using Jupyter notebook-
based exercises to experience the knowledge firsthand and see where you can use these
algorithms and frameworks. Best of luck, and welcome to the world of deep learning!

xvi
CHAPTER 1

Introduction to Anomaly
Detection
In this chapter, you will learn about anomalies in general, the categories of anomalies,
and anomaly detection. You will also learn why anomaly detection is important, how
anomalies can be detected, and the use case for such a mechanism.
In a nutshell, this chapter covers the following topics:

• What is an anomaly?

• Categories of different anomalies

• What is anomaly detection?

• Where is anomaly detection used?

What Is an Anomaly?
Before you get started with learning about anomaly detection, you must first understand
what exactly you are targeting. Generally, an anomaly is an outcome or value that
deviates from what is expected, but the exact criteria for what determines an anomaly
can vary from situation to situation.

Anomalous Swans
To get a better understanding of what an anomaly is, let’s take a look at some swans
sitting by a lake (Figure 1-1).

1
© Suman Kalyan Adari, Sridhar Alla 2024
S. K. Adari and S. Alla, Beginning Anomaly Detection Using Python-Based Deep Learning,
https://doi.org/10.1007/979-8-8688-0008-5_1
Chapter 1 Introduction to Anomaly Detection

Figure 1-1. A couple swans by a lake

Let’s say that we want to observe these swans and make assumptions about the
color of the swans at this particular lake. Our goal is to determine what the normal
color of swans is and to see if there are any swans that are of a different color than this
(Figure 1-2).

Figure 1-2. More swans show up, all of which are white

2
Chapter 1 Introduction to Anomaly Detection

We continue to observe swans for a few years and all of them have been white. Given
these observations, we can reasonably conclude that every swan at this lake should be
white. The very next day, we are observing swans at the lake again. But wait! What’s this?
A black swan has just flown in (Figure 1-3).

Figure 1-3. A black swan appears

Considering our previous observations, we thought that we had seen enough swans
to assume that the next swan would also be white. However, the black swan defies that
assumption entirely, making it an anomaly. It’s not really an outlier, which would be, for
example, a really big white swan or a really small white swan; it’s a swan that’s entirely
a different color, making it an anomaly. In our scenario, the overwhelming majority of
swans are white, making the black swan extremely rare.
In other words, given a swan by the lake, the probability of it being black is very
small. We can explain our reasoning for labeling the black swan as an anomaly with one
of two approaches (though we aren’t limited to only these two approaches).
First, given that a vast majority of swans observed at this particular lake are white, we
can assume that, through a process similar to inductive reasoning, the normal color for a
swan here is white. Naturally, we would label the black swan as an anomaly purely based
on our prior assumptions that all swans are white, considering that we’d only seen white
swans before the black swan arrived.

3
Chapter 1 Introduction to Anomaly Detection

Another way to look at why the black swan is an anomaly is through probability.
Now assume that there is a total of 1000 swans at this lake and only two are black swans;
the probability of a swan being black is 2 / 1000, or 0.002. Depending on the probability
threshold, meaning the lowest probability for an outcome or event that will be accepted
as normal, the black swan could be labeled as anomalous or normal. In our case, we will
consider it an anomaly because of its extreme rarity at this lake.

Anomalies as Data Points


We can extend this same concept to a real-world application. In the following example,
we will take a look at a factory that produces screws and attempt to determine what an
anomaly could be in this context and individual screws are sampled from each batch
and are tested to ensure a certain level of quality is maintained. For each sampled screw,
assume that the density and tensile strength (how resistant the screw is to breaking
under stress) are measured.
Figure 1-4 is an example graph of various sampled screws with the dotted lines
representing the range of densities and tensile strengths allowed. The solid lines form a
bounding box where any value of tensile strength and density inside it is considered good.

Figure 1-4. Density and tensile strength in a batch of screw samples

The intersections of the dotted lines have created several different regions containing
data points. Of interest is the bounding box (solid lines) created from the intersection of
both sets of dotted lines since it contains the data points for samples deemed acceptable
(Figure 1-5). Any data point outside of that specific box will be considered anomalous.
4
Chapter 1 Introduction to Anomaly Detection

Figure 1-5. Data points are identified as “good” or “anomaly” based on their
location

Now that we know which points are and aren’t acceptable, let’s pick out a sample from
a new batch of screws and check its data to see where it falls on the graph (Figure 1-6).

Figure 1-6. A new data point representing the new sample screw is generated,
with the data falling within the bounding box

The data for this sample screw falls within the acceptable range. That means that this
batch of screws is good to use since its density as well as tensile strength is appropriate
for use by the consumer. Now let’s look at a sample from the next batch of screws and
check its data (Figure 1-7).

5
Chapter 1 Introduction to Anomaly Detection

Figure 1-7. A new data point is generated for another sample, but this falls
outside the bounding box

The data falls far outside the acceptable range. For its density, the screw has abysmal
tensile strength and is unfit for use. Since it has been flagged as an anomaly, the
factory can investigate why this batch of screws turned out to be brittle. For a factory of
considerable size, it is important to hold a high standard of quality as well as maintain
a high volume of steady output to keep up with consumer demands. For a monumental
task like that, automation to detect any anomalies to avoid sending out faulty screws is
essential and has the benefit of being extremely scalable.
So far, we have explored anomalies as data points that are either out of place, in the
case of the black swan, or unwanted, in the case of faulty screws. So what happens when
we introduce time as a new variable?

Anomalies in a Time Series


With the introduction of time as a variable, we are now dealing with a notion of
temporality associated with the data sets. What this means is that certain patterns are
dependent on time. For example, daily, monthly, or yearly occurrences are time-series
patterns as they present on regular time intervals.
To better understand time series–based anomalies, let’s look at a few examples.

6
Chapter 1 Introduction to Anomaly Detection

Personal Spending Pattern


Figure 1-8 depicts a random person’s spending habits over the course of a month.

Figure 1-8. Spending habits of a person over the course of a month

Assume the initial spike in expenditures at the start of the month is due to the
payment of bills such as rent and insurance. During the weekdays, our example person
occasionally eats out, and on the weekends goes shopping for groceries, clothes, and
various other items. Also assume that this month does not include any major holidays.
These expenditures can vary from month to month, especially in months with major
holidays. Assume that our person lives in the United States, in which the holiday of
Thanksgiving falls on the last Thursday of the month of November. Many U.S. employers
also include the Friday after Thanksgiving as a day off for employees. U.S. retailers have
leveraged that fact to entice people to begin their Christmas shopping by offering special
deals on what has colloquially become known as “Black Friday.” With that in mind, let’s
take a look at our person’s spending pattern in November (Figure 1-9). As expected, a
massive spike in purchases occurred on Black Friday, some of them quite expensive.

7
Random documents with unrelated
content Scribd suggests to you:
was in Nancy’s mind a new thought. It came when Orilla had smiled
at her in the woods. Perhaps Nancy could help Orilla!

So the moment passed and the cousins continued to bathe and


bind the scratches. Rosa’s hands were cruelly torn and, as the girls
talked, Rosa gave Nancy an inkling of the whole absurd plot.

“I never expected she would ask me to chop down trees, of


course,” explained Rosa. “She had always insisted that what I
needed was hard work. She made fun of me for being soft, and I
suppose that made me mad. At any rate, she promised that I would
lose five pounds a week if I faithfully followed her advice.”

“Five pounds a week?” repeated Nancy, incredulously.

“Yes. And you see, if I lost twenty pounds in the month the folks
are in Europe I would be quite—quite slender when they came
back,” and she smiled so prettily that Nancy wondered Why she
wanted to spoil those dimples with trimming off their scallops.

“And she was going to do all that—with violent exercise?” Nancy


questioned in amazement.

“That and—starvation.” Rosa uttered the last word tragically. “I


didn’t promise to starve but—now, Coz, haven’t I been humble
enough? You don’t want to hear any more of the horrible details, do
you?”

“Well, I’d like to know,” continued Nancy cautiously, “why she


wanted the trees cut down? What was she going to do with them?”

“That’s just what I wanted to know, too,” Rosa said in reply. “I


knew for a long time that she had some secret scheme; you know
the night I hurt my foot we saw that she had a hatchet in her car,
but she has never told me what the real plan was. I’ve known Orilla
since I was a baby, and I suppose I’m used to her ways, but I must
say she is secretive. And sly! I couldn’t find out the least thing, ever,
that she didn’t want me to know.”

“Yes, I think she is like that,” agreed Nancy, thereby dismissing for
a time at least the mystery of the plot. “But what we have got to do
now is to fix up her damages. Rosa, I do wish you would let Margot
see that big scratch. I’m no good at nursing and I don’t want to take
the responsibility—”

“I’ll be as beautiful as ever in a day or two—see if I don’t,” replied


Rosa, making desperate efforts not to wince as she poured the
disinfectant over her hands.

“But when Margot smells this drug store she’ll surely suspect,”
intimated Nancy, for, as she said, the disinfectants had made havoc
with the atmosphere of Rosa’s little dressing room, that adjoined her
bath.

“I’m always getting cuts on my hands,” replied Rosa. “All I have to


do is to hide the rest of me. Margot is pretty busy now, you know. If
she hadn’t been she would have heard old Pixley’s story. Can’t that
woman talk though?”

Nancy agreed that she could, and that led to further discussion of
Mrs. Pixley, Orilla, Mrs. Rigney and some other folks that Nancy had
recently become acquainted with.

This was to have been the evening of the dance at Sunset Hotel,
but there was now no possibility of the girls attending it. Not only
did Rosa’s battered condition make it impossible, but a heavy
summer storm had descended upon the mountains, and showed no
indications of subsiding.

Rain, wind, thunder, lightning! The girls watched the great


spectacle from a west window, and at times it seemed as if the
heavens were splitting asunder. The lightning flashed in a solid sea
of fire behind one great mountain, and this looked indeed as if the
sky were rent and another world was breaking through.

Somehow the storm seemed a fitting finish for the turbulent day
that Nancy and Rosa had just passed through, and as they watched
the display in the heavens they worried about Orilla. Was she safely
under shelter? Why did not her mother prevent her foolish work?
And, Nancy secretly wondered, what had that little flash of light
meant which she had seen flame up suddenly and then die out?

For days following this there was no sign of Orilla nor did any
word from her come to Fernlode. But this was in no way unusual,
rather was it regarded as a good thing for Rosa and Nancy.

Mrs. Rigney came around occasionally, Nancy noticed, and she


was surprised to find her a woman of intelligence. She appeared to
be on the best of terms with Margot and the other servants at
Fernlode, and this seemed to be cause for greater wonderment that
Orilla should be so antagonistic.

Rosa recovered quickly, as she had promised to, and she also
“reformed.” That is, she no longer kept secret trysts with the “fat-
killer,” as she now called Orilla, although Nancy knew that letters,
messages, and even bundles addressed to Orilla went out very
privately from Rosa’s room.

The arrival of a lovely white scales for Rosa’s bath room came as a
surprise one day, but a letter from Lady Betty presently explained it.

Rosa was to take long walks with Nancy, as she had promised to
do; she was also to follow some sensible advice in the matter of
diet, and just to keep up her courage she was to watch the scales!

This plan, which was really the fulfillment of Nancy’s written


suggestion to Lady Betty, brought the dove of peace to Fernlode, in
so far as Rosa’s conduct was concerned. For in the first week of her
trial of it she actually lost three and one half pounds.
“And no barked paws nor skinned shins,” she gayly announced to
everyone, including, of course, the Durands.

“I can’t see why you didn’t know that insistent exercise and cut-
down rations was the real cure,” argued Nancy, reasonably enough.
“Even at grammar school, and in the lower grades, babes, fat dimply
little ones, are walking miles to school and turning their backs on
lollipops.”

“But I hate to walk and I love lollipops,” explained the shameless


Rosa.

“And you loved the excitement of a woodland mystery?”

“Yes; I could just see myself in a movie cutting down trees and
falling away into skeleton lines. It was romantic now, Nance, wasn’t
it, really?”

“Very. Especially when we brought you back on a tray. All carved


up like a tatooed injun—”

They yelled at this, and Nancy was so relieved at Rosa’s change of


disposition that she, Nancy, began to get fat! Just as Lady Betty had
hoped!

Everything was so happy and cheerful; Rosa’s friends came almost


every afternoon and evening, numbers of them, girls and boys, and
at last the summer had opened up into a real vacation for Nancy.

They finally went to a dance at Sunset Hotel, and Rosa wore the
blue cape. It was a perfect evening and everyone was so happy that
even the sight of the cape upon Rosa’s shoulders failed to bring
regret to Nancy. Four car loads of young folks from their summer
homes paraded down the hillside road at nine o’clock. It seemed late
to Nancy, but she knew better than to say so.
“The hotel children have the ball-room from eight until nine,” Dell
had explained, “then the young folks swarm in. Don’t worry about
being too young, Nancy. You look like a young lady in that stunning
rig.”

The “rig” was stunning, even Nancy conceded that, for it was a
flame-colored chiffon robe that fell down straight from her
shoulders, sleeveless, and with the fashionable high neck. Her dark
hair set the flame color off beautifully, as did the glints of her dark
eyes, and she really did look lovely. This costume was one of Lady
Betty’s presents.

Whether a girl was fourteen or nineteen no one could tell, for the
bobbed heads were so much alike and so ineffably youthful,
everyone looked very young indeed.

The hotel was fascinating to Nancy; its great posts and pillars
flanked with baskets of growing vines, the spectacular lights set all
over the ceilings, and the music!

It was a scene of gaiety such as Nancy had never before


witnessed, and when Gar had danced with her and had then taken
her out to the great porch to see the lake illuminations, Nancy
Brandon felt like a girl in a dream. Summer life at a fashionable
resort was to her like a page from a book, or a scene in a play.

“But I’d die if I had to stay at a hotel,” Gar assured her as she
commented upon the grandeur. “It’s all right once in a while, but you
would hate this artificial living as a regular diet.”

Nancy agreed that she might, but she also expressed her interest
in a sample like this. Rosa had a wonderful time also, the best part
of it being the number of compliments she received.

“Wasn’t she getting thin!”


The dance ended early for the Durand party, as Dell was a
practical chaperon, and she insisted upon returning to the hills at a
reasonable hour. But the memory of that first night stayed in Nancy’s
mind just as she remembered her own little party in the Whatnot
Shop last year.

Only Ted and her mother had been there to make that first one
really complete.
CHAPTER XX

A SMALL BROWN BAG

And Rosa was getting thin! In this simple, easy, pleasant way—just
long walks, daily. That meant rain or shine and “long” meant all the
way to the village, clear down to the post office, two miles each way.
At first Rosa objected; she found her feet untrained for such tramps,
but Nancy knew and insisted.

“Why not try my cure?” she urged. “It’s not near as unpleasant as
Orilla’s.”

“Very well,” Rosa would sigh. “But you better tip off the scales. If
they don’t mark me low—”

“They will,” Nancy promised, and of course they always did.

Gar proposed tennis. Rosa had never before played—“good reason


why,” she explained, but now she was anxious to try the splendid
summer game.

“You look wonderful in your sport suit, Rosa,” Nancy encouraged,


“and out on the courts—”

“All right. Anything once, but don’t expect me to fly up in the air
after the ball, the way you do, Nance. I’m still something of a paper
weight, you know.”

So tennis was tried, successfully.

“I know what was the matter with you, Rosa,” her cousin told her
one afternoon after an especially enjoyable set with Paul and Gar,
“you thought you were fat, and so you were self-conscious and
miserable. Now you think you aren’t very fat, and you’re proud.”

“I think I’m not! I am not, am I Nancy? Tell me quickly! End this


‘crool’ suspense—” and Rosa performed a wonderful stunt with
tennis racket and ball, actually “flying” off her feet in a really
creditable manner.

She was so happy! No one who has always been free from such
an insistent worry as Rosa’s had been, can actually understand the
joy of hope that a few pounds less flesh can bring. The hand of that
little white scale became a friend, an understanding friend, and
every time it pointed to a figure Rosa held her breath.

But this did not solve the mystery built around Orilla. Rosa herself
was as keenly interested in that as was Nancy, in spite of her rescue
from any actual need of it. Bit by bit she confided in Nancy details of
the queer bargain between her and Orilla. She had shared her
allowance with her, who insisted she had a right to some of it
anyway, and that she would not “make Rosa as thin as herself” if
she didn’t pay well for it.

“But what has she done with the money?” Nancy asked, after that
admission.

“Oh, I don’t know,” replied Rosa, innocently. “You see, she had
some big project in her mind and everything else she could get was
supposed to go toward it.”

One evening when Nancy was seeking a little solitude along the
lake front, there to read again her latest letter from her mother and
the latest “funny page” from Ted, she was startled by someone
calling her name in a hushed, whispering voice.

“Who is it?” she asked, although quite certain of whom it would


prove to be.
“I, Orilla,” came the answer, as the girl stepped from behind the
shrubbery into Nancy’s path.

“Oh, how you frightened me!” Nancy exclaimed. “I was so intent


upon—my own thoughts. How are you, Orilla? We haven’t seen or
heard of you in such a long time.”

“Oh, I’m all right,” replied the girl, who as usual wore the dingy
suit of khaki, and a boy’s soft hat upon her thick red hair. “I’m glad I
met you here. I want to ask a favor of you.”

“All right, Orilla,” said Nancy sincerely, “I shall be glad to help you
if I can.”

“I believe you. You’re different. Maybe it’s because you’re poor—”

Nancy smiled broadly at this, but Orilla did not appear to notice it.
She motioned to a rustic seat and they both sat down. Nancy was
curious and a little anxious, for Orilla, while assuming friendship, still
had that queer, furtive look in her eyes, and her face was surely
unnaturally flushed.

“Have you been working too hard, Orilla?” Nancy asked kindly.
“You aren’t strong and you shouldn’t—”

“I’m strong as an ox,” interrupted the girl. “That’s because I live


out doors. I was sick once, and since I cured myself no one has
interfered with my ways.”

This, thought Nancy, must be why Orilla’s mother allowed her to


do as she pleased. But even so, she surely might have saved her
daughter from wood chopping!

“Yes, I only go indoors at night—I steal in. No one knows where I


go,” this meant much to Orilla, evidently. “But you’re my friend and
we both have a secret, so that’s what I want to tell you.”
Nancy was so surprised she merely listened, not venturing to
interrupt with a single word. Orilla kept locking and unlocking her
fingers in a nervous way, and she fidgeted in her seat even more
nervously.

As if the secret so long waited for was about to burst over Nancy’s
head, like a cloud before a storm, she waited.

“Yes, I know I can trust you,” Orilla continued after a pause.


“You’re what they call an idealist, aren’t you?”

“No, I don’t think I am,” faltered Nancy. “Why should I be?”

“Because you’re so square. I’ve read about girls like you. They
always want everything just right, no tricks nor sneaking. I knew
that night when you tried on that cape that you were doing
something for Rosa.”

“Why? How did you know?”

“You looked it. When a girl is sneaking she doesn’t flare up and
get mad the way you did,” went on the surprising Orilla and Nancy
knew better than to prolong the discussion by any arguments. She
merely smiled and accepted the words as they were intended.

“And since then you’ve never told,” Orilla declared, her features
drawn and strained as she talked, and her eyes shifting. “You never
told Rosa, for if you had she would have told me. What she knows
the world knows,” said Orilla, scornfully.

“But Rosa has never said anything against you, Orilla,” spoke up
Nancy. “I’m sure you ought to give her credit for that.”

“There you go again. I told you you were an idealist. But that’s all
the better for me. I can trust you, too.”

This sounded like trickery to Nancy, and she said so.


“But you are lots older than I am and you ought to have lots more
sense,” she pointed out. “I don’t mind helping you, if it’s something
you can’t do yourself, but I must be loyal to my own family,” she
insisted, firmly.

“It won’t interfere with your family, don’t worry,” replied Orilla. “I
just want you to take care of some money for me. That’s not so hard
to do, is it?”

“Money!” Nancy remembered what Rosa had said about that.


“Why can’t you take care of it?” she asked.

“Because I suspect that someone knows I’ve got it, and they’re
after it.” Orilla was very calm and composed now, and Nancy noticed
how quickly her moods changed. “It’s in this little bag,” Orilla
continued, showing to Nancy a square, brown bag made of khaki,
just like her suit. It was bulky and seemed to contain quite a lot of
money—if it were all money.

“Well, if you just want me to take it for a few days I don’t suppose
there is any harm in that,” reasoned Nancy. “But suppose someone
stole it from me?”

“No one would around here, that is, not up in your rooms,” replied
Orilla. “Please take it, Nancy. It means an awful lot to me,” and she
laid the bag on Nancy’s lap as she pleaded.

“All right. But don’t hold me responsible. I’ll do the best I can to
take care of it, of course,” Nancy assured her, “but if anything does
happen—”

“It won’t. Thank you for taking it, Nancy. Now I am free to—finish
my work,” and she stood up to leave.

“But, Orilla, you were going to tell me something else; your secret
place, wasn’t it?” Nancy felt now she should know more about
Orilla’s business if she were going to act as her secret treasurer.
“Oh, I can’t wait now, but meet me here to-morrow evening at
this time, and then I’ll tell you. Good-bye, I must go. Don’t mention
having seen me,” and just as she had done before, Orilla slipped
away, back of the bushes like a wild creature of the woods, indeed.

For a few minutes Nancy sat there, the brown bag lying in her lap,
an unwelcome treasure.

“How queer!” she was thinking. “And most of this was Rosa’s. But
Rosa gave it to her, so it really is Orilla’s now. Imagine my being her
—cashier!” and a little laugh escaped from Nancy’s lips.

The gentle splash of a canoe paddle told of Orilla’s departure, and


Nancy checked her thoughts to listen.

“She is certainly the oddest girl I have ever met,” she reflected.
“But I had no idea of becoming a chum of hers. What would Rosa
say if she knew?”

This was not a pleasant consideration, but somehow Nancy knew


she could serve even Rosa best by agreeing, partly, with Orilla, so
her misgivings were presently quieted.

Having the bag of money was certainly a tangible link between her
and Orilla, and already Nancy understood its significance.

“I’d love to tell Rosa,” she pondered, “but if I did Orilla would not
trust me further, and I know I must keep her confidence, for a while
at least. Just now Rosa is getting along so splendidly,” she told
herself, “and she’s so relieved from her worries, that it surely must
be best to keep her out of Orilla’s affairs.”

The little brown bag assumed almost a live form as Nancy


clutched it. How long had Orilla been saving all that money? Some of
it was in bills—that was easily felt through the cloth—and much of it
was in coin; the weight vouched for that.
However, it was all in Nancy’s keeping now, and she tucked it
under her scarf as she entered the house. Meeting Rosa in the hall,
Nancy then accepted the plan for an evening at Durand’s.

“Anything easy for to-night,” she replied to Rosa’s suggestion. “I


don’t feel a bit like thinking—hard.”
CHAPTER XXI

ENTANGLEMENTS

A week passed and still Nancy guarded the bag, but in that time
had neither seen Orilla nor heard from her. The girl’s promise to
meet her at the lakeside, on the evening following that upon which
she had imposed the trust upon Nancy, had not been kept. Nancy
waited until dark, and even a little later than she felt comfortable,
out there alone away from everyone, and at a considerable distance
from the house; but Orilla did not come.

Nancy imagined many reasons for her failure to appear. Perhaps


she had feared detection, as she had the person she suspected of
being after her money. Or perhaps her mother was keeping watch.
Mrs. Rigney had been around Fernlode almost daily in the past
week, and more than once Nancy heard her talking to Margot, as if
she were in distress. Orilla’s name was mentioned often, but Nancy
knew nothing more than that.

Finally, it was Rosa who broke the spell. She burst in upon Nancy
one morning before breakfast.

“Nancy!” she exclaimed, “I’m just worried to death about Orilla.


There’s a reason why, but I just can’t explain, if you don’t mind.
You’ve been such a dear, I perfectly hate to go at things this way
again,” and Rosa’s face bore out that statement. “But if you’ll only
trust me this once more—”

“Of course I trust you, Rosa—”

“I knew you would. Then don’t worry about me this morning. I’ve
just got to go off and find her—”
“I’ll go with you.”

“If you don’t mind, dear, I’d rather go alone.”

“But I want to go, Rosa. I’m interested in finding her. In fact, I’ve
got a reason—”

“Really! Are we both having secrets about Orilla? That would be


funny if we weren’t so worried, wouldn’t it? But, Nancy, please let
me find her and then I’ll tell you where she is. I hate to seem
secretive but—well, I just have to this time.”

Nancy was baffled. Rosa was so positive in wanting to go off


alone. And she, Nancy, was just as anxious to get in touch with
Orilla. Why shouldn’t they both go together?

“Rosa,” she began again, “I’d love to tell you my secret, but you
see I promised Orilla—”

“So did I,” interrupted Rosa, smiling in spite of herself. “And, you
see, if we both went she would believe we both told.”

This sounded reasonable and Nancy hesitated. Rosa saw her


chance and pressed it further.

“I’ll come back as quickly as I can,” she promised, “and then you
can go talk to her.”

“But you haven’t had breakfast—”

“Yes, I have. I couldn’t rest. I got to fussing and I went downstairs


before even Margot was around. Don’t worry about me, Nancy love,”
begged Rosa, pressing her cousin’s hand impulsively. “I’ll take good
care of myself this time, and I promise not to cut down a single
tree.”

“But you are not going on the lake alone?”


“No; a friend is going to take me in her motor boat.”

“Not Dell, nor Gar?”

“No. But someone just as trustworthy. You know Katherine Walters


you met last week at Durand’s? She’s a regular old sea captain on
the lake, and runs a boat like one.”

“I saw her out the other day, in a big green launch—”

“The Cucumber. That’s her boat and that’s the one we’re going in.”

“Who else is going?” asked Nancy. “Why couldn’t I sit in the boat
with Katherine—”

“If Orilla saw you along she would never believe me,” persisted
Rosa, a little disconsolately.

“Don’t you think we are humoring her an awful lot, Rosa?” Nancy
asked in a strained voice; she too was bothered.

“Well, I suppose I am; not you. But just this once. You see, Nancy,
Orilla hasn’t much in life and she expected such a lot.”

“You’re good to her, Rosa, perhaps too good. But I hope you’re
not making another mistake; you know how she influences you.”

“She couldn’t now, Coz. I’m not in need of her services. You see,
my doctor is a resident. I have her with me all the time,” and again
she flung her arms affectionately around Nancy.

There seemed nothing to do but agree, so after many admonitions


from Nancy and promises from Rosa, the latter started off. She had
arranged things with Margot so as to allay her suspicions, and when
Rosa waved to Nancy from the green launch, called the Cucumber,
Nancy sighed in spite of the beautiful morning and all other
favorable circumstances.
Hours dragged by slowly. First Nancy wrote letters—it would soon
be time for homecomings—then she drew a pen and ink sketch for
Ted. She even finished the little handkerchief she was hemstitching
for Manny, but yet there remained a full half hour before lunch time.
And no sign of Rosa!

It might have been that Nancy had not yet gotten over that
anxious search for Rosa, when she and the Durands finally found her
on Mushroom Island, at any rate, all that morning Nancy worried.

Lunch time came but Rosa did not. One, two, three o’clock! Nancy
could stand it no longer. She made some excuse to Margot and
hurried over to Durand’s.

It happened that Paul was there, and, of course, Gar was with
him; but Dell had gone out.

“Look for Rosa!” shouted Gar, just as she knew he would when
she told why she had come. “Say, Nance, what is this, anyway? A
bureau of missing persons?”

She explained without fully explaining, and the boys gladly enough
set sail in the Whitecap, once more to search for the illusive Rosa.

“But no wood carving, wood chopping, nor wood lugging,”


declared Gar, gayly. Then he told Paul about his previous experience
in that line, embellishing the story with extravagant little touches
peculiar to the style of Garfield Durand.

Paul and Nancy, as usual, found many things to talk about, to


discuss and even to disagree over, for Paul proclaimed the beauties
of New Hampshire while Nancy held with unswerving loyalty to the
glories of Massachusetts.

But her anxiety over the delay of Rosa’s return was not even thinly
covered by these assumed interests, and only Gar’s continual threats
to do something dreadful to the runaway “this time sure” and his
repeated avowals that he positively, absolutely and unquestionably
would not “dig up the woods nor chop down trees in this search,”
kept Nancy’s real worry from being mentioned.

“We don’t have to go on the islands to look for the Cucumber,” Gar
insisted. “The girls couldn’t hide that boat if they tried. It’s so green
you can hear it, to say nothing of the noise that engine makes.”

“Oh, no, we don’t have to go inland at all,” Nancy agreed with


elaborate indifference. “I just wanted to look around and hurry Rosa
along. She has a way of staying over, if it’s only to gather weeds.
Rosa doesn’t seem to worry, ever, about keeping her appointments,
but I didn’t want Margot to spoil any of our fun, just because Rosa
stayed out all day, you see,” finished Nancy, quite confused from the
length of her speech and its utter improbability.

“Let’s skirt around these islands,” proposed Paul, “and if we don’t


spy the Cuke we better try over at the Point. They may be
picnicking. Katherine loves the lollypops they sell at the Point—I
know.”

“All right,” agreed, Gar, “but after that I’ve got to get back.
Promised to drive down for Dell, you know, and she isn’t walking off
fat.”

They skirted the islands but did not discover the long green boat
at any landing or out upon the lake. Then they proceeded to
navigate in the direction of the Point. Here they encountered many
boats of many descriptions, for the Point was not only a pretty point
of land extending out into the water, but it was also a point of
recreation and general interest for summer folk for miles around.

“Not here,” reported Paul, for there was no sign of the girls, and
the boat was nowhere to be seen. “Better go back home. They could
have gone in through the cove, you know.”
“Of course they could, and I’ll bet they have,” declared Gar. “Well,
we had a fine sail, anyway. Hope you enjoyed it, Miss Brandon?” he
finished in assumed formality.

“Very much,” simpered Nancy imitating Gar’s affectation. “I had


been rather dull all day, but this—” she swept the lake with a broad
gesture—“this is glorious.”

“Joking aside,” said Paul, “are you having any fun, Nancy? That
cousin of yours is as hard to manage as a young colt, I’d say.”

“Oh, no, she isn’t, really,” replied Nancy. “We have wonderful times
now, much better than we did at first when we didn’t understand
each other.”

“And you claim to understand Rosa now?” asked Gar, swerving his
boat into the small cove that lay beside his own summer home and
Fernlode.

“Well, yes, I think I do,” spoke up Nancy. “But then, Rosa’s my


own cousin and that makes it easier.”

“Maybe that’s it,” retorted Gar, “because I’m not so dreadfully


stupid, I hope, yet I can’t understand her a-tall.”

“Now look!” cried Paul suddenly, standing up and pointing to


Fernlode. “There they are! What did I tell you!”

“That,” replied Gar, crisply, slowing down his engine.

“Oh, I’m so glad,” breathed Nancy, in her joy betraying how


anxious she had been. “But the boat is going off!”

“Yes, but your dear little Rosalind is all right, standing there all by
her little self. See her?” said Gar, as usual teasing about Rosa.
It took but a few moments to pull up to the long landing, but the
Cucumber had already steamed off and, as Gar had said, Rosa stood
there, waiting alone.

One look at her cousin’s face and Nancy knew she had been
disappointed. She had not found Orilla.
CHAPTER XXII

A GIRL AND HER ROOM

Nancy found Rosa, as she suspected, disappointed and even


worried.

“It was the strangest thing,” Rosa explained, “every time we


thought we had found Orilla she just seemed to disappear. Of course
she didn’t, but on the lake there are so many turns, and ins and outs
and, being in the boat, we stayed on the water. I suppose Orilla was
on land,” she finished sullenly.

“Why was it so important for you to see her to-day?” Nancy asked,
innocently enough.

“I had a message for her, and that should have reached her to-
day,” replied Rosa. But she did not go into details and Nancy felt that
she could not question further. However, she did try to reassure
Nancy that Orilla would probably be around before nightfall.

“I hope so,” Rosa said, “if not, I simply don’t know what I shall do.
I went to all her woodland haunts that I know of, and land knows
she’s got enough of them, but there wasn’t even a trace to show
that human footprints had been over the ground lately. Oh, dear,
isn’t it awful to be a crank? Orilla is just a crank, and I tell you I’m
about sick of her ways,” Rosa pouted. “But I have to get some of the
loose ends tied up before I can wash my hands of it, as Margot
would say.”

“And there she is,” Nancy reminded Rosa, for at that moment
Margot was coming down the path at a brisk rate.
“On the war path,” Rosa remarked. “I’ve got to surprise her with
some news. Let me see! Oh, I’ll tell her about a big sale of linens
down at Daws,” and forthwith Rosa rushed up the path to proclaim
the glad tidings to the unsuspecting Margot—or the Margot who was
pretending to be unsuspecting.

From that moment until after dinner and until almost nightfall, the
cousins had not a moment to themselves, for company came, and
Rosa had to entertain. Nancy also helped out, the visitors being
most interested in her simple reports from the neighboring state.
When they were leaving (they were the Drydens from the Weirs and
were staying at a hotel in Craggy Bluff) Rosa drove in town with
them to bring some mail to the post office, but Nancy declined to
go. Rosa was to meet Dell Durand and drive back with her, and as
Dell had talked to Nancy on the phone and assured her she would
be back before dark (all this in coaxing Nancy to go), there seemed
no danger of delay for Rosa.

When they had all gone Nancy felt herself free at last to take her
favorite stroll along the lake front. The sunset was glorious; golds,
purples, greens and ashes of roses, in hues too brilliant to be so
tersely described. Is there anything which can beggar description as
can a sunset on that great, majestic lake! Words cannot tell of it, no
more than the mist can veil it.

“It looks as if heaven were leaking joy,” thought Nancy, as she


watched the descending beauty.

Thinking of her mother, of Ted and of dear Manny, as she did


every evening, this being a part of her filial love and devotion, Nancy
gazed and wondered, until suddenly a step near her startled her
from her reverie.

It was Orilla!

“Oh!” exclaimed Nancy. “I didn’t see you coming—”


“No, one can’t. I have so many secret little paths around here,”
spoke Orilla, and Nancy noticed that her voice was very low,
subdued, and her words rather well chosen.

“But I’m so glad you came,” Nancy hurried to add. “We’ve been
looking everywhere for you, all day.”

“I’ve been away, to the city, and I’m so tired!” With a sigh she
sank down upon the lake-side bench. “I believe I would die if I had
to live in a city,” she murmured.

“It is dreadfully stuffy after air like this,” agreed Nancy. “But you
are not sick, are you, Orilla?” she asked anxiously, for Orilla did seem
very unlike herself.

“No, I guess not. I have an awful headache but—don’t let us talk


about sickness,” Orilla broke off suddenly. “I have something more
important to talk of to-night.”

“First, Orilla,” interrupted Nancy, “won’t you please let me give you
your little bag? It has worried me—”

“If you’ll only keep it a few more days, Nancy—”

“But why? Shouldn’t your mother take care of it for you?”


questioned Nancy. She had been determined to get rid of the
treasure and this was her chance.

“Mother?” Orilla’s voice showed disapproval of that idea, most


emphatically. “No, mother is good and has given me much freedom,
but she doesn’t quite understand me, you see, Nancy,” finished the
girl with one more of those weary, heavy sighs.

Before Nancy could speak again Orilla had risen and was leading
the way to the other end of the spacious grounds.
“Come this way,” she said. “We won’t meet anybody and I must
not delay too long.”

“But Rosa may be along—”

“Let me tell you alone, Nancy, please,” pleaded Orilla. “Then you
may tell Rosa if you want to. I’m tired of secrets, tired of being
hated and tired of fighting. Until you showed some friendliness for
me, I haven’t ever remembered kindness except from mother, and,
well, just a few others,” finished Orilla, evasively.

She was hurrying toward the rear of the big house and Nancy was
following. The path she picked out was quite new to Nancy, who
thought she had discovered every little nook and corner of the big
summer place, but this was a mere strip of clearance, tunneled in
under heavy wild grape vines that grew clamorously over high and
low shrubbery, and even climbed into the biggest wild cherry tree.

Neither girl spoke for some minutes. Then Orilla asked Nancy if
she liked Fernlode.

“Why, yes,” Nancy replied, “I love it.”

“So do I,” declared Orilla sharply, “and you know they—put me


out!”

“Oh, no, Orilla, they didn’t do that,” Nancy hurried to correct her.
“When Uncle Frederic married—”

“I know all that, Nancy, but don’t let’s talk of it. It makes me
furious, even now. Don’t talk any more—some one might hear us.
Just come quietly after me,” she whispered.

Where could she be leading her, Nancy wondered? Surely this was
the end of the house just back of the servant’s dining room—
Orilla stepped up to the corner of the building, and then Nancy
saw that they faced a small door. It was situated at the extreme end
of the first floor and almost hidden in heavy shrubbery. While Nancy
waited, Orilla surprised her still further by taking a key from her
dress and turning it in the lock.

The door opened!

“Orilla!”

“Hush! Just keep close,” whispered the girl. “It is only dark at the
entrance.”

By keeping close Nancy soon found herself in a quarter of


Fernlode she had never before explored. She knew that it must be
the servants’ quarters, and before she could speculate further, Orilla
had unlocked another door and they both found themselves in a
pleasant little room!

“This is—my—room!”

Nancy could scarcely breathe, she was so frightened at the tone in


which Orilla said that.

Her room!

“You see, these are all my things, and I come here whenever I get
a chance,” Orilla confessed. “No one ever thinks of looking in here,
and I never take anything away. I wouldn’t do that, you know,” she
said very positively, as if fearing Nancy’s opinion.

“Your—room!” Nancy was too surprised to get past that


unbelievable statement.

“Yes; and no one else cares for it or needs it.” Orilla was
straightening around the brown reed chairs and patting the small
table cover, and as she touched a thing, her affectionate interest in it
was plain even to Nancy’s excited gaze.

“Doesn’t Rosa know?” Nancy asked finally.

“No. Rosa has been away a lot, you know, and besides, the
Fernells only come here in summer. I was born in these mountains,
and as a child mother brought me here. She’s a nurse, you know,
and a wonderful mother.” Orilla sat down and pointed out a chair to
Nancy, which the latter gratefully accepted.

Nancy knew little about Mrs. Rigney, but she guessed now that
probably her love for Orilla had led her into the mistake of allowing
her daughter to grow up believing Fernlode to be her own home.

As if divining Nancy’s thoughts, Orilla said almost that very thing.

“Mother was devoted to the real Mrs. Fernell,” she said, thereby
disputing Lady Betty’s later claim, “and Mrs. Fernell was lovely to
me. While Rosa was away at school I played around here as—well—
you can imagine how I felt to be put out of this room!” she again
challenged.

In vain did Nancy try to explain the situation, defending Lady


Betty’s purpose in keeping no one but servants on Fernlode, but
Orilla would not be convinced of its justice. Suddenly she threw
herself upon the bed with such secret enjoyment, that Nancy knew
the girl’s mind had become morbid on the subject of ownership.

As so often happens with those who are physically delicate, her


reasoning also was at fault. She imagined she had been unjustly
treated, whereas nothing of the sort had happened. Mr. Fernell had
been generous to the point of bounty in educating Orilla and in
giving a sum of money to the mother. This had all been done
because of Mrs. Rigney’s devotion to Nancy’s Aunt Katherine, the
first Mrs. Fernell, and Nancy knew the story well.
“Yes,” Orilla began again, “it was not mother’s fault. And she has
tried to make me see things her way; but I can’t. I’ve always been a
wild mountain girl and all that I’ve loved has been here. You don’t
think I did wrong to come back here once in a while, do you?” she
asked plaintively.

Nancy gazed silently at the girl upon the bed. Her hair, always so
fiery red, did not look quite so peculiar on that pillow—Orilla’s own
pillow, that she had so long loved. The room was musty and needed
a thorough airing, but Nancy noticed a small casement window
opened slightly—this was, she reasoned, Orilla’s way of secretly
ventilating the room.

“I don’t see what could be very wrong about your coming here,”
Nancy finally answered Orilla’s question. “But why didn’t you ask?”

“Ask? After being turned away?”

“You were not turned away, Orilla, and that’s a foolish thing to say.
Uncle Frederic simply changed his plans and there was no need of a
nurse here,” stoutly and emphatically proclaimed Nancy.

“And they didn’t like me to be with Rosa—”

“Now, Orilla, you can’t deny you were not a suitable companion
for Rosa, because you could make her do anything. You are older,
and you worked on her sympathies,” Nancy felt obliged to point out.

“I’ll admit that now, Nancy, to you, but it didn’t seem that way
before. I never told anyone, not even mother, how I felt, and it just
all piled up inside of me until I imagined myself like a volcano,
always ready to—erupt.”

This was the first time that Nancy had noticed any depth to Orilla’s
character, and she had continually wondered where the educational
influences, said to have been provided by her uncle, had been
hidden in the girl’s personality. But the confession of her morbid,
morose state of mind was plainly the answer. She had fought down
culture, choosing to be simply a wild girl of the mountains.

“My mother always insists upon us talking things out,” said Nancy
quietly. “It’s so much better to share our worries—”

“I know that now. I feel like a different girl, just from talking to
you, and you’re only a kid,” said Orilla, again betraying her disregard
of polite English. “I’m through with secrets, Nancy,” she continued,
jumping up suddenly from the bed, with evident nervousness. “One
secret leads to another until I am fairly smothered in them. Now,
this one is not so heavy, but there—are—more.”
CHAPTER XXIII

SHEDDING SECRETS

Orilla was now moving about the room in such an excited manner
that Nancy became alarmed!

“Come on out, Orilla,” she begged. “I really have stayed too long.
Rosa will be back—”

“All right. Let’s go. But I want to tell you that I broke the fern
stand—Mrs. Betty’s, you know,” Orilla said, her voice raising beyond
the pitch of security. “I came back that night—mother was to be
away a week and I came up here for that one night—and I had
forgotten my key. I was so mad to have to go back home all alone
and it was late, you know, that I just Smashed that fancy stand for
revenge!”

“Orilla! That lovely fernery!” gasped Nancy.

“Yes, I know it does seem cowardly,” admitted the girl, “but my


head was splitting—”

“You have a headache now,” interrupted Nancy, noting again the


girl’s highly flushed face.

“Yes, and I must go,” she cast a lingering look about the room,
which really was quite cozy. “How I would love to be able to come in
here and fix things up,” she sighed.

Nancy was thinking of a possible plan, but she had no time to


mention it now. She wanted to get outside and find Rosa.
“Of course I’m going to tell Rosa,” she said, making sure of
speaking positively so that Orilla would not expect to object.

“I suppose you can. I am so tired of secrets that I was determined


to tell you before my old crankiness would come over me again,”
confessed Orilla. She had locked the door and again they were
treading their way under the wild grape-vine tunnel. “I don’t know
why it is that some people can soothe one so. I should never have
thought of confiding in anyone else, and yet you’re just a little girl,”
reasoned Orilla wonderingly.

“Maybe that’s it,” replied Nancy brightly. “Because I’m little—”

“Oh, no. That isn’t all of it, but you wouldn’t care for soft soap,”
said Orilla wistfully.

“I’m sure I hear Rosa—”

“But I must go, Nancy. My head is bursting, and if I get talking to


Rosa, she’ll say so much—”

“You know she has been looking for you all day,” persisted Nancy,
anxiously.

“I can’t help it. Everything has got to wait—until to-morrow. Tell


her I’ll be here in the morning—if I’m able—”

“Orilla, I can’t let you go,” interposed Nancy. “I’m afraid you’re sick
—”

“No, I’m not, really. I have these headaches often, and bringing
you into my room, you see—”

“Yes, I understand,” said Nancy kindly. “And if you feel that


perhaps, as you say, you had better get quiet. All right; I’ll tell Rosa.
Don’t worry that she’ll find fault; she always speaks well of you,
Orilla.”
“Yes, little Rosa’s all right, but silly. She was so ashamed of being
fat—why—” and a little laugh escaped Orilla’s lips. “Wasn’t she
foolish?”

Nancy heard voices from the roadway just as Orilla slipped into
her boat and paddled off. Finding the secret room had been such a
sudden revelation that Nancy could scarcely understand it all even
yet. That Orilla should have so loved that room, and that she had
been coming to it secretly for so long a time, seemed incredible.

“Uncle Frederic would have let her have it, I’m sure,” Nancy
reasoned, “and I’m going to ask him to,” she determined, when the
unmistakable voice of Rosa floated in through the hedge.

It was going to be exciting, Nancy knew, this news to Rosa. It


would surely be met with one of Rosa’s typical outbursts, so she
decided to postpone the telling until Rosa was safely, if not quietly,
indoors.

“Drydens want us to come to their hotel some night,” Rosa


reported, “and we must go. Nancy, they think I’m thin enough. What
do you think of that?” and Rosa took a look in the mirror to help
Nancy’s answer.

“Calm yourself, Rosa,” said Nancy importantly. “I’ve got such news
—”

“Orilla been here?”

“Yes—”

“And she’s gone? Why didn’t you chain her till I came—”

“I couldn’t, Rosa, she had a dreadful headache—”

“Headache! What’s that to the trouble I’ve got? Her troubles, I


mean,” and Rosa fell into a chair as if in despair.
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