{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Published on April 02, 2023. By Marília Prata, mpwolke" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19", "_kg_hide-input": true, "_kg_hide-output": true, "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5", "execution": { "iopub.execute_input": "2023-04-02T22:11:04.640536Z", "iopub.status.busy": "2023-04-02T22:11:04.640086Z", "iopub.status.idle": "2023-04-02T22:11:04.675820Z", "shell.execute_reply": "2023-04-02T22:11:04.674545Z", "shell.execute_reply.started": "2023-04-02T22:11:04.640485Z" } }, "outputs": [], "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", "\n", "import numpy as np # linear algebra\n", "import 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", "\n", "import os\n", "for 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" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "_kg_hide-output": true, "execution": { "iopub.execute_input": "2023-04-02T22:11:15.868876Z", "iopub.status.busy": "2023-04-02T22:11:15.867831Z", "iopub.status.idle": "2023-04-02T22:11:32.323625Z", "shell.execute_reply": "2023-04-02T22:11:32.322233Z", "shell.execute_reply.started": "2023-04-02T22:11:15.868817Z" } }, "outputs": [], "source": [ "!pip install -U kaleido" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "twitter.com" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "_kg_hide-output": true, "execution": { "iopub.execute_input": "2023-04-02T22:11:51.604609Z", "iopub.status.busy": "2023-04-02T22:11:51.604203Z", "iopub.status.idle": "2023-04-02T22:12:02.956664Z", "shell.execute_reply": "2023-04-02T22:12:02.955622Z", "shell.execute_reply.started": "2023-04-02T22:11:51.604572Z" } }, "outputs": [], "source": [ "!pip install yellowbrick" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "_kg_hide-output": true, "execution": { "iopub.execute_input": "2023-04-02T22:12:09.726575Z", "iopub.status.busy": "2023-04-02T22:12:09.725781Z", "iopub.status.idle": "2023-04-02T22:12:21.413987Z", "shell.execute_reply": "2023-04-02T22:12:21.412852Z", "shell.execute_reply.started": "2023-04-02T22:12:09.726527Z" } }, "outputs": [], "source": [ "!pip install Kneed" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "execution": { "iopub.execute_input": "2023-04-02T22:13:10.882723Z", "iopub.status.busy": "2023-04-02T22:13:10.882326Z", "iopub.status.idle": "2023-04-02T22:13:13.930673Z", "shell.execute_reply": "2023-04-02T22:13:13.929367Z", "shell.execute_reply.started": "2023-04-02T22:13:10.882688Z" } }, "outputs": [], "source": [ "import warnings\n", "\n", "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "import matplotlib as mpl\n", "import seaborn as sns\n", "\n", "# for visuallization\n", "import plotly.express as px\n", "# import kaleido # comment out for reproducing purposes\n", "import scipy\n", "from mpl_toolkits.mplot3d import Axes3D\n", "from yellowbrick.cluster import KElbowVisualizer\n", "# from kneed import KneeLocator\n", "\n", "# %notebook matplotlib\n", "from warnings import filterwarnings\n", "filterwarnings('ignore')" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "execution": { "iopub.execute_input": "2023-04-02T22:13:49.239975Z", "iopub.status.busy": "2023-04-02T22:13:49.238568Z", "iopub.status.idle": "2023-04-02T22:13:49.340114Z", "shell.execute_reply": "2023-04-02T22:13:49.338955Z", "shell.execute_reply.started": "2023-04-02T22:13:49.239900Z" } }, "outputs": [ { "data": { "text/html": [ "
| \n", " | matchDate | \n", "symbol | \n", "matchPri | \n", "matchQty | \n", "tolMatchQty | \n", "matchTime | \n", "bidPri1 | \n", "bidPri2 | \n", "bidPri3 | \n", "bidPri4 | \n", "... | \n", "askQty3 | \n", "askQty4 | \n", "askQty5 | \n", "openPri | \n", "highPri | \n", "lowPri | \n", "refPri | \n", "upPri | \n", "dnPri | \n", "label | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "20221220 | \n", "3711 | \n", "94.6 | \n", "216 | \n", "216 | \n", "90003845 | \n", "94.6 | \n", "94.5 | \n", "94.4 | \n", "94.3 | \n", "... | \n", "8 | \n", "13 | \n", "58 | \n", "94.6 | \n", "94.6 | \n", "94.6 | \n", "95.8 | \n", "105 | \n", "86.3 | \n", "2.0 | \n", "
| 1 | \n", "20221220 | \n", "3711 | \n", "94.6 | \n", "1 | \n", "217 | \n", "90003921 | \n", "94.7 | \n", "94.6 | \n", "94.5 | \n", "94.4 | \n", "... | \n", "1 | \n", "18 | \n", "1 | \n", "94.6 | \n", "94.6 | \n", "94.6 | \n", "95.8 | \n", "105 | \n", "86.3 | \n", "1.0 | \n", "
| 2 | \n", "20221220 | \n", "3711 | \n", "94.7 | \n", "1 | \n", "218 | \n", "90005353 | \n", "94.7 | \n", "94.6 | \n", "94.5 | \n", "94.4 | \n", "... | \n", "1 | \n", "18 | \n", "1 | \n", "94.6 | \n", "94.7 | \n", "94.6 | \n", "95.8 | \n", "105 | \n", "86.3 | \n", "2.0 | \n", "
| 3 | \n", "20221220 | \n", "3711 | \n", "94.7 | \n", "1 | \n", "219 | \n", "90005400 | \n", "94.7 | \n", "94.6 | \n", "94.5 | \n", "94.4 | \n", "... | \n", "19 | \n", "33 | \n", "18 | \n", "94.6 | \n", "94.7 | \n", "94.6 | \n", "95.8 | \n", "105 | \n", "86.3 | \n", "2.0 | \n", "
| 4 | \n", "20221220 | \n", "3711 | \n", "94.7 | \n", "15 | \n", "234 | \n", "90006605 | \n", "94.6 | \n", "94.5 | \n", "94.4 | \n", "94.3 | \n", "... | \n", "19 | \n", "33 | \n", "24 | \n", "94.6 | \n", "94.7 | \n", "94.6 | \n", "95.8 | \n", "105 | \n", "86.3 | \n", "0.0 | \n", "
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 5596 | \n", "20221220 | \n", "3711 | \n", "93.3 | \n", "1 | \n", "15240 | \n", "132456151 | \n", "93.3 | \n", "93.2 | \n", "93.1 | \n", "93.0 | \n", "... | \n", "28 | \n", "16 | \n", "32 | \n", "94.6 | \n", "95.2 | \n", "93.3 | \n", "95.8 | \n", "105 | \n", "86.3 | \n", "1.0 | \n", "
| 5597 | \n", "20221220 | \n", "3711 | \n", "93.5 | \n", "1 | \n", "15242 | \n", "132456435 | \n", "93.3 | \n", "93.2 | \n", "93.1 | \n", "93.0 | \n", "... | \n", "16 | \n", "32 | \n", "36 | \n", "94.6 | \n", "95.2 | \n", "93.3 | \n", "95.8 | \n", "105 | \n", "86.3 | \n", "0.0 | \n", "
| 5598 | \n", "20221220 | \n", "3711 | \n", "93.3 | \n", "1 | \n", "15243 | \n", "132457241 | \n", "93.3 | \n", "93.2 | \n", "93.1 | \n", "93.0 | \n", "... | \n", "16 | \n", "32 | \n", "36 | \n", "94.6 | \n", "95.2 | \n", "93.3 | \n", "95.8 | \n", "105 | \n", "86.3 | \n", "1.0 | \n", "
| 5599 | \n", "20221220 | \n", "3711 | \n", "93.5 | \n", "2 | \n", "15245 | \n", "132458268 | \n", "93.3 | \n", "93.2 | \n", "93.1 | \n", "93.0 | \n", "... | \n", "16 | \n", "32 | \n", "36 | \n", "94.6 | \n", "95.2 | \n", "93.3 | \n", "95.8 | \n", "105 | \n", "86.3 | \n", "0.0 | \n", "
| 5600 | \n", "20221220 | \n", "3711 | \n", "93.3 | \n", "1 | \n", "15246 | \n", "132458352 | \n", "93.3 | \n", "93.2 | \n", "93.1 | \n", "93.0 | \n", "... | \n", "15 | \n", "32 | \n", "36 | \n", "94.6 | \n", "95.2 | \n", "93.3 | \n", "95.8 | \n", "105 | \n", "86.3 | \n", "1.0 | \n", "
5601 rows × 33 columns
\n", "