diff --git a/22-06-09-PCA/code.ipynb b/22-06-09-PCA/code.ipynb
new file mode 100644
index 0000000..9772e32
--- /dev/null
+++ b/22-06-09-PCA/code.ipynb
@@ -0,0 +1,1268 @@
+{
+ "nbformat": 4,
+ "nbformat_minor": 0,
+ "metadata": {
+ "colab": {
+ "name": "April PCA.ipynb",
+ "provenance": [],
+ "authorship_tag": "ABX9TyPxwXIudwOoac7pfXlTlaLi",
+ "include_colab_link": true
+ },
+ "kernelspec": {
+ "name": "python3",
+ "display_name": "Python 3"
+ },
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "view-in-github",
+ "colab_type": "text"
+ },
+ "source": [
+ ""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "id": "NbcIoYBbe6m0"
+ },
+ "outputs": [],
+ "source": [
+ "from sklearn.datasets import load_breast_cancer\n",
+ "import matplotlib.pyplot as plt\n",
+ "import pandas as pd\n",
+ "import numpy as np"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "cancer = load_breast_cancer()\n",
+ "cancer.keys()"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "oS454e4sfAA_",
+ "outputId": "dfd77c05-e48e-4d04-e09a-8937ef7dfd9b"
+ },
+ "execution_count": 2,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "dict_keys(['data', 'target', 'frame', 'target_names', 'DESCR', 'feature_names', 'filename', 'data_module'])"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 2
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "print(cancer.DESCR)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "Iro6FZawfUzw",
+ "outputId": "2d38595b-f2ae-4336-d3d5-e21368ef8975"
+ },
+ "execution_count": 3,
+ "outputs": [
+ {
+ "output_type": "stream",
+ "name": "stdout",
+ "text": [
+ ".. _breast_cancer_dataset:\n",
+ "\n",
+ "Breast cancer wisconsin (diagnostic) dataset\n",
+ "--------------------------------------------\n",
+ "\n",
+ "**Data Set Characteristics:**\n",
+ "\n",
+ " :Number of Instances: 569\n",
+ "\n",
+ " :Number of Attributes: 30 numeric, predictive attributes and the class\n",
+ "\n",
+ " :Attribute Information:\n",
+ " - radius (mean of distances from center to points on the perimeter)\n",
+ " - texture (standard deviation of gray-scale values)\n",
+ " - perimeter\n",
+ " - area\n",
+ " - smoothness (local variation in radius lengths)\n",
+ " - compactness (perimeter^2 / area - 1.0)\n",
+ " - concavity (severity of concave portions of the contour)\n",
+ " - concave points (number of concave portions of the contour)\n",
+ " - symmetry\n",
+ " - fractal dimension (\"coastline approximation\" - 1)\n",
+ "\n",
+ " The mean, standard error, and \"worst\" or largest (mean of the three\n",
+ " worst/largest values) of these features were computed for each image,\n",
+ " resulting in 30 features. For instance, field 0 is Mean Radius, field\n",
+ " 10 is Radius SE, field 20 is Worst Radius.\n",
+ "\n",
+ " - class:\n",
+ " - WDBC-Malignant\n",
+ " - WDBC-Benign\n",
+ "\n",
+ " :Summary Statistics:\n",
+ "\n",
+ " ===================================== ====== ======\n",
+ " Min Max\n",
+ " ===================================== ====== ======\n",
+ " radius (mean): 6.981 28.11\n",
+ " texture (mean): 9.71 39.28\n",
+ " perimeter (mean): 43.79 188.5\n",
+ " area (mean): 143.5 2501.0\n",
+ " smoothness (mean): 0.053 0.163\n",
+ " compactness (mean): 0.019 0.345\n",
+ " concavity (mean): 0.0 0.427\n",
+ " concave points (mean): 0.0 0.201\n",
+ " symmetry (mean): 0.106 0.304\n",
+ " fractal dimension (mean): 0.05 0.097\n",
+ " radius (standard error): 0.112 2.873\n",
+ " texture (standard error): 0.36 4.885\n",
+ " perimeter (standard error): 0.757 21.98\n",
+ " area (standard error): 6.802 542.2\n",
+ " smoothness (standard error): 0.002 0.031\n",
+ " compactness (standard error): 0.002 0.135\n",
+ " concavity (standard error): 0.0 0.396\n",
+ " concave points (standard error): 0.0 0.053\n",
+ " symmetry (standard error): 0.008 0.079\n",
+ " fractal dimension (standard error): 0.001 0.03\n",
+ " radius (worst): 7.93 36.04\n",
+ " texture (worst): 12.02 49.54\n",
+ " perimeter (worst): 50.41 251.2\n",
+ " area (worst): 185.2 4254.0\n",
+ " smoothness (worst): 0.071 0.223\n",
+ " compactness (worst): 0.027 1.058\n",
+ " concavity (worst): 0.0 1.252\n",
+ " concave points (worst): 0.0 0.291\n",
+ " symmetry (worst): 0.156 0.664\n",
+ " fractal dimension (worst): 0.055 0.208\n",
+ " ===================================== ====== ======\n",
+ "\n",
+ " :Missing Attribute Values: None\n",
+ "\n",
+ " :Class Distribution: 212 - Malignant, 357 - Benign\n",
+ "\n",
+ " :Creator: Dr. William H. Wolberg, W. Nick Street, Olvi L. Mangasarian\n",
+ "\n",
+ " :Donor: Nick Street\n",
+ "\n",
+ " :Date: November, 1995\n",
+ "\n",
+ "This is a copy of UCI ML Breast Cancer Wisconsin (Diagnostic) datasets.\n",
+ "https://goo.gl/U2Uwz2\n",
+ "\n",
+ "Features are computed from a digitized image of a fine needle\n",
+ "aspirate (FNA) of a breast mass. They describe\n",
+ "characteristics of the cell nuclei present in the image.\n",
+ "\n",
+ "Separating plane described above was obtained using\n",
+ "Multisurface Method-Tree (MSM-T) [K. P. Bennett, \"Decision Tree\n",
+ "Construction Via Linear Programming.\" Proceedings of the 4th\n",
+ "Midwest Artificial Intelligence and Cognitive Science Society,\n",
+ "pp. 97-101, 1992], a classification method which uses linear\n",
+ "programming to construct a decision tree. Relevant features\n",
+ "were selected using an exhaustive search in the space of 1-4\n",
+ "features and 1-3 separating planes.\n",
+ "\n",
+ "The actual linear program used to obtain the separating plane\n",
+ "in the 3-dimensional space is that described in:\n",
+ "[K. P. Bennett and O. L. Mangasarian: \"Robust Linear\n",
+ "Programming Discrimination of Two Linearly Inseparable Sets\",\n",
+ "Optimization Methods and Software 1, 1992, 23-34].\n",
+ "\n",
+ "This database is also available through the UW CS ftp server:\n",
+ "\n",
+ "ftp ftp.cs.wisc.edu\n",
+ "cd math-prog/cpo-dataset/machine-learn/WDBC/\n",
+ "\n",
+ ".. topic:: References\n",
+ "\n",
+ " - W.N. Street, W.H. Wolberg and O.L. Mangasarian. Nuclear feature extraction \n",
+ " for breast tumor diagnosis. IS&T/SPIE 1993 International Symposium on \n",
+ " Electronic Imaging: Science and Technology, volume 1905, pages 861-870,\n",
+ " San Jose, CA, 1993.\n",
+ " - O.L. Mangasarian, W.N. Street and W.H. Wolberg. Breast cancer diagnosis and \n",
+ " prognosis via linear programming. Operations Research, 43(4), pages 570-577, \n",
+ " July-August 1995.\n",
+ " - W.H. Wolberg, W.N. Street, and O.L. Mangasarian. Machine learning techniques\n",
+ " to diagnose breast cancer from fine-needle aspirates. Cancer Letters 77 (1994) \n",
+ " 163-171.\n"
+ ]
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "X = pd.DataFrame(cancer.data, columns=cancer.feature_names)\n",
+ "y = cancer.target"
+ ],
+ "metadata": {
+ "id": "dCBWA-vkfXN-"
+ },
+ "execution_count": 4,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "X"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 522
+ },
+ "id": "40f2FNGcfgEi",
+ "outputId": "4ba0321b-55c7-4aff-dc25-00b341654267"
+ },
+ "execution_count": 5,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ " mean radius mean texture mean perimeter mean area mean smoothness \\\n",
+ "0 17.99 10.38 122.80 1001.0 0.11840 \n",
+ "1 20.57 17.77 132.90 1326.0 0.08474 \n",
+ "2 19.69 21.25 130.00 1203.0 0.10960 \n",
+ "3 11.42 20.38 77.58 386.1 0.14250 \n",
+ "4 20.29 14.34 135.10 1297.0 0.10030 \n",
+ ".. ... ... ... ... ... \n",
+ "564 21.56 22.39 142.00 1479.0 0.11100 \n",
+ "565 20.13 28.25 131.20 1261.0 0.09780 \n",
+ "566 16.60 28.08 108.30 858.1 0.08455 \n",
+ "567 20.60 29.33 140.10 1265.0 0.11780 \n",
+ "568 7.76 24.54 47.92 181.0 0.05263 \n",
+ "\n",
+ " mean compactness mean concavity mean concave points mean symmetry \\\n",
+ "0 0.27760 0.30010 0.14710 0.2419 \n",
+ "1 0.07864 0.08690 0.07017 0.1812 \n",
+ "2 0.15990 0.19740 0.12790 0.2069 \n",
+ "3 0.28390 0.24140 0.10520 0.2597 \n",
+ "4 0.13280 0.19800 0.10430 0.1809 \n",
+ ".. ... ... ... ... \n",
+ "564 0.11590 0.24390 0.13890 0.1726 \n",
+ "565 0.10340 0.14400 0.09791 0.1752 \n",
+ "566 0.10230 0.09251 0.05302 0.1590 \n",
+ "567 0.27700 0.35140 0.15200 0.2397 \n",
+ "568 0.04362 0.00000 0.00000 0.1587 \n",
+ "\n",
+ " mean fractal dimension ... worst radius worst texture \\\n",
+ "0 0.07871 ... 25.380 17.33 \n",
+ "1 0.05667 ... 24.990 23.41 \n",
+ "2 0.05999 ... 23.570 25.53 \n",
+ "3 0.09744 ... 14.910 26.50 \n",
+ "4 0.05883 ... 22.540 16.67 \n",
+ ".. ... ... ... ... \n",
+ "564 0.05623 ... 25.450 26.40 \n",
+ "565 0.05533 ... 23.690 38.25 \n",
+ "566 0.05648 ... 18.980 34.12 \n",
+ "567 0.07016 ... 25.740 39.42 \n",
+ "568 0.05884 ... 9.456 30.37 \n",
+ "\n",
+ " worst perimeter worst area worst smoothness worst compactness \\\n",
+ "0 184.60 2019.0 0.16220 0.66560 \n",
+ "1 158.80 1956.0 0.12380 0.18660 \n",
+ "2 152.50 1709.0 0.14440 0.42450 \n",
+ "3 98.87 567.7 0.20980 0.86630 \n",
+ "4 152.20 1575.0 0.13740 0.20500 \n",
+ ".. ... ... ... ... \n",
+ "564 166.10 2027.0 0.14100 0.21130 \n",
+ "565 155.00 1731.0 0.11660 0.19220 \n",
+ "566 126.70 1124.0 0.11390 0.30940 \n",
+ "567 184.60 1821.0 0.16500 0.86810 \n",
+ "568 59.16 268.6 0.08996 0.06444 \n",
+ "\n",
+ " worst concavity worst concave points worst symmetry \\\n",
+ "0 0.7119 0.2654 0.4601 \n",
+ "1 0.2416 0.1860 0.2750 \n",
+ "2 0.4504 0.2430 0.3613 \n",
+ "3 0.6869 0.2575 0.6638 \n",
+ "4 0.4000 0.1625 0.2364 \n",
+ ".. ... ... ... \n",
+ "564 0.4107 0.2216 0.2060 \n",
+ "565 0.3215 0.1628 0.2572 \n",
+ "566 0.3403 0.1418 0.2218 \n",
+ "567 0.9387 0.2650 0.4087 \n",
+ "568 0.0000 0.0000 0.2871 \n",
+ "\n",
+ " worst fractal dimension \n",
+ "0 0.11890 \n",
+ "1 0.08902 \n",
+ "2 0.08758 \n",
+ "3 0.17300 \n",
+ "4 0.07678 \n",
+ ".. ... \n",
+ "564 0.07115 \n",
+ "565 0.06637 \n",
+ "566 0.07820 \n",
+ "567 0.12400 \n",
+ "568 0.07039 \n",
+ "\n",
+ "[569 rows x 30 columns]"
+ ],
+ "text/html": [
+ "\n",
+ "
\n",
+ "
\n",
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " mean radius | \n",
+ " mean texture | \n",
+ " mean perimeter | \n",
+ " mean area | \n",
+ " mean smoothness | \n",
+ " mean compactness | \n",
+ " mean concavity | \n",
+ " mean concave points | \n",
+ " mean symmetry | \n",
+ " mean fractal dimension | \n",
+ " ... | \n",
+ " worst radius | \n",
+ " worst texture | \n",
+ " worst perimeter | \n",
+ " worst area | \n",
+ " worst smoothness | \n",
+ " worst compactness | \n",
+ " worst concavity | \n",
+ " worst concave points | \n",
+ " worst symmetry | \n",
+ " worst fractal dimension | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " 0 | \n",
+ " 17.99 | \n",
+ " 10.38 | \n",
+ " 122.80 | \n",
+ " 1001.0 | \n",
+ " 0.11840 | \n",
+ " 0.27760 | \n",
+ " 0.30010 | \n",
+ " 0.14710 | \n",
+ " 0.2419 | \n",
+ " 0.07871 | \n",
+ " ... | \n",
+ " 25.380 | \n",
+ " 17.33 | \n",
+ " 184.60 | \n",
+ " 2019.0 | \n",
+ " 0.16220 | \n",
+ " 0.66560 | \n",
+ " 0.7119 | \n",
+ " 0.2654 | \n",
+ " 0.4601 | \n",
+ " 0.11890 | \n",
+ "
\n",
+ " \n",
+ " 1 | \n",
+ " 20.57 | \n",
+ " 17.77 | \n",
+ " 132.90 | \n",
+ " 1326.0 | \n",
+ " 0.08474 | \n",
+ " 0.07864 | \n",
+ " 0.08690 | \n",
+ " 0.07017 | \n",
+ " 0.1812 | \n",
+ " 0.05667 | \n",
+ " ... | \n",
+ " 24.990 | \n",
+ " 23.41 | \n",
+ " 158.80 | \n",
+ " 1956.0 | \n",
+ " 0.12380 | \n",
+ " 0.18660 | \n",
+ " 0.2416 | \n",
+ " 0.1860 | \n",
+ " 0.2750 | \n",
+ " 0.08902 | \n",
+ "
\n",
+ " \n",
+ " 2 | \n",
+ " 19.69 | \n",
+ " 21.25 | \n",
+ " 130.00 | \n",
+ " 1203.0 | \n",
+ " 0.10960 | \n",
+ " 0.15990 | \n",
+ " 0.19740 | \n",
+ " 0.12790 | \n",
+ " 0.2069 | \n",
+ " 0.05999 | \n",
+ " ... | \n",
+ " 23.570 | \n",
+ " 25.53 | \n",
+ " 152.50 | \n",
+ " 1709.0 | \n",
+ " 0.14440 | \n",
+ " 0.42450 | \n",
+ " 0.4504 | \n",
+ " 0.2430 | \n",
+ " 0.3613 | \n",
+ " 0.08758 | \n",
+ "
\n",
+ " \n",
+ " 3 | \n",
+ " 11.42 | \n",
+ " 20.38 | \n",
+ " 77.58 | \n",
+ " 386.1 | \n",
+ " 0.14250 | \n",
+ " 0.28390 | \n",
+ " 0.24140 | \n",
+ " 0.10520 | \n",
+ " 0.2597 | \n",
+ " 0.09744 | \n",
+ " ... | \n",
+ " 14.910 | \n",
+ " 26.50 | \n",
+ " 98.87 | \n",
+ " 567.7 | \n",
+ " 0.20980 | \n",
+ " 0.86630 | \n",
+ " 0.6869 | \n",
+ " 0.2575 | \n",
+ " 0.6638 | \n",
+ " 0.17300 | \n",
+ "
\n",
+ " \n",
+ " 4 | \n",
+ " 20.29 | \n",
+ " 14.34 | \n",
+ " 135.10 | \n",
+ " 1297.0 | \n",
+ " 0.10030 | \n",
+ " 0.13280 | \n",
+ " 0.19800 | \n",
+ " 0.10430 | \n",
+ " 0.1809 | \n",
+ " 0.05883 | \n",
+ " ... | \n",
+ " 22.540 | \n",
+ " 16.67 | \n",
+ " 152.20 | \n",
+ " 1575.0 | \n",
+ " 0.13740 | \n",
+ " 0.20500 | \n",
+ " 0.4000 | \n",
+ " 0.1625 | \n",
+ " 0.2364 | \n",
+ " 0.07678 | \n",
+ "
\n",
+ " \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ " ... | \n",
+ "
\n",
+ " \n",
+ " 564 | \n",
+ " 21.56 | \n",
+ " 22.39 | \n",
+ " 142.00 | \n",
+ " 1479.0 | \n",
+ " 0.11100 | \n",
+ " 0.11590 | \n",
+ " 0.24390 | \n",
+ " 0.13890 | \n",
+ " 0.1726 | \n",
+ " 0.05623 | \n",
+ " ... | \n",
+ " 25.450 | \n",
+ " 26.40 | \n",
+ " 166.10 | \n",
+ " 2027.0 | \n",
+ " 0.14100 | \n",
+ " 0.21130 | \n",
+ " 0.4107 | \n",
+ " 0.2216 | \n",
+ " 0.2060 | \n",
+ " 0.07115 | \n",
+ "
\n",
+ " \n",
+ " 565 | \n",
+ " 20.13 | \n",
+ " 28.25 | \n",
+ " 131.20 | \n",
+ " 1261.0 | \n",
+ " 0.09780 | \n",
+ " 0.10340 | \n",
+ " 0.14400 | \n",
+ " 0.09791 | \n",
+ " 0.1752 | \n",
+ " 0.05533 | \n",
+ " ... | \n",
+ " 23.690 | \n",
+ " 38.25 | \n",
+ " 155.00 | \n",
+ " 1731.0 | \n",
+ " 0.11660 | \n",
+ " 0.19220 | \n",
+ " 0.3215 | \n",
+ " 0.1628 | \n",
+ " 0.2572 | \n",
+ " 0.06637 | \n",
+ "
\n",
+ " \n",
+ " 566 | \n",
+ " 16.60 | \n",
+ " 28.08 | \n",
+ " 108.30 | \n",
+ " 858.1 | \n",
+ " 0.08455 | \n",
+ " 0.10230 | \n",
+ " 0.09251 | \n",
+ " 0.05302 | \n",
+ " 0.1590 | \n",
+ " 0.05648 | \n",
+ " ... | \n",
+ " 18.980 | \n",
+ " 34.12 | \n",
+ " 126.70 | \n",
+ " 1124.0 | \n",
+ " 0.11390 | \n",
+ " 0.30940 | \n",
+ " 0.3403 | \n",
+ " 0.1418 | \n",
+ " 0.2218 | \n",
+ " 0.07820 | \n",
+ "
\n",
+ " \n",
+ " 567 | \n",
+ " 20.60 | \n",
+ " 29.33 | \n",
+ " 140.10 | \n",
+ " 1265.0 | \n",
+ " 0.11780 | \n",
+ " 0.27700 | \n",
+ " 0.35140 | \n",
+ " 0.15200 | \n",
+ " 0.2397 | \n",
+ " 0.07016 | \n",
+ " ... | \n",
+ " 25.740 | \n",
+ " 39.42 | \n",
+ " 184.60 | \n",
+ " 1821.0 | \n",
+ " 0.16500 | \n",
+ " 0.86810 | \n",
+ " 0.9387 | \n",
+ " 0.2650 | \n",
+ " 0.4087 | \n",
+ " 0.12400 | \n",
+ "
\n",
+ " \n",
+ " 568 | \n",
+ " 7.76 | \n",
+ " 24.54 | \n",
+ " 47.92 | \n",
+ " 181.0 | \n",
+ " 0.05263 | \n",
+ " 0.04362 | \n",
+ " 0.00000 | \n",
+ " 0.00000 | \n",
+ " 0.1587 | \n",
+ " 0.05884 | \n",
+ " ... | \n",
+ " 9.456 | \n",
+ " 30.37 | \n",
+ " 59.16 | \n",
+ " 268.6 | \n",
+ " 0.08996 | \n",
+ " 0.06444 | \n",
+ " 0.0000 | \n",
+ " 0.0000 | \n",
+ " 0.2871 | \n",
+ " 0.07039 | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
569 rows × 30 columns
\n",
+ "
\n",
+ "
\n",
+ " \n",
+ " \n",
+ "\n",
+ " \n",
+ "
\n",
+ "
\n",
+ " "
+ ]
+ },
+ "metadata": {},
+ "execution_count": 5
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "X.shape"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "tjs6dWUGfgfE",
+ "outputId": "704dec97-d84f-4b61-9b06-ab133c305da9"
+ },
+ "execution_count": 6,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "(569, 30)"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 6
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "from sklearn.preprocessing import StandardScaler\n",
+ "\n",
+ "scaled = StandardScaler().fit_transform(X)"
+ ],
+ "metadata": {
+ "id": "lzI1KvNRfmnC"
+ },
+ "execution_count": 7,
+ "outputs": []
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "# Co-Variance Matrix\n",
+ "\n",
+ "cov_mat = np.matmul(scaled.T, scaled)\n",
+ "cov_mat.shape"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "6RykrBR6gLBK",
+ "outputId": "fa0c4079-4729-4390-e978-4711e69c042f"
+ },
+ "execution_count": 8,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "(30, 30)"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 8
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "# Eigen Value\n",
+ "# Eigen Vector\n",
+ "\n",
+ "values, vectors = np.linalg.eig(cov_mat)\n",
+ "\n",
+ "values.shape, vectors.shape"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "1stFD43ngNgb",
+ "outputId": "5847c3aa-b5d3-403b-d62d-adbc74f5318e"
+ },
+ "execution_count": 9,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "((30,), (30, 30))"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 9
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "np.round(values, 1)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "9FY_uFSVhBq0",
+ "outputId": "34afa57c-cbe7-407d-f455-a4441bff8620"
+ },
+ "execution_count": 14,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "array([7.5572e+03, 3.2384e+03, 1.6034e+03, 1.1270e+03, 9.3810e+02,\n",
+ " 6.8700e+02, 3.8420e+02, 2.7120e+02, 2.3720e+02, 1.9950e+02,\n",
+ " 1.6720e+02, 1.4860e+02, 1.3730e+02, 8.9300e+01, 5.3600e+01,\n",
+ " 4.5400e+01, 3.3800e+01, 2.9900e+01, 2.8200e+01, 1.0000e-01,\n",
+ " 4.0000e-01, 9.0000e-01, 3.9000e+00, 4.7000e+00, 8.8000e+00,\n",
+ " 1.0300e+01, 1.3800e+01, 1.5600e+01, 1.7700e+01, 1.7100e+01])"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 14
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "# prefix sum\n",
+ "\n",
+ "np.round(np.cumsum(values) / values.sum(), 3)"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/"
+ },
+ "id": "aFTWOePHgadw",
+ "outputId": "5747dfb4-e078-47f7-ebe5-410d4183f3e8"
+ },
+ "execution_count": 20,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "array([0.443, 0.632, 0.726, 0.792, 0.847, 0.888, 0.91 , 0.926, 0.94 ,\n",
+ " 0.952, 0.961, 0.97 , 0.978, 0.983, 0.986, 0.989, 0.991, 0.993,\n",
+ " 0.995, 0.995, 0.995, 0.995, 0.995, 0.995, 0.996, 0.996, 0.997,\n",
+ " 0.998, 0.999, 1. ])"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 20
+ }
+ ]
+ },
+ {
+ "cell_type": "code",
+ "source": [
+ "plt.plot(np.cumsum(values) * 100 / values.sum())"
+ ],
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 282
+ },
+ "id": "lX6gceOZghaq",
+ "outputId": "a0c1b783-8f6f-4d6c-c880-40a22fec4238"
+ },
+ "execution_count": 21,
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "[]"
+ ]
+ },
+ "metadata": {},
+ "execution_count": 21
+ },
+ {
+ "output_type": "display_data",
+ "data": {
+ "text/plain": [
+ "