Skip to Content
Hands-On Unsupervised Learning with Python
book

Hands-On Unsupervised Learning with Python

by Giuseppe Bonaccorso
February 2019
Intermediate to advanced
386 pages
9h 54m
English
Packt Publishing
Content preview from Hands-On Unsupervised Learning with Python

Anomaly detection

Let's now apply the Epanechnikov density estimation to perform an example of anomaly detection. According to the structure of the probability density, we have decided to impose a cut-off at p(x) < 0.005. Such a condition is displayed in the following screenshot:

Epanechnikov density estimation with anomaly cut-off

The red dots indicate the age limits for a sample to be classified as an anomaly. Let's compute the probability densities for some test points:

import numpy as nptest_data = np.array([12, 15, 18, 20, 25, 30, 40, 50, 55, 60, 65, 70, 75, 80, 85, 90]).reshape(-1, 1)test_densities_epanechnikov = np.exp(kd_epanechnikov.score_samples(test_data)) ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Unsupervised Learning Using Python

Hands-On Unsupervised Learning Using Python

Ankur A. Patel
Introduction to Machine Learning with Python

Introduction to Machine Learning with Python

Andreas C. Müller, Sarah Guido

Publisher Resources

ISBN: 9781789348279Supplemental Content