Skip to Main Content
Hands-On Unsupervised Learning with Python
book

Hands-On Unsupervised Learning with Python

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

An example of Sanger's network

Let's consider a sample bidimensional zero-centered dataset, obtained with the scikit-learn make_blobs() utility function:

import numpy as npdef zero_center(Xd):    return Xd - np.mean(Xd, axis=0)X, _ = make_blobs(n_samples=500, centers=3, cluster_std=[5.0, 1.0, 2.5], random_state=1000)Xs = zero_center(X)Q = np.cov(Xs.T)eigu, eigv = np.linalg.eig(Q)print('Covariance matrix: {}'.format(Q))print('Eigenvalues: {}'.format(eigu))print('Eigenvectors: {}'.format(eigv.T))

The output of the previous snippet is as follows:

Covariance matrix: [[18.14296606  8.15571356]
 [ 8.15571356 22.87011239]]
Eigenvalues: [12.01524122 28.99783723]
Eigenvectors: [[-0.79948496  0.60068611]
 [-0.60068611 -0.79948496]]

The eigenvalues are about ...

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