From 5d2215c06c8a477c61194f16426b34dee213e558 Mon Sep 17 00:00:00 2001 From: Orrm23 <burhanusuf7@gmail.com> Date: Tue, 25 Feb 2025 23:06:19 -0800 Subject: [PATCH] apriori --- Untitled13.ipynb | 730 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 730 insertions(+) create mode 100644 Untitled13.ipynb diff --git a/Untitled13.ipynb b/Untitled13.ipynb new file mode 100644 index 0000000..e8defb0 --- /dev/null +++ b/Untitled13.ipynb @@ -0,0 +1,730 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [], + "authorship_tag": "ABX9TyMJAMTJ2UxcPpBAc/ntokzp", + "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": [ + "<a href=\"https://colab.research.google.com/github/Orrm23/DeepSeek-Coder/blob/main/Untitled13.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "iU_l3SQ9A65p" + }, + "outputs": [], + "source": [] + }, + { + "source": [ + "#23_MarketBasketAnalysisusingAPIRIORI\n", + "### Importing the basic libraries\n", + "import numpy as np\n", + "import pandas as pd\n", + "import matplotlib.pyplot as plt\n", + "### Load Dataset from Local Directory\n", + "from google.colab import files\n", + "uploaded = files.upload()\n", + "### Importing the dataset\n", + "dataset = pd.read_csv('dataset.csv')\n", + "print(dataset.shape)\n", + "print(dataset.head(5))\n", + "### Data Pre-Processing using vectorized operations\n", + "# Extract the relevant columns (assuming first 20)\n", + "transactions_df = dataset.iloc[:, :20]\n", + "# Convert all values to strings\n", + "transactions_df = transactions_df.astype(str)\n", + "# Convert DataFrame to list of lists\n", + "transactions = transactions_df.values.tolist()\n", + "### Training APRIORI\n", + "!pip install apyori\n", + "from apyori import apriori\n", + "rules = apriori(transactions = transactions, min_support = 0.003, min_confidence = 0.2, min_lift = 3, min_length = 2, max_length = 2)\n", + "### Result\n", + "results = list(rules)\n", + "results\n", + "### Results in Dataframe\n", + "lhs = [tuple(result[2][0][0])[0] for result in results]\n", + "rhs = [tuple(result[2][0][1])[0] for result in results]\n", + "supports = [result[1] for result in results]\n", + "confidences = [result[2][0][2] for result in results]\n", + "lifts = [result[2][0][3] for result in results]\n", + "resultsinDataFrame = pd.DataFrame(zip(lhs, rhs, supports, confidences, lifts), columns = ['Left Hand Side', 'Right Hand Side', 'Support', 'Confidence', 'Lift'])\n", + "resultsinDataFrame" + ], + "cell_type": "code", + "metadata": { + "id": "lFqrYPxIAk31", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 1291 + }, + "outputId": "dfb99183-e856-45ba-8a3d-9d4e58d67a90" + }, + "execution_count": 1, + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/plain": [ + "<IPython.core.display.HTML object>" + ], + "text/html": [ + "\n", + " <input type=\"file\" id=\"files-cd4b8c1e-81ca-47e9-afff-0523698ccd96\" name=\"files[]\" multiple disabled\n", + " style=\"border:none\" />\n", + " <output id=\"result-cd4b8c1e-81ca-47e9-afff-0523698ccd96\">\n", + " Upload widget is only available when the cell has been executed in the\n", + " current browser session. Please rerun this cell to enable.\n", + " </output>\n", + " <script>// Copyright 2017 Google LLC\n", + "//\n", + "// Licensed under the Apache License, Version 2.0 (the \"License\");\n", + "// you may not use this file except in compliance with the License.\n", + "// You may obtain a copy of the License at\n", + "//\n", + "// http://www.apache.org/licenses/LICENSE-2.0\n", + "//\n", + "// Unless required by applicable law or agreed to in writing, software\n", + "// distributed under the License is distributed on an \"AS IS\" BASIS,\n", + "// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n", + "// See the License for the specific language governing permissions and\n", + "// limitations under the License.\n", + "\n", + "/**\n", + " * @fileoverview Helpers for google.colab Python module.\n", + " */\n", + "(function(scope) {\n", + "function span(text, styleAttributes = {}) {\n", + " const element = document.createElement('span');\n", + " element.textContent = text;\n", + " for (const key of Object.keys(styleAttributes)) {\n", + " element.style[key] = styleAttributes[key];\n", + " }\n", + " return element;\n", + "}\n", + "\n", + "// Max number of bytes which will be uploaded at a time.\n", + "const MAX_PAYLOAD_SIZE = 100 * 1024;\n", + "\n", + "function _uploadFiles(inputId, outputId) {\n", + " const steps = uploadFilesStep(inputId, outputId);\n", + " const outputElement = document.getElementById(outputId);\n", + " // Cache steps on the outputElement to make it available for the next call\n", + " // to uploadFilesContinue from Python.\n", + " outputElement.steps = steps;\n", + "\n", + " return _uploadFilesContinue(outputId);\n", + "}\n", + "\n", + "// This is roughly an async generator (not supported in the browser yet),\n", + "// where there are multiple asynchronous steps and the Python side is going\n", + "// to poll for completion of each step.\n", + "// This uses a Promise to block the python side on completion of each step,\n", + "// then passes the result of the previous step as the input to the next step.\n", + "function _uploadFilesContinue(outputId) {\n", + " const outputElement = document.getElementById(outputId);\n", + " const steps = outputElement.steps;\n", + "\n", + " const next = steps.next(outputElement.lastPromiseValue);\n", + " return Promise.resolve(next.value.promise).then((value) => {\n", + " // Cache the last promise value to make it available to the next\n", + " // step of the generator.\n", + " outputElement.lastPromiseValue = value;\n", + " return next.value.response;\n", + " });\n", + "}\n", + "\n", + "/**\n", + " * Generator function which is called between each async step of the upload\n", + " * process.\n", + " * @param {string} inputId Element ID of the input file picker element.\n", + " * @param {string} outputId Element ID of the output display.\n", + " * @return {!Iterable<!Object>} Iterable of next steps.\n", + " */\n", + "function* uploadFilesStep(inputId, outputId) {\n", + " const inputElement = document.getElementById(inputId);\n", + " inputElement.disabled = false;\n", + "\n", + " const outputElement = document.getElementById(outputId);\n", + " outputElement.innerHTML = '';\n", + "\n", + " const pickedPromise = new Promise((resolve) => {\n", + " inputElement.addEventListener('change', (e) => {\n", + " resolve(e.target.files);\n", + " });\n", + " });\n", + "\n", + " const cancel = document.createElement('button');\n", + " inputElement.parentElement.appendChild(cancel);\n", + " cancel.textContent = 'Cancel upload';\n", + " const cancelPromise = new Promise((resolve) => {\n", + " cancel.onclick = () => {\n", + " resolve(null);\n", + " };\n", + " });\n", + "\n", + " // Wait for the user to pick the files.\n", + " const files = yield {\n", + " promise: Promise.race([pickedPromise, cancelPromise]),\n", + " response: {\n", + " action: 'starting',\n", + " }\n", + " };\n", + "\n", + " cancel.remove();\n", + "\n", + " // Disable the input element since further picks are not allowed.\n", + " inputElement.disabled = true;\n", + "\n", + " if (!files) {\n", + " return {\n", + " response: {\n", + " action: 'complete',\n", + " }\n", + " };\n", + " }\n", + "\n", + " for (const file of files) {\n", + " const li = document.createElement('li');\n", + " li.append(span(file.name, {fontWeight: 'bold'}));\n", + " li.append(span(\n", + " `(${file.type || 'n/a'}) - ${file.size} bytes, ` +\n", + " `last modified: ${\n", + " file.lastModifiedDate ? file.lastModifiedDate.toLocaleDateString() :\n", + " 'n/a'} - `));\n", + " const percent = span('0% done');\n", + " li.appendChild(percent);\n", + "\n", + " outputElement.appendChild(li);\n", + "\n", + " const fileDataPromise = new Promise((resolve) => {\n", + " const reader = new FileReader();\n", + " reader.onload = (e) => {\n", + " resolve(e.target.result);\n", + " };\n", + " reader.readAsArrayBuffer(file);\n", + " });\n", + " // Wait for the data to be ready.\n", + " let fileData = yield {\n", + " promise: fileDataPromise,\n", + " response: {\n", + " action: 'continue',\n", + " }\n", + " };\n", + "\n", + " // Use a chunked sending to avoid message size limits. See b/62115660.\n", + " let position = 0;\n", + " do {\n", + " const length = Math.min(fileData.byteLength - position, MAX_PAYLOAD_SIZE);\n", + " const chunk = new Uint8Array(fileData, position, length);\n", + " position += length;\n", + "\n", + " const base64 = btoa(String.fromCharCode.apply(null, chunk));\n", + " yield {\n", + " response: {\n", + " action: 'append',\n", + " file: file.name,\n", + " data: base64,\n", + " },\n", + " };\n", + "\n", + " let percentDone = fileData.byteLength === 0 ?\n", + " 100 :\n", + " Math.round((position / fileData.byteLength) * 100);\n", + " percent.textContent = `${percentDone}% done`;\n", + "\n", + " } while (position < fileData.byteLength);\n", + " }\n", + "\n", + " // All done.\n", + " yield {\n", + " response: {\n", + " action: 'complete',\n", + " }\n", + " };\n", + "}\n", + "\n", + "scope.google = scope.google || {};\n", + "scope.google.colab = scope.google.colab || {};\n", + "scope.google.colab._files = {\n", + " _uploadFiles,\n", + " _uploadFilesContinue,\n", + "};\n", + "})(self);\n", + "</script> " + ] + }, + "metadata": {} + }, + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Saving dataset.csv to dataset.csv\n", + "(7500, 20)\n", + " shrimp almonds avocado vegetables mix green grapes \\\n", + "0 burgers meatballs eggs NaN NaN \n", + "1 chutney NaN NaN NaN NaN \n", + "2 turkey avocado NaN NaN NaN \n", + "3 mineral water milk energy bar whole wheat rice green tea \n", + "4 low fat yogurt NaN NaN NaN NaN \n", + "\n", + " whole weat flour yams cottage cheese energy drink tomato juice \\\n", + "0 NaN NaN NaN NaN NaN \n", + "1 NaN NaN NaN NaN NaN \n", + "2 NaN NaN NaN NaN NaN \n", + "3 NaN NaN NaN NaN NaN \n", + "4 NaN NaN NaN NaN NaN \n", + "\n", + " low fat yogurt green tea honey salad mineral water salmon antioxydant juice \\\n", + "0 NaN NaN NaN NaN NaN NaN NaN \n", + "1 NaN NaN NaN NaN NaN NaN NaN \n", + "2 NaN NaN NaN NaN NaN NaN NaN \n", + "3 NaN NaN NaN NaN NaN NaN NaN \n", + "4 NaN NaN NaN NaN NaN NaN NaN \n", + "\n", + " frozen smoothie spinach olive oil \n", + "0 NaN NaN NaN \n", + "1 NaN NaN NaN \n", + "2 NaN NaN NaN \n", + "3 NaN NaN NaN \n", + "4 NaN NaN NaN \n", + "Collecting apyori\n", + " Downloading apyori-1.1.2.tar.gz (8.6 kB)\n", + " Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\n", + "Building wheels for collected packages: apyori\n", + " Building wheel for apyori (setup.py) ... \u001b[?25l\u001b[?25hdone\n", + " Created wheel for apyori: filename=apyori-1.1.2-py3-none-any.whl size=5954 sha256=6f460bf2d21945572fd7d1a90d9524bf5c416704c59847856c42f2fb0d60d484\n", + " Stored in directory: /root/.cache/pip/wheels/77/3d/a6/d317a6fb32be58a602b1e8c6b5d6f31f79322da554cad2a5ea\n", + "Successfully built apyori\n", + "Installing collected packages: apyori\n", + "Successfully installed apyori-1.1.2\n" + ] + }, + { + "output_type": "execute_result", + "data": { + "text/plain": [ + " Left Hand Side Right Hand Side Support Confidence Lift\n", + "0 light cream chicken 0.004533 0.290598 4.843305\n", + "1 mushroom cream sauce escalope 0.005733 0.300699 3.790327\n", + "2 pasta escalope 0.005867 0.372881 4.700185\n", + "3 fromage blanc honey 0.003333 0.245098 5.178128\n", + "4 herb & pepper ground beef 0.016000 0.323450 3.291555\n", + "5 tomato sauce ground beef 0.005333 0.377358 3.840147\n", + "6 light cream olive oil 0.003200 0.205128 3.120612\n", + "7 whole wheat pasta olive oil 0.008000 0.271493 4.130221\n", + "8 pasta shrimp 0.005067 0.322034 4.514494" + ], + "text/html": [ + "\n", + " <div id=\"df-008c783b-279a-40b9-a9e4-1b17fd994e2c\" class=\"colab-df-container\">\n", + " <div>\n", + "<style scoped>\n", + " .dataframe tbody tr th:only-of-type {\n", + " vertical-align: middle;\n", + " }\n", + "\n", + " .dataframe tbody tr th {\n", + " vertical-align: top;\n", + " }\n", + "\n", + " .dataframe thead th {\n", + " text-align: right;\n", + " }\n", + "</style>\n", + "<table border=\"1\" class=\"dataframe\">\n", + " <thead>\n", + " <tr style=\"text-align: right;\">\n", + " <th></th>\n", + " <th>Left Hand Side</th>\n", + " <th>Right Hand Side</th>\n", + " <th>Support</th>\n", + " <th>Confidence</th>\n", + " <th>Lift</th>\n", + " </tr>\n", + " </thead>\n", + " <tbody>\n", + " <tr>\n", + " <th>0</th>\n", + " <td>light cream</td>\n", + " <td>chicken</td>\n", + " <td>0.004533</td>\n", + " <td>0.290598</td>\n", + " <td>4.843305</td>\n", + " </tr>\n", + " <tr>\n", + " <th>1</th>\n", + " <td>mushroom cream sauce</td>\n", + " <td>escalope</td>\n", + " <td>0.005733</td>\n", + " <td>0.300699</td>\n", + " <td>3.790327</td>\n", + " </tr>\n", + " <tr>\n", + " <th>2</th>\n", + " <td>pasta</td>\n", + " <td>escalope</td>\n", + " <td>0.005867</td>\n", + " <td>0.372881</td>\n", + " <td>4.700185</td>\n", + " </tr>\n", + " <tr>\n", + " <th>3</th>\n", + " <td>fromage blanc</td>\n", + " <td>honey</td>\n", + " <td>0.003333</td>\n", + " <td>0.245098</td>\n", + " <td>5.178128</td>\n", + " </tr>\n", + " <tr>\n", + " <th>4</th>\n", + " <td>herb & pepper</td>\n", + " <td>ground beef</td>\n", + " <td>0.016000</td>\n", + " <td>0.323450</td>\n", + " <td>3.291555</td>\n", + " </tr>\n", + " <tr>\n", + " <th>5</th>\n", + " <td>tomato sauce</td>\n", + " <td>ground beef</td>\n", + " <td>0.005333</td>\n", + " <td>0.377358</td>\n", + " <td>3.840147</td>\n", + " </tr>\n", + " <tr>\n", + " <th>6</th>\n", + " <td>light cream</td>\n", + " <td>olive oil</td>\n", + " <td>0.003200</td>\n", + " <td>0.205128</td>\n", + " <td>3.120612</td>\n", + " </tr>\n", + " <tr>\n", + " <th>7</th>\n", + " <td>whole wheat pasta</td>\n", + " <td>olive oil</td>\n", + " <td>0.008000</td>\n", + " <td>0.271493</td>\n", + " <td>4.130221</td>\n", + " </tr>\n", + " <tr>\n", + " <th>8</th>\n", + " <td>pasta</td>\n", + " <td>shrimp</td>\n", + " <td>0.005067</td>\n", + " <td>0.322034</td>\n", + " <td>4.514494</td>\n", + " </tr>\n", + " </tbody>\n", + "</table>\n", + "</div>\n", + " <div class=\"colab-df-buttons\">\n", + "\n", + " <div class=\"colab-df-container\">\n", + " <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-008c783b-279a-40b9-a9e4-1b17fd994e2c')\"\n", + " title=\"Convert this dataframe to an interactive table.\"\n", + " style=\"display:none;\">\n", + "\n", + " <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n", + " <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n", + " </svg>\n", + " </button>\n", + "\n", + " <style>\n", + " .colab-df-container {\n", + " display:flex;\n", + " gap: 12px;\n", + " }\n", + "\n", + " .colab-df-convert {\n", + " background-color: #E8F0FE;\n", + " border: none;\n", + " border-radius: 50%;\n", + " cursor: pointer;\n", + " display: none;\n", + " fill: #1967D2;\n", + " height: 32px;\n", + " padding: 0 0 0 0;\n", + " width: 32px;\n", + " }\n", + "\n", + " .colab-df-convert:hover {\n", + " background-color: #E2EBFA;\n", + " box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n", + " fill: #174EA6;\n", + " }\n", + "\n", + " .colab-df-buttons div {\n", + " margin-bottom: 4px;\n", + " }\n", + "\n", + " [theme=dark] .colab-df-convert {\n", + " background-color: #3B4455;\n", + " fill: #D2E3FC;\n", + " }\n", + "\n", + " [theme=dark] .colab-df-convert:hover {\n", + " background-color: #434B5C;\n", + " box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n", + " filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n", + " fill: #FFFFFF;\n", + " }\n", + " </style>\n", + "\n", + " <script>\n", + " const buttonEl =\n", + " document.querySelector('#df-008c783b-279a-40b9-a9e4-1b17fd994e2c button.colab-df-convert');\n", + " buttonEl.style.display =\n", + " google.colab.kernel.accessAllowed ? 'block' : 'none';\n", + "\n", + " async function convertToInteractive(key) {\n", + " const element = document.querySelector('#df-008c783b-279a-40b9-a9e4-1b17fd994e2c');\n", + " const dataTable =\n", + " await google.colab.kernel.invokeFunction('convertToInteractive',\n", + " [key], {});\n", + " if (!dataTable) return;\n", + "\n", + " const docLinkHtml = 'Like what you see? Visit the ' +\n", + " '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n", + " + ' to learn more about interactive tables.';\n", + " element.innerHTML = '';\n", + " dataTable['output_type'] = 'display_data';\n", + " await google.colab.output.renderOutput(dataTable, element);\n", + " const docLink = document.createElement('div');\n", + " docLink.innerHTML = docLinkHtml;\n", + " element.appendChild(docLink);\n", + " }\n", + " </script>\n", + " </div>\n", + "\n", + "\n", + "<div id=\"df-99413864-1e27-4eff-b893-b72424d2b6a1\">\n", + " <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-99413864-1e27-4eff-b893-b72424d2b6a1')\"\n", + " title=\"Suggest charts\"\n", + " style=\"display:none;\">\n", + "\n", + "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n", + " width=\"24px\">\n", + " <g>\n", + " <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n", + " </g>\n", + "</svg>\n", + " </button>\n", + "\n", + "<style>\n", + " .colab-df-quickchart {\n", + " --bg-color: #E8F0FE;\n", + " --fill-color: #1967D2;\n", + " --hover-bg-color: #E2EBFA;\n", + " --hover-fill-color: #174EA6;\n", + " --disabled-fill-color: #AAA;\n", + " --disabled-bg-color: #DDD;\n", + " }\n", + "\n", + " [theme=dark] .colab-df-quickchart {\n", + " --bg-color: #3B4455;\n", + " --fill-color: #D2E3FC;\n", + " --hover-bg-color: #434B5C;\n", + " --hover-fill-color: #FFFFFF;\n", + " --disabled-bg-color: #3B4455;\n", + " --disabled-fill-color: #666;\n", + " }\n", + "\n", + " .colab-df-quickchart {\n", + " background-color: var(--bg-color);\n", + " border: none;\n", + " border-radius: 50%;\n", + " cursor: pointer;\n", + " display: none;\n", + " fill: var(--fill-color);\n", + " height: 32px;\n", + " padding: 0;\n", + " width: 32px;\n", + " }\n", + "\n", + " .colab-df-quickchart:hover {\n", + " background-color: var(--hover-bg-color);\n", + " box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n", + " fill: var(--button-hover-fill-color);\n", + " }\n", + "\n", + " .colab-df-quickchart-complete:disabled,\n", + " .colab-df-quickchart-complete:disabled:hover {\n", + " background-color: var(--disabled-bg-color);\n", + " fill: var(--disabled-fill-color);\n", + " box-shadow: none;\n", + " }\n", + "\n", + " .colab-df-spinner {\n", + " border: 2px solid var(--fill-color);\n", + " border-color: transparent;\n", + " border-bottom-color: var(--fill-color);\n", + " animation:\n", + " spin 1s steps(1) infinite;\n", + " }\n", + "\n", + " @keyframes spin {\n", + " 0% {\n", + " border-color: transparent;\n", + " border-bottom-color: var(--fill-color);\n", + " border-left-color: var(--fill-color);\n", + " }\n", + " 20% {\n", + " border-color: transparent;\n", + " border-left-color: var(--fill-color);\n", + " border-top-color: var(--fill-color);\n", + " }\n", + " 30% {\n", + " border-color: transparent;\n", + " border-left-color: var(--fill-color);\n", + " border-top-color: var(--fill-color);\n", + " border-right-color: var(--fill-color);\n", + " }\n", + " 40% {\n", + " border-color: transparent;\n", + " border-right-color: var(--fill-color);\n", + " border-top-color: var(--fill-color);\n", + " }\n", + " 60% {\n", + " border-color: transparent;\n", + " border-right-color: var(--fill-color);\n", + " }\n", + " 80% {\n", + " border-color: transparent;\n", + " border-right-color: var(--fill-color);\n", + " border-bottom-color: var(--fill-color);\n", + " }\n", + " 90% {\n", + " border-color: transparent;\n", + " border-bottom-color: var(--fill-color);\n", + " }\n", + " }\n", + "</style>\n", + "\n", + " <script>\n", + " async function quickchart(key) {\n", + " const quickchartButtonEl =\n", + " document.querySelector('#' + key + ' button');\n", + " quickchartButtonEl.disabled = true; // To prevent multiple clicks.\n", + " quickchartButtonEl.classList.add('colab-df-spinner');\n", + " try {\n", + " const charts = await google.colab.kernel.invokeFunction(\n", + " 'suggestCharts', [key], {});\n", + " } catch (error) {\n", + " console.error('Error during call to suggestCharts:', error);\n", + " }\n", + " quickchartButtonEl.classList.remove('colab-df-spinner');\n", + " quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n", + " }\n", + " (() => {\n", + " let quickchartButtonEl =\n", + " document.querySelector('#df-99413864-1e27-4eff-b893-b72424d2b6a1 button');\n", + " quickchartButtonEl.style.display =\n", + " google.colab.kernel.accessAllowed ? 'block' : 'none';\n", + " })();\n", + " </script>\n", + "</div>\n", + "\n", + " <div id=\"id_608141c4-567b-4f50-88d6-7182c8a13969\">\n", + " <style>\n", + " .colab-df-generate {\n", + " background-color: #E8F0FE;\n", + " border: none;\n", + " border-radius: 50%;\n", + " cursor: pointer;\n", + " display: none;\n", + " fill: #1967D2;\n", + " height: 32px;\n", + " padding: 0 0 0 0;\n", + " width: 32px;\n", + " }\n", + "\n", + " .colab-df-generate:hover {\n", + " background-color: #E2EBFA;\n", + " box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n", + " fill: #174EA6;\n", + " }\n", + "\n", + " [theme=dark] .colab-df-generate {\n", + " background-color: #3B4455;\n", + " fill: #D2E3FC;\n", + " }\n", + "\n", + " [theme=dark] .colab-df-generate:hover {\n", + " background-color: #434B5C;\n", + " box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n", + " filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n", + " fill: #FFFFFF;\n", + " }\n", + " </style>\n", + " <button class=\"colab-df-generate\" onclick=\"generateWithVariable('resultsinDataFrame')\"\n", + " title=\"Generate code using this dataframe.\"\n", + " style=\"display:none;\">\n", + "\n", + " <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n", + " width=\"24px\">\n", + " <path d=\"M7,19H8.4L18.45,9,17,7.55,7,17.6ZM5,21V16.75L18.45,3.32a2,2,0,0,1,2.83,0l1.4,1.43a1.91,1.91,0,0,1,.58,1.4,1.91,1.91,0,0,1-.58,1.4L9.25,21ZM18.45,9,17,7.55Zm-12,3A5.31,5.31,0,0,0,4.9,8.1,5.31,5.31,0,0,0,1,6.5,5.31,5.31,0,0,0,4.9,4.9,5.31,5.31,0,0,0,6.5,1,5.31,5.31,0,0,0,8.1,4.9,5.31,5.31,0,0,0,12,6.5,5.46,5.46,0,0,0,6.5,12Z\"/>\n", + " </svg>\n", + " </button>\n", + " <script>\n", + " (() => {\n", + " const buttonEl =\n", + " document.querySelector('#id_608141c4-567b-4f50-88d6-7182c8a13969 button.colab-df-generate');\n", + " buttonEl.style.display =\n", + " google.colab.kernel.accessAllowed ? 'block' : 'none';\n", + "\n", + " buttonEl.onclick = () => {\n", + " google.colab.notebook.generateWithVariable('resultsinDataFrame');\n", + " }\n", + " })();\n", + " </script>\n", + " </div>\n", + "\n", + " </div>\n", + " </div>\n" + ], + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "dataframe", + "variable_name": "resultsinDataFrame", + "summary": "{\n \"name\": \"resultsinDataFrame\",\n \"rows\": 9,\n \"fields\": [\n {\n \"column\": \"Left Hand Side\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 7,\n \"samples\": [\n \"light cream\",\n \"mushroom cream sauce\",\n \"tomato sauce\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Right Hand Side\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 6,\n \"samples\": [\n \"chicken\",\n \"escalope\",\n \"shrimp\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Support\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.003896500487537852,\n \"min\": 0.0032,\n \"max\": 0.016,\n \"num_unique_values\": 9,\n \"samples\": [\n 0.008,\n 0.005733333333333333,\n 0.005333333333333333\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Confidence\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.056168653549259547,\n \"min\": 0.20512820512820515,\n \"max\": 0.37735849056603776,\n \"num_unique_values\": 9,\n \"samples\": [\n 0.2714932126696833,\n 0.30069930069930073,\n 0.37735849056603776\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Lift\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.7066844698506499,\n \"min\": 3.120611639881417,\n \"max\": 5.178127589063795,\n \"num_unique_values\": 9,\n \"samples\": [\n 4.130221288078346,\n 3.7903273197390845,\n 3.840147461662528\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}" + } + }, + "metadata": {}, + "execution_count": 1 + } + ] + }, + { + "cell_type": "code", + "source": [], + "metadata": { + "id": "rj5duez_ERkd" + }, + "execution_count": null, + "outputs": [] + } + ] +} \ No newline at end of file