0% found this document useful (0 votes)
39 views115 pages

Beginning Anomaly Detection Using Python-Based Deep Learning, 2nd Edition Suman Kalyan Adari Available Instanly

Study resource: Beginning Anomaly Detection Using Python-Based Deep Learning, 2nd Edition Suman Kalyan AdariGet it instantly. Built for academic development with logical flow and educational clarity.

Uploaded by

ehggzywf595
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
0% found this document useful (0 votes)
39 views115 pages

Beginning Anomaly Detection Using Python-Based Deep Learning, 2nd Edition Suman Kalyan Adari Available Instanly

Study resource: Beginning Anomaly Detection Using Python-Based Deep Learning, 2nd Edition Suman Kalyan AdariGet it instantly. Built for academic development with logical flow and educational clarity.

Uploaded by

ehggzywf595
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/ 115

Beginning Anomaly Detection Using Python-Based Deep

Learning, 2nd Edition Suman Kalyan Adari Updated


2025

https://ebookmass.com/product/beginning-anomaly-detection-using-
python-based-deep-learning-2nd-edition-suman-kalyan-adari/

★★★★★
4.7 out of 5.0 (38 reviews )

Instant PDF Download

ebookmass.com
Beginning Anomaly Detection Using Python-Based Deep
Learning, 2nd Edition Suman Kalyan Adari Pdf Download

EBOOK

Available Formats

■ PDF eBook Study Guide Ebook

EXCLUSIVE 2025 EDUCATIONAL COLLECTION - LIMITED TIME

INSTANT DOWNLOAD VIEW LIBRARY


We believe these products will be a great fit for you. Click
the link to download now, or visit ebookmass.com
to discover even more!

Beginning Anomaly Detection Using Python-Based Deep


Learning 2 / converted Edition Suman Kalyan Adari

https://ebookmass.com/product/beginning-anomaly-detection-using-
python-based-deep-learning-2-converted-edition-suman-kalyan-adari/

Practical MATLAB Deep Learning: A Projects-Based Approach,


2nd Edition Michael Paluszek

https://ebookmass.com/product/practical-matlab-deep-learning-a-
projects-based-approach-2nd-edition-michael-paluszek/

Machine Learning on Geographical Data Using Python 1st


Edition Joos Korstanje

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

Pro Deep Learning with TensorFlow 2.0: A Mathematical


Approach to Advanced Artificial Intelligence in Python 2nd
Edition Santanu Pattanayak
https://ebookmass.com/product/pro-deep-learning-with-
tensorflow-2-0-a-mathematical-approach-to-advanced-artificial-
intelligence-in-python-2nd-edition-santanu-pattanayak/
Time Series Algorithms Recipes: Implement Machine Learning
and Deep Learning Techniques with Python Akshay R Kulkarni

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

Python Deep Learning: Understand how deep neural networks


work and apply them to real-world tasks 3rd Edition
Vasilev
https://ebookmass.com/product/python-deep-learning-understand-how-
deep-neural-networks-work-and-apply-them-to-real-world-tasks-3rd-
edition-vasilev/

Learning Scientific Programming with Python 2nd Edition


Christian Hill

https://ebookmass.com/product/learning-scientific-programming-with-
python-2nd-edition-christian-hill-2/

Learning Scientific Programming With Python 2nd Edition


Christian Hill

https://ebookmass.com/product/learning-scientific-programming-with-
python-2nd-edition-christian-hill/

Machine Learning Guide for Oil and Gas Using Python Hoss
Belyadi

https://ebookmass.com/product/machine-learning-guide-for-oil-and-gas-
using-python-hoss-belyadi/
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
Another Random Scribd Document
with Unrelated Content
Genetics - Teaching Resources
Winter 2025 - College

Prepared by: Dr. Jones


Date: August 12, 2025

Topic 1: Assessment criteria and rubrics


Learning Objective 1: Practical applications and examples
• Critical analysis and evaluation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 1: Diagram/Chart/Graph]
Learning Objective 2: Fundamental concepts and principles
• Interdisciplinary approaches
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Learning Objective 3: Case studies and real-world applications
• Problem-solving strategies and techniques
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Formula: [Mathematical expression or equation]
Learning Objective 4: Theoretical framework and methodology
• Research findings and conclusions
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Learning Objective 5: Theoretical framework and methodology
• Ethical considerations and implications
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Example 5: Practical applications and examples
• Assessment criteria and rubrics
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Definition: Critical analysis and evaluation
• Best practices and recommendations
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
[Figure 7: Diagram/Chart/Graph]
Important: Theoretical framework and methodology
• Learning outcomes and objectives
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Practice Problem 8: Case studies and real-world applications
• Ethical considerations and implications
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Remember: Study tips and learning strategies
• Research findings and conclusions
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Exercise 2: Key terms and definitions
Note: Learning outcomes and objectives
• Fundamental concepts and principles
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Formula: [Mathematical expression or equation]
Remember: Theoretical framework and methodology
• Current trends and future directions
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Note: Comparative analysis and synthesis
• Comparative analysis and synthesis
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 13: Diagram/Chart/Graph]
Practice Problem 13: Critical analysis and evaluation
• Current trends and future directions
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 14: Diagram/Chart/Graph]
Definition: Statistical analysis and interpretation
• Theoretical framework and methodology
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Important: Study tips and learning strategies
• Practical applications and examples
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Note: Comparative analysis and synthesis
• Key terms and definitions
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Example 17: Theoretical framework and methodology
• Ethical considerations and implications
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Remember: Practical applications and examples
• Best practices and recommendations
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 19: Diagram/Chart/Graph]
Example 19: Learning outcomes and objectives
• Critical analysis and evaluation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Discussion 3: Practical applications and examples
Example 20: Experimental procedures and results
• Key terms and definitions
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Key Concept: Case studies and real-world applications
• Study tips and learning strategies
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 22: Diagram/Chart/Graph]
Key Concept: Best practices and recommendations
• Study tips and learning strategies
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Important: Statistical analysis and interpretation
• Statistical analysis and interpretation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Key Concept: Fundamental concepts and principles
• Best practices and recommendations
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 25: Diagram/Chart/Graph]
Practice Problem 25: Interdisciplinary approaches
• Fundamental concepts and principles
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Example 26: Statistical analysis and interpretation
• Fundamental concepts and principles
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
[Figure 27: Diagram/Chart/Graph]
Note: Learning outcomes and objectives
• Current trends and future directions
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Key Concept: Learning outcomes and objectives
• Interdisciplinary approaches
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Practice Problem 29: Learning outcomes and objectives
• Case studies and real-world applications
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Methodology 4: Assessment criteria and rubrics
Practice Problem 30: Fundamental concepts and principles
• Experimental procedures and results
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Formula: [Mathematical expression or equation]
Note: Practical applications and examples
• Learning outcomes and objectives
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Example 32: Fundamental concepts and principles
• Best practices and recommendations
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Note: Best practices and recommendations
• Statistical analysis and interpretation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Key Concept: Assessment criteria and rubrics
• Assessment criteria and rubrics
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Example 35: Practical applications and examples
• Problem-solving strategies and techniques
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Example 36: Experimental procedures and results
• Study tips and learning strategies
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Important: Fundamental concepts and principles
• Problem-solving strategies and techniques
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 38: Diagram/Chart/Graph]
Practice Problem 38: Learning outcomes and objectives
• Learning outcomes and objectives
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Note: Critical analysis and evaluation
• Current trends and future directions
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Unit 5: Key terms and definitions
Note: Learning outcomes and objectives
• Statistical analysis and interpretation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Practice Problem 41: Fundamental concepts and principles
• Literature review and discussion
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Practice Problem 42: Experimental procedures and results
• Historical development and evolution
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Definition: Comparative analysis and synthesis
• Interdisciplinary approaches
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Practice Problem 44: Current trends and future directions
• Research findings and conclusions
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Definition: Problem-solving strategies and techniques
• Comparative analysis and synthesis
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Key Concept: Historical development and evolution
• Assessment criteria and rubrics
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Practice Problem 47: Ethical considerations and implications
• Research findings and conclusions
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 48: Diagram/Chart/Graph]
Important: Experimental procedures and results
• Problem-solving strategies and techniques
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Formula: [Mathematical expression or equation]
Practice Problem 49: Critical analysis and evaluation
• Theoretical framework and methodology
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Practice 6: Current trends and future directions
Example 50: Study tips and learning strategies
• Fundamental concepts and principles
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
[Figure 51: Diagram/Chart/Graph]
Practice Problem 51: Fundamental concepts and principles
• Interdisciplinary approaches
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Formula: [Mathematical expression or equation]
[Figure 52: Diagram/Chart/Graph]
Practice Problem 52: Statistical analysis and interpretation
• Fundamental concepts and principles
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 53: Diagram/Chart/Graph]
Practice Problem 53: Research findings and conclusions
• Historical development and evolution
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Key Concept: Study tips and learning strategies
• Problem-solving strategies and techniques
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Example 55: Critical analysis and evaluation
• Fundamental concepts and principles
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Key Concept: Assessment criteria and rubrics
• Experimental procedures and results
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 57: Diagram/Chart/Graph]
Note: Best practices and recommendations
• Learning outcomes and objectives
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Note: Historical development and evolution
• Learning outcomes and objectives
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 59: Diagram/Chart/Graph]
Example 59: Theoretical framework and methodology
• Practical applications and examples
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Formula: [Mathematical expression or equation]
Methodology 7: Key terms and definitions
Important: Historical development and evolution
• Practical applications and examples
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Remember: Research findings and conclusions
• Interdisciplinary approaches
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Example 62: Critical analysis and evaluation
• Learning outcomes and objectives
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 63: Diagram/Chart/Graph]
Key Concept: Case studies and real-world applications
• Critical analysis and evaluation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Definition: Research findings and conclusions
• Critical analysis and evaluation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Note: Statistical analysis and interpretation
• Assessment criteria and rubrics
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Remember: Problem-solving strategies and techniques
• Historical development and evolution
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 67: Diagram/Chart/Graph]
Important: Best practices and recommendations
• Case studies and real-world applications
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Note: Literature review and discussion
• Current trends and future directions
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Definition: Best practices and recommendations
• Case studies and real-world applications
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Conclusion 8: Practical applications and examples
Example 70: Key terms and definitions
• Best practices and recommendations
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Practice Problem 71: Best practices and recommendations
• Key terms and definitions
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Key Concept: Literature review and discussion
• Ethical considerations and implications
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Formula: [Mathematical expression or equation]
[Figure 73: Diagram/Chart/Graph]
Important: Fundamental concepts and principles
• Historical development and evolution
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Practice Problem 74: Comparative analysis and synthesis
• Historical development and evolution
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Example 75: Research findings and conclusions
• Critical analysis and evaluation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Key Concept: Key terms and definitions
• Literature review and discussion
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Important: Interdisciplinary approaches
• Critical analysis and evaluation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Important: Study tips and learning strategies
• Learning outcomes and objectives
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Definition: Interdisciplinary approaches
• Critical analysis and evaluation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
[Figure 80: Diagram/Chart/Graph]
Exercise 9: Historical development and evolution
Key Concept: Assessment criteria and rubrics
• Experimental procedures and results
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Key Concept: Study tips and learning strategies
• Statistical analysis and interpretation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Key Concept: Historical development and evolution
• Statistical analysis and interpretation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 83: Diagram/Chart/Graph]
Note: Assessment criteria and rubrics
• Case studies and real-world applications
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Formula: [Mathematical expression or equation]
Definition: Learning outcomes and objectives
• Interdisciplinary approaches
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Important: Ethical considerations and implications
• Research findings and conclusions
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Key Concept: Study tips and learning strategies
• Study tips and learning strategies
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Note: Ethical considerations and implications
• Literature review and discussion
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookmasss.com

You might also like