Introduction to Embedded Machine Learning 2.4.1 - Anomaly Detection
Summary
TLDRThis video delves into anomaly detection in machine learning, highlighting its utility in fraud detection and predictive maintenance. It uses the example of credit card fraud to illustrate how unsupervised learning can flag unusual transactions. The script also discusses its application in embedded systems, like predicting mechanical failures in factories or satellites, using NASA's bearing data as a case study. The tutorial demonstrates setting up anomaly detection using Edge Impulse, showing how to classify and detect anomalies in motion data with a microcontroller, emphasizing its practicality in identifying unexpected behaviors.
Takeaways
- 💡 Anomaly detection is a vital technique in machine learning, used for identifying unusual patterns or outliers in data.
- 🔍 It can be implemented through supervised or unsupervised learning methods, depending on the availability and nature of data labels.
- 🛒 A common application of anomaly detection is in fraud detection, such as identifying suspicious credit card transactions.
- 📈 The script uses a two-dimensional plot to illustrate how anomaly detection can spot purchases that deviate from a customer's typical spending pattern.
- 🚫 Anomaly detection can help in flagging transactions that significantly differ from a cluster of 'normal' samples, even if they appear normal in individual dimensions.
- 🛠️ The technique is not only useful in financial contexts but also in predicting mechanical failures in industrial and aerospace applications.
- 📊 Historical data, such as vibration readings from bearings, can be analyzed to predict failures before they occur, which is crucial for maintenance and safety.
- 📱 The script demonstrates how to use a smartphone and Edge Impulse to collect and classify motion data, identifying anomalies in real-time.
- 🤖 Edge Impulse employs k-means clustering, an unsupervised learning algorithm, to define boundaries around normal data clusters and detect outliers.
- 🔧 The anomaly detection model assigns an anomaly score to new samples, which helps in determining how far they deviate from expected patterns.
- 💻 The script guides through deploying an anomaly detection model on a microcontroller, showcasing its practical application in embedded systems.
Q & A
What is anomaly detection in the context of machine learning?
-Anomaly detection is a technique used in machine learning to identify data points that do not conform to expected patterns or other data points, often indicating irregularities or outliers.
How can anomaly detection be applied in fraud detection?
-In fraud detection, anomaly detection can be used by credit card companies to identify unusual purchase patterns that deviate from a customer's typical spending habits, potentially flagging fraudulent transactions.
What is the significance of using multiple dimensions in anomaly detection?
-Using multiple dimensions in anomaly detection allows for the creation of a boundary around clusters of samples, which is more effective than using simple thresholds in one dimension at a time, as it can better capture the complexity of the data.
How does the credit card company example illustrate the concept of anomaly detection?
-The credit card company example shows anomaly detection by comparing a new purchase to a model of normal spending habits. If the new purchase falls outside the expected range in multiple dimensions, it is flagged as an anomaly.
What role does anomaly detection play in embedded systems?
-In embedded systems, anomaly detection is crucial for predicting faults and mechanical failures before they occur, which can prevent significant damage and costs in industries such as manufacturing and aerospace.
Why is the NASA bearing data significant for anomaly detection research?
-The NASA bearing data is significant because it provides a real-world dataset where researchers can test and develop anomaly detection algorithms to predict mechanical failures based on vibration data, before the actual failure occurs.
How does the Edge Impulse platform facilitate anomaly detection?
-Edge Impulse allows users to connect their devices, collect data, and use machine learning models to classify and detect anomalies. It offers tools like spectral feature analysis and k-means clustering for anomaly detection.
What is k-means clustering and how is it used in anomaly detection on Edge Impulse?
-K-means clustering is an unsupervised learning technique used in anomaly detection to find and define the boundaries of clusters in the data. On Edge Impulse, it helps in identifying if new samples are within the expected cluster boundaries or if they are anomalies.
How can anomaly detection be implemented on a microcontroller using Edge Impulse?
-Anomaly detection can be implemented on a microcontroller by adding a k-means anomaly detection block in the Edge Impulse platform, training the model, and then deploying it to the microcontroller to classify and detect anomalies in real-time.
What is the purpose of the anomaly score in anomaly detection?
-The anomaly score in anomaly detection indicates how far a sample is from the expected cluster boundaries. A score above a certain threshold suggests that the sample is an anomaly, which can be useful for alerting or taking corrective actions.
Outlines
🔍 Introduction to Anomaly Detection
This paragraph introduces anomaly detection as a vital technique in machine learning, applicable in both supervised and unsupervised learning contexts. It highlights its utility in scenarios where exact labels are unavailable or the nature of the data is uncertain. A practical application in fraud detection within credit card companies is discussed, where purchase histories are analyzed to identify unusual transactions. The concept is further illustrated through a two-dimensional plot representing customer purchases, emphasizing the challenge of detecting anomalies that don't fit typical patterns when viewed in isolation. The paragraph concludes with an overview of anomaly detection's broader applications, such as predicting mechanical failures in industrial settings and the use of historical vibration data from NASA's experiments to improve predictive models.
🛠️ Implementing Anomaly Detection in Embedded Systems
The second paragraph delves into the application of anomaly detection in embedded systems, focusing on the prevention of mechanical failures. It references a 2005 study where vibration data from bearings was collected until their failure, with the data now available for research and competition. The paragraph then transitions to a practical demonstration using a smartphone connected to an Edge Impulse project. The process involves classifying motion patterns and using spectral features to identify anomalies. The concept of anomaly detection through clustering is introduced, with k-means clustering being the chosen method. The steps to set up anomaly detection in Edge Impulse, including selecting axes and training the model, are outlined. The paragraph concludes with a discussion on deploying the trained model on a microcontroller, demonstrating how anomaly detection can be integrated into hardware to classify and respond to unexpected motion patterns.
Mindmap
Keywords
💡Anomaly Detection
💡Supervised Learning
💡Unsupervised Learning
💡Fraud Detection
💡Dimensionality Reduction
💡Clustering
💡Feature Compression
💡Vibration Data
💡Embedded Systems
💡K-means Clustering
💡Anomaly Score
Highlights
Anomaly detection is a valuable technique in machine learning for identifying unusual patterns or errors.
Supervised or unsupervised learning can be applied depending on the availability and nature of data labels.
Anomaly detection is instrumental in fraud detection, such as identifying unusual credit card transactions.
Data features can be visualized in a two-dimensional plot to simplify the identification of anomalies.
Creating a boundary around clusters in multiple dimensions is a technique to flag anomalies.
Anomaly detection can prevent fraud by alerting credit card companies to unusual transactions.
Predicting mechanical failures in advance is crucial for maintaining equipment in factories and spacecraft.
Vibration data from worn-out bearings can be used to train models for predicting equipment failures.
Anomaly detection in embedded systems can prevent costly damage by identifying potential faults early.
Edge Impulse is a platform that can be used to connect smartphones for live classification of motion data.
K-means clustering is an unsupervised learning technique used for anomaly detection in spectral features.
Anomaly detection models assign a score to new samples to determine how close they are to known clusters.
Thresholds can be set to flag anomalies based on the anomaly score derived from the model.
The RMS values of each axis provide the best separation for anomaly detection in motion data.
Anomaly detection can be implemented on microcontrollers for real-time monitoring of equipment.
Anomaly detection systems can identify motions that are outside the expected norm, enhancing classification accuracy.
Anomaly detection is beneficial for ensuring the correct classification of data and identifying potential errors.
Transcripts
[Music]
anomaly detection is an incredibly
useful technique in the world of machine
learning we can use supervised or
unsupervised learning to accomplish it
depending on the type of data we might
have if we don't have exact labels for
things or we don't quite know what we're
looking for anomaly detection can help
us determine if something has gone wrong
with our system a common use of anomaly
detection techniques is in fraud
detection let's say a credit card
company keeps track of its customers
purchase history it knows what kinds of
things people buy on what days and it
creates a model of each person's
spending habits to make this easier to
visualize let's pretend that all of
these features can be compressed into
just two dimensions that allows us to
imagine the features as a
two-dimensional plot with points each
representing a purchase by the customer
let's say that a new purchase happens to
our eyes this doesn't look quite right
we can intuitively see that this sample
doesn't quite belong with the group
however if a computer were to compare
this with the group in any one dimension
the sample would be acceptable it's less
in the x direction than the rightmost
normal sample and it's certainly less in
the y direction than the highest
purchase so what can we do to flag this
as an anomaly one technique involves
creating a boundary around the cluster
of samples in multiple dimensions rather
than using simple thresholds in one
dimension at a time here we can see that
our new sample is outside of this
acceptable range and we can flag it as
an anomaly in the case of our credit
card company we might ask the customer
if they really made this purchase or if
the anomaly was bad enough maybe cancel
the card and ship out a new one
automatically this is a broad overview
of what anomaly detection does there are
many different techniques and algorithms
that can be used to detect anomalies
when it comes to embedded systems
predicting faults and mechanical
failures before they happen is extremely
useful for things like factories large
equipment and space faring vehicles back
in 2005 researchers set up bearings to
rotate for days and wore them out to the
point of breaking they recorded the
vibration data which you can see in
these charts at some point about 30 days
out all of the bearings broke
this data has been made freely available
on nasa's site and there have been lots
of research and competitions using this
data the idea is to try and predict
anomalies in the vibration data long
before the bearings break
imagine applying this to things like
large motors bearings or compressors in
places like factories or maybe on a
satellite if you could detect when
something was about to break you might
have the chance to repair it before it
causes thousands or millions of dollars
of damage
this is why anomaly detection is so
interesting in the world of embedded
machine learning connect your phone to
your edge impulse project by heading to
smartphone.edgeimpulse.com
in your project head to live
classification start classifying and
when your phone says it's collecting
data start moving the phone in a known
pattern like left to right then move it
in a pattern that does not match
something we've done before i'll move
mine forward and backward when it's done
you'll see that the model classified the
left to right motions successfully but
it attempted to classify the forward and
backward motions as idle that makes
sense because the x and z axes weren't
moving which were the only axes that
made any difference for the other
motions however if you look at the
spectral features plot you can see that
our forward and backward samples seem to
create their own cluster outside of
other samples note that these are the x
y and z rms values just like our credit
card example we can clearly see that
something is not right but our
classifier isn't trained to pick up this
motion so it classifies it as one of the
four possible categories
head to impulse design we can see that
there's enough information present in
the spectral features to separate
anomalies so we can keep the spectral
analysis block what we need is some form
of anomaly detection so let's add that
as a second learning block note that
edge impulse is using k-means clustering
which is an unsupervised learning
technique that attempts to find the
boundaries of each set of feature
clusters save the impulse and head to
the newly added anomaly detection page
cluster count gives us the number of
clusters that the k-means algorithm will
look for in the data you should have at
least as many clusters as you do classes
but in practice you want more to account
for variations in the data for example
if one of your motions has the phone in
different positions like pointing down
instead of up you will likely have a few
clusters in that one class feel free to
play around with this number and take a
look at where the clusters form in the
output plot once we train the anomaly
detection model any new sample will be
given an anomaly score which determines
how close it is to one of those clusters
anything over zero is considered outside
the cluster boundary and we can set the
threshold here which is 0.3 by default
you can select any number of axes to
perform the k-means clustering algorithm
on but as you saw earlier the rms values
of each axis gives us the best
separation so check each of the x y and
z axes for rms and click start training
when it's done the clusters should be
assigned head to live classification
repeat the same test as before moving
the phone left to right and then some
other motion like forward and backward
when it's done take a look at the output
there's a new anomaly column which tells
you how much each sample is outside the
norm for that class negative numbers are
well within the normal limits for the
class but anything over 0.3 is flagged
as an anomaly sure enough if you look at
the spectral features plot you can see
where we started in the left right
cluster and then moved out to our own
cluster click on one of the anomaly
predictions and it should highlight the
sample showing you that it's far outside
of one of the clusters feel free to try
this again for any of the other motions
but i'd like to show you this in action
on a microcontroller open your arduino
motion project in edge impulse and head
to impulse design add a k-means anomaly
detection block and click save impulse
head to the newly created anomaly
detection page and select all three rms
axes click start training and wait a few
moments for the clustering algorithm to
complete when it's done head to the
deployment page and download the arduino
library
you might need to delete the old library
from your arduino libraries folder so
that it does not conflict with your
earlier one even if you are able to
install both it makes it easier to keep
track of which one you're using in
arduino if you only have one
start the arduino ide and include the
newly downloaded.zip library go to file
examples and open the accelerometer
sketch we won't use the continuous one
this time to keep things simple select
the serial port and begin uploading this
to your board this sketch should
actually be the same as before the only
difference now is that ei classifier has
anomaly should be set to 1 and we should
see an anomaly score printed to the
console in your own application you can
now use this result.anomaly value to
determine if a particular motion is
outside of what your model expects to
see remember that in edge impulse we
looked for this number to be over 0.3 to
determine if something should be
classified as an anomaly when uploading
is done select your port again and open
a serial monitor you should see the
program sample for two seconds perform
inference and then let you know what the
results are notice that we also have an
anomaly score now try performing one of
the trained motions and you should see
that it classifies the motions and gives
you a negative anomaly score letting you
know that it's quite sure the motion
falls within the expected norm now try a
motion that you didn't train for like
forward and backward it should attempt
to classify the motion but it should
also give you a high anomaly score try
some other motions that you did not
train the model on or try performing one
of the motions erratically to see what
happens when it comes to classifying
motion an anomaly detection system can
be great for determining if something
seems off or letting you know that
something might not have been classified
correctly
[Music]
you
Посмотреть больше похожих видео
#7 Machine Learning Specialization [Course 1, Week 1, Lesson 2]
5 Ways Data Science Changed Finance
NanoEdge AI Studio V3 - Anomaly Detection demo
Machine Learning | What Is Machine Learning? | Introduction To Machine Learning | 2021 | Simplilearn
Network Traffic Anomaly Detection Using Machine Learning
Webinar: AI/ML in the Fintech Industry by PayPal Global PM, Vinod Jain
5.0 / 5 (0 votes)