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 ...

Get Hands-On Unsupervised Learning with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.