{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-03-14T20:02:35.700081Z","iopub.execute_input":"2022-03-14T20:02:35.700579Z","iopub.status.idle":"2022-03-14T20:02:35.730408Z","shell.execute_reply.started":"2022-03-14T20:02:35.700460Z","shell.execute_reply":"2022-03-14T20:02:35.729597Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.read_csv('/kaggle/input/digit-recognizer/train.csv')","metadata":{"execution":{"iopub.status.busy":"2022-03-14T18:37:57.008002Z","iopub.execute_input":"2022-03-14T18:37:57.00832Z","iopub.status.idle":"2022-03-14T18:38:00.190884Z","shell.execute_reply.started":"2022-03-14T18:37:57.008273Z","shell.execute_reply":"2022-03-14T18:38:00.189806Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2022-03-14T18:38:01.163061Z","iopub.execute_input":"2022-03-14T18:38:01.163363Z","iopub.status.idle":"2022-03-14T18:38:01.189619Z","shell.execute_reply.started":"2022-03-14T18:38:01.163331Z","shell.execute_reply":"2022-03-14T18:38:01.18897Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.shape","metadata":{"execution":{"iopub.status.busy":"2022-03-14T18:38:12.369025Z","iopub.execute_input":"2022-03-14T18:38:12.369549Z","iopub.status.idle":"2022-03-14T18:38:12.375147Z","shell.execute_reply.started":"2022-03-14T18:38:12.369514Z","shell.execute_reply":"2022-03-14T18:38:12.374252Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.sample(5)","metadata":{"execution":{"iopub.status.busy":"2022-03-14T18:38:14.47219Z","iopub.execute_input":"2022-03-14T18:38:14.472478Z","iopub.status.idle":"2022-03-14T18:38:14.490749Z","shell.execute_reply.started":"2022-03-14T18:38:14.472442Z","shell.execute_reply":"2022-03-14T18:38:14.489947Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt","metadata":{"execution":{"iopub.status.busy":"2022-03-14T18:38:22.997874Z","iopub.execute_input":"2022-03-14T18:38:22.998424Z","iopub.status.idle":"2022-03-14T18:38:23.003172Z","shell.execute_reply.started":"2022-03-14T18:38:22.998389Z","shell.execute_reply":"2022-03-14T18:38:23.00225Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.imshow(df.iloc[27794, 1:].values.reshape(28,28))\n","metadata":{"execution":{"iopub.status.busy":"2022-03-14T18:38:25.916412Z","iopub.execute_input":"2022-03-14T18:38:25.916702Z","iopub.status.idle":"2022-03-14T18:38:26.147469Z","shell.execute_reply.started":"2022-03-14T18:38:25.91667Z","shell.execute_reply":"2022-03-14T18:38:26.146442Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x = df.iloc[:, 1:]\ny = df.iloc[:,0]","metadata":{"execution":{"iopub.status.busy":"2022-03-14T18:38:31.991545Z","iopub.execute_input":"2022-03-14T18:38:31.992117Z","iopub.status.idle":"2022-03-14T18:38:31.997292Z","shell.execute_reply.started":"2022-03-14T18:38:31.992068Z","shell.execute_reply":"2022-03-14T18:38:31.996694Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\nx_train, x_test, y_train, y_test = train_test_split(x, y, test_size = 0.2, random_state = 42)","metadata":{"execution":{"iopub.status.busy":"2022-03-14T18:38:34.384533Z","iopub.execute_input":"2022-03-14T18:38:34.385121Z","iopub.status.idle":"2022-03-14T18:38:35.750534Z","shell.execute_reply.started":"2022-03-14T18:38:34.385084Z","shell.execute_reply":"2022-03-14T18:38:35.749401Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train.shape","metadata":{"execution":{"iopub.status.busy":"2022-03-14T18:38:37.212728Z","iopub.execute_input":"2022-03-14T18:38:37.213438Z","iopub.status.idle":"2022-03-14T18:38:37.219603Z","shell.execute_reply.started":"2022-03-14T18:38:37.213398Z","shell.execute_reply":"2022-03-14T18:38:37.218591Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.neighbors import KNeighborsClassifier","metadata":{"execution":{"iopub.status.busy":"2022-03-14T18:38:39.274486Z","iopub.execute_input":"2022-03-14T18:38:39.274943Z","iopub.status.idle":"2022-03-14T18:38:39.420161Z","shell.execute_reply.started":"2022-03-14T18:38:39.274911Z","shell.execute_reply":"2022-03-14T18:38:39.419391Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"knn = KNeighborsClassifier()","metadata":{"execution":{"iopub.status.busy":"2022-03-14T18:38:46.117999Z","iopub.execute_input":"2022-03-14T18:38:46.118306Z","iopub.status.idle":"2022-03-14T18:38:46.122085Z","shell.execute_reply.started":"2022-03-14T18:38:46.118255Z","shell.execute_reply":"2022-03-14T18:38:46.121361Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"knn.fit(x_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-03-14T18:38:48.42231Z","iopub.execute_input":"2022-03-14T18:38:48.422595Z","iopub.status.idle":"2022-03-14T18:38:54.772445Z","shell.execute_reply.started":"2022-03-14T18:38:48.422563Z","shell.execute_reply":"2022-03-14T18:38:54.771701Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import time\nstart = time.time()\ny_pred = knn.predict(x_test)\nprint(time.time() - start)","metadata":{"execution":{"iopub.status.busy":"2022-03-14T18:39:02.562527Z","iopub.execute_input":"2022-03-14T18:39:02.562781Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import accuracy_score\naccuracy_score(y_pred, y_test)","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:21:39.149488Z","iopub.execute_input":"2022-02-28T17:21:39.149791Z","iopub.status.idle":"2022-02-28T17:21:39.159409Z","shell.execute_reply.started":"2022-02-28T17:21:39.149751Z","shell.execute_reply":"2022-02-28T17:21:39.158431Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# step 1 \nfrom sklearn.preprocessing import StandardScaler\nscaler = StandardScaler()","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:21:39.160804Z","iopub.execute_input":"2022-02-28T17:21:39.161148Z","iopub.status.idle":"2022-02-28T17:21:39.17297Z","shell.execute_reply.started":"2022-02-28T17:21:39.161108Z","shell.execute_reply":"2022-02-28T17:21:39.172298Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train = scaler.fit_transform(x_train)\nx_test = scaler.transform(x_test)","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:21:39.174802Z","iopub.execute_input":"2022-02-28T17:21:39.175404Z","iopub.status.idle":"2022-02-28T17:21:39.91645Z","shell.execute_reply.started":"2022-02-28T17:21:39.175355Z","shell.execute_reply":"2022-02-28T17:21:39.9155Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# step 2\nfrom sklearn.decomposition import PCA\npca = PCA(n_components=100)\n","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:21:39.918854Z","iopub.execute_input":"2022-02-28T17:21:39.919465Z","iopub.status.idle":"2022-02-28T17:21:39.925723Z","shell.execute_reply.started":"2022-02-28T17:21:39.919415Z","shell.execute_reply":"2022-02-28T17:21:39.924633Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train_trf = pca.fit_transform(x_train)\nx_test_trf  = pca.transform(x_test)","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:21:39.927296Z","iopub.execute_input":"2022-02-28T17:21:39.927773Z","iopub.status.idle":"2022-02-28T17:21:43.464529Z","shell.execute_reply.started":"2022-02-28T17:21:39.927728Z","shell.execute_reply":"2022-02-28T17:21:43.463612Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train_trf.shape","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:21:43.466472Z","iopub.execute_input":"2022-02-28T17:21:43.467152Z","iopub.status.idle":"2022-02-28T17:21:43.474512Z","shell.execute_reply.started":"2022-02-28T17:21:43.467105Z","shell.execute_reply":"2022-02-28T17:21:43.473425Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"knn = KNeighborsClassifier()","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:21:43.476218Z","iopub.execute_input":"2022-02-28T17:21:43.476548Z","iopub.status.idle":"2022-02-28T17:21:43.488115Z","shell.execute_reply.started":"2022-02-28T17:21:43.476505Z","shell.execute_reply":"2022-02-28T17:21:43.486978Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"knn.fit(x_train_trf, y_train)","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:21:43.490268Z","iopub.execute_input":"2022-02-28T17:21:43.490622Z","iopub.status.idle":"2022-02-28T17:21:44.148928Z","shell.execute_reply.started":"2022-02-28T17:21:43.490577Z","shell.execute_reply":"2022-02-28T17:21:44.148133Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train_trf.shape","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:21:44.150612Z","iopub.execute_input":"2022-02-28T17:21:44.150927Z","iopub.status.idle":"2022-02-28T17:21:44.157672Z","shell.execute_reply.started":"2022-02-28T17:21:44.150885Z","shell.execute_reply":"2022-02-28T17:21:44.156872Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred = knn.predict(x_test_trf)","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:21:44.15889Z","iopub.execute_input":"2022-02-28T17:21:44.159149Z","iopub.status.idle":"2022-02-28T17:23:15.060316Z","shell.execute_reply.started":"2022-02-28T17:21:44.159121Z","shell.execute_reply":"2022-02-28T17:23:15.05915Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"accuracy_score(y_pred, y_test)","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:23:15.062682Z","iopub.execute_input":"2022-02-28T17:23:15.062975Z","iopub.status.idle":"2022-02-28T17:23:15.07179Z","shell.execute_reply.started":"2022-02-28T17:23:15.062928Z","shell.execute_reply":"2022-02-28T17:23:15.071001Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# for i in range(1, 785):\n#     pca = PCA(n_components=i)\n    \n#     x_train_trf = pca.fit_transform(x_train)\n#     x_test_trf  = pca.transform(x_test)\n    \n#     knn = KNeighborsClassifier()\n    \n#     knn.fit(x_train_trf, y_train)\n    \n#     y_pred = knn.predict(x_test_trf)\n    \n#     print(accuracy_score(y_pred, y_test))","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:23:15.072849Z","iopub.execute_input":"2022-02-28T17:23:15.073379Z","iopub.status.idle":"2022-02-28T17:23:15.085634Z","shell.execute_reply.started":"2022-02-28T17:23:15.073342Z","shell.execute_reply":"2022-02-28T17:23:15.084598Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# 2nd part PCA for visualization.\npca = PCA(n_components=2)\n\nx_train_trf = pca.fit_transform(x_train)\nx_test_trf  = pca.transform(x_test)","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:23:15.087295Z","iopub.execute_input":"2022-02-28T17:23:15.088085Z","iopub.status.idle":"2022-02-28T17:23:17.824253Z","shell.execute_reply.started":"2022-02-28T17:23:15.088037Z","shell.execute_reply":"2022-02-28T17:23:17.823428Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train_trf.shape","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:23:17.831482Z","iopub.execute_input":"2022-02-28T17:23:17.83202Z","iopub.status.idle":"2022-02-28T17:23:17.844098Z","shell.execute_reply.started":"2022-02-28T17:23:17.831964Z","shell.execute_reply":"2022-02-28T17:23:17.8425Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train_trf","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:23:17.848955Z","iopub.execute_input":"2022-02-28T17:23:17.849316Z","iopub.status.idle":"2022-02-28T17:23:17.858508Z","shell.execute_reply.started":"2022-02-28T17:23:17.849271Z","shell.execute_reply":"2022-02-28T17:23:17.857542Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import plotly.express as px\ny_train_trf = y_train.astype(str)\nfig = px.scatter(x = x_train_trf[:, 0],\n                 y = x_train_trf[:, 1],\n                 color = y_train_trf,\n                 color_discrete_sequence = px.colors.qualitative.G10\n                )\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:23:17.86052Z","iopub.execute_input":"2022-02-28T17:23:17.861438Z","iopub.status.idle":"2022-02-28T17:23:20.746468Z","shell.execute_reply.started":"2022-02-28T17:23:17.861389Z","shell.execute_reply":"2022-02-28T17:23:20.745656Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# pca with 3 components\npca = PCA(n_components=3)\n\nx_train_trf = pca.fit_transform(x_train)\nx_test_trf  = pca.transform(x_test)","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:23:20.74786Z","iopub.execute_input":"2022-02-28T17:23:20.748276Z","iopub.status.idle":"2022-02-28T17:23:23.396854Z","shell.execute_reply.started":"2022-02-28T17:23:20.748244Z","shell.execute_reply":"2022-02-28T17:23:23.395611Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train_trf.shape","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:23:23.398682Z","iopub.execute_input":"2022-02-28T17:23:23.399059Z","iopub.status.idle":"2022-02-28T17:23:23.40701Z","shell.execute_reply.started":"2022-02-28T17:23:23.399012Z","shell.execute_reply":"2022-02-28T17:23:23.406002Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train_trf","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:23:23.408526Z","iopub.execute_input":"2022-02-28T17:23:23.408955Z","iopub.status.idle":"2022-02-28T17:23:23.424895Z","shell.execute_reply.started":"2022-02-28T17:23:23.408892Z","shell.execute_reply":"2022-02-28T17:23:23.423955Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import plotly.express as px\ny_train_trf = y_train.astype(str)\nfig = px.scatter_3d(df, x = x_train_trf[:, 0],\n                 y = x_train_trf[:, 1],\n                 z = x_train_trf[:, 2],\n                 color = y_train_trf,\n                 color_discrete_sequence = px.colors.qualitative.G10\n                )\nfig.show()","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:23:23.428274Z","iopub.execute_input":"2022-02-28T17:23:23.431679Z","iopub.status.idle":"2022-02-28T17:23:23.901204Z","shell.execute_reply.started":"2022-02-28T17:23:23.431614Z","shell.execute_reply":"2022-02-28T17:23:23.900254Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# attributes of pca \n# 1. eigen values\npca.explained_variance_","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:23:23.9027Z","iopub.execute_input":"2022-02-28T17:23:23.903111Z","iopub.status.idle":"2022-02-28T17:23:23.908722Z","shell.execute_reply.started":"2022-02-28T17:23:23.903067Z","shell.execute_reply":"2022-02-28T17:23:23.907898Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# 2.eigen vectors\npca.components_","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:23:23.910079Z","iopub.execute_input":"2022-02-28T17:23:23.910307Z","iopub.status.idle":"2022-02-28T17:23:23.920549Z","shell.execute_reply.started":"2022-02-28T17:23:23.910278Z","shell.execute_reply":"2022-02-28T17:23:23.919758Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pca.components_.shape","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:23:23.921676Z","iopub.execute_input":"2022-02-28T17:23:23.922013Z","iopub.status.idle":"2022-02-28T17:23:23.931633Z","shell.execute_reply.started":"2022-02-28T17:23:23.921969Z","shell.execute_reply":"2022-02-28T17:23:23.930875Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# 3. expalined ratio\npca.explained_variance_ratio_","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:23:23.932553Z","iopub.execute_input":"2022-02-28T17:23:23.932797Z","iopub.status.idle":"2022-02-28T17:23:23.943383Z","shell.execute_reply.started":"2022-02-28T17:23:23.932768Z","shell.execute_reply":"2022-02-28T17:23:23.942561Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# pca with none components.\npca = PCA(n_components=None)\n\nx_train_trf = pca.fit_transform(x_train)\nx_test_trf  = pca.transform(x_test)","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:23:23.944473Z","iopub.execute_input":"2022-02-28T17:23:23.944712Z","iopub.status.idle":"2022-02-28T17:23:28.543384Z","shell.execute_reply.started":"2022-02-28T17:23:23.944668Z","shell.execute_reply":"2022-02-28T17:23:28.542287Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train_trf.shape","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:23:28.545178Z","iopub.execute_input":"2022-02-28T17:23:28.545775Z","iopub.status.idle":"2022-02-28T17:23:28.553354Z","shell.execute_reply.started":"2022-02-28T17:23:28.54572Z","shell.execute_reply":"2022-02-28T17:23:28.552409Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pca.explained_variance_.shape","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:23:28.555328Z","iopub.execute_input":"2022-02-28T17:23:28.556015Z","iopub.status.idle":"2022-02-28T17:23:28.568816Z","shell.execute_reply.started":"2022-02-28T17:23:28.555956Z","shell.execute_reply":"2022-02-28T17:23:28.567813Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pca.components_.shape","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:23:28.570805Z","iopub.execute_input":"2022-02-28T17:23:28.57168Z","iopub.status.idle":"2022-02-28T17:23:28.582318Z","shell.execute_reply.started":"2022-02-28T17:23:28.571622Z","shell.execute_reply":"2022-02-28T17:23:28.581373Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pca.explained_variance_ratio_","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:23:28.584343Z","iopub.execute_input":"2022-02-28T17:23:28.585096Z","iopub.status.idle":"2022-02-28T17:23:28.622411Z","shell.execute_reply.started":"2022-02-28T17:23:28.585039Z","shell.execute_reply":"2022-02-28T17:23:28.621385Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"np.cumsum(pca.explained_variance_ratio_)","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:23:28.628399Z","iopub.execute_input":"2022-02-28T17:23:28.631476Z","iopub.status.idle":"2022-02-28T17:23:28.662408Z","shell.execute_reply.started":"2022-02-28T17:23:28.631404Z","shell.execute_reply":"2022-02-28T17:23:28.661379Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(np.cumsum(pca.explained_variance_ratio_))","metadata":{"execution":{"iopub.status.busy":"2022-02-28T17:23:28.664115Z","iopub.execute_input":"2022-02-28T17:23:28.664726Z","iopub.status.idle":"2022-02-28T17:23:28.870918Z","shell.execute_reply.started":"2022-02-28T17:23:28.664658Z","shell.execute_reply":"2022-02-28T17:23:28.870024Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}