From 28fce491d087cb52fe0eb9bb98142c6d17bd200f Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Tue, 19 Dec 2023 14:58:00 +0100 Subject: [PATCH] Create README.md Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com> --- scikit-learn/pca/README.md | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 scikit-learn/pca/README.md diff --git a/scikit-learn/pca/README.md b/scikit-learn/pca/README.md new file mode 100644 index 0000000..cd51062 --- /dev/null +++ b/scikit-learn/pca/README.md @@ -0,0 +1,42 @@ +# PCA +{:.no_toc} + + + +## The goal + + +Questions to [David Rotermund](mailto:davrot@uni-bremen.de) + +```python +import numpy as np +import matplotlib.pyplot as plt + +rng = np.random.default_rng(1) + +a_x = rng.normal(0.0, 1.0, size=(5000))[:, np.newaxis] +a_y = rng.normal(0.0, 1.0, size=(5000))[:, np.newaxis] ** 3 +data_a = np.concatenate((a_x, a_y), axis=1) + +b_x = rng.normal(0.0, 1.0, size=(5000))[:, np.newaxis] ** 3 +b_y = rng.normal(0.0, 1.0, size=(5000))[:, np.newaxis] +data_b = np.concatenate((b_x, b_y), axis=1) + +data = np.concatenate((data_a, data_b), axis=0) + +angle = -0.3 + +roation_matrix = np.array( + [[np.cos(angle), -np.sin(angle)], [np.sin(angle), np.cos(angle)]] +) +data_r = data @ roation_matrix + +plt.plot(data[:, 0], data[:, 1], "b.") +plt.plot(data_r[:, 0], data_r[:, 1], "r.") +``` + +![image0](image0.png) +