3006 lines
127 KiB
Plaintext
3006 lines
127 KiB
Plaintext
{
|
||
"cells": [
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 4,
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/"
|
||
},
|
||
"id": "CelFOfyF9ti_",
|
||
"outputId": "ce866d46-2915-4af4-815f-99dd9720fdf3"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"output_type": "stream",
|
||
"name": "stdout",
|
||
"text": [
|
||
"Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\n",
|
||
"Collecting openai\n",
|
||
" Downloading openai-0.27.2-py3-none-any.whl (70 kB)\n",
|
||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m70.1/70.1 KB\u001b[0m \u001b[31m4.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||
"\u001b[?25hRequirement already satisfied: tqdm in /usr/local/lib/python3.9/dist-packages (from openai) (4.65.0)\n",
|
||
"Requirement already satisfied: requests>=2.20 in /usr/local/lib/python3.9/dist-packages (from openai) (2.27.1)\n",
|
||
"Collecting aiohttp\n",
|
||
" Downloading aiohttp-3.8.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB)\n",
|
||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.0/1.0 MB\u001b[0m \u001b[31m31.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||
"\u001b[?25hRequirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.9/dist-packages (from requests>=2.20->openai) (3.4)\n",
|
||
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.9/dist-packages (from requests>=2.20->openai) (2022.12.7)\n",
|
||
"Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.9/dist-packages (from requests>=2.20->openai) (2.0.12)\n",
|
||
"Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.9/dist-packages (from requests>=2.20->openai) (1.26.15)\n",
|
||
"Collecting frozenlist>=1.1.1\n",
|
||
" Downloading frozenlist-1.3.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (158 kB)\n",
|
||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m158.8/158.8 KB\u001b[0m \u001b[31m21.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||
"\u001b[?25hRequirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.9/dist-packages (from aiohttp->openai) (22.2.0)\n",
|
||
"Collecting async-timeout<5.0,>=4.0.0a3\n",
|
||
" Downloading async_timeout-4.0.2-py3-none-any.whl (5.8 kB)\n",
|
||
"Collecting multidict<7.0,>=4.5\n",
|
||
" Downloading multidict-6.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (114 kB)\n",
|
||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m114.2/114.2 KB\u001b[0m \u001b[31m14.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||
"\u001b[?25hCollecting yarl<2.0,>=1.0\n",
|
||
" Downloading yarl-1.8.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (264 kB)\n",
|
||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m264.6/264.6 KB\u001b[0m \u001b[31m29.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
|
||
"\u001b[?25hCollecting aiosignal>=1.1.2\n",
|
||
" Downloading aiosignal-1.3.1-py3-none-any.whl (7.6 kB)\n",
|
||
"Installing collected packages: multidict, frozenlist, async-timeout, yarl, aiosignal, aiohttp, openai\n",
|
||
"Successfully installed aiohttp-3.8.4 aiosignal-1.3.1 async-timeout-4.0.2 frozenlist-1.3.3 multidict-6.0.4 openai-0.27.2 yarl-1.8.2\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"!pip install openai"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 5,
|
||
"metadata": {
|
||
"id": "pP7YkLvs95Pt"
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import os\n",
|
||
"os.environ['OPENAI_API_KEY'] = \"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\""
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 6,
|
||
"metadata": {
|
||
"id": "raj54WV098Dd"
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import openai\n",
|
||
"def call(context):\n",
|
||
" try:\n",
|
||
" response = openai.Completion.create(\n",
|
||
" api_key = \"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\",\n",
|
||
" engine=\"text-davinci-003\",\n",
|
||
" prompt=context,\n",
|
||
" temperature=1,\n",
|
||
" max_tokens=900,\n",
|
||
" top_p=1,\n",
|
||
" frequency_penalty=0,\n",
|
||
" presence_penalty=0\n",
|
||
" )\n",
|
||
" return response['choices'][0]['text']\n",
|
||
" except Exception as e:\n",
|
||
" print (e)\n",
|
||
" return \"\""
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 36,
|
||
"metadata": {
|
||
"id": "XOGiyCQb-QoM"
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"data = ''' \n",
|
||
"Preference\t Red_Wine\t White_Wine\t Recommendation\n",
|
||
"Red\t Light-Bodied\t\tNone Pinot Noir\n",
|
||
"Red\t Full-Bodied\t\t None Shiraz or Zinfandel\n",
|
||
"White\t\t None Dry Sauvignon Blanc\n",
|
||
"White\t\t None None Sweet\tGewurztraminer\n",
|
||
"Red-Fruity\t None\t\t None Pinot Noir\n",
|
||
"Red-Earthy\t None\t\t None Chianti\n",
|
||
"White-Crisp\t None\t\t None Sauvignon Blanc\n",
|
||
"White-Creamy None\t\t\t None Chardonnay\n",
|
||
"Red-Spicy\t\t None\t None Shiraz or Zinfandel\n",
|
||
"Red-Rich\t\t None \t None Cabernet Sauvignon\n",
|
||
"White-Floral None\t\t\t None Gewurztraminer\n",
|
||
"White-Citrus None\t\t\t None Riesling\n",
|
||
"Red\t\t\t None None Pinot Noir\n",
|
||
"Red\t\t\t None None Chianti\n",
|
||
"White\t\t\t None None Sauvignon Blanc\n",
|
||
"White\t\t\t None None Chardonnay\n",
|
||
"Red\t\t\t None None Shiraz or Zinfandel\n",
|
||
"Red\t\t\t None None Cabernet Sauvignon\n",
|
||
"White\t\t\t None None Gewurztraminer\n",
|
||
"White\t\t\t None None Riesling\n",
|
||
"Red-Fruity\t Light-Bodied\t\tNone Pinot Noir\n",
|
||
"Red-Fruity\t Full-Bodied\t\t None Shiraz or Zinfandel\n",
|
||
"Red-Earthy\t Light-Bodied\t\tNone Pinot Noir\n",
|
||
"Red-Earthy\t Full-Bodied\t\t None Cabernet Sauvignon\n",
|
||
"White-Crisp\t Dry\t\t None Sauvignon Blanc\n",
|
||
"White-Crisp\t Sweet\t\t None Pinot Noir\n",
|
||
"White-Creamy Dry\t\t None Pinot Noir\n",
|
||
"White-Creamy Sweet\t\t None Chardonnay\n",
|
||
"Red-Spicy\t Light-Bodied\t\tNone Pinot Noir\n",
|
||
"Red-Spicy\t Full-Bodied\t\t None Shiraz or Zinfandel\n",
|
||
"Red-Rich\t Light-Bodied\t\tNone Pinot Noir\n",
|
||
"Red-Rich\t Full-Bodied\t\t None Cabernet Sauvignon\n",
|
||
"White-Floral\tDry\t\t None Pinot Noir\n",
|
||
"White-Floral\tSweet\t\t None Gewurztraminer\n",
|
||
"White-Citrus\tDry\t\t None Sauvignon Blanc\n",
|
||
"White-Citrus\tSweet\t\t None Riesling\n",
|
||
"Red-Fruity\t\tNone\t Sweet Pinot Noir\n",
|
||
"Red-Fruity\t\tNone\t Dry Pinot Noir\n",
|
||
"Red-Earthy\t\tNone\t Sweet Chianti\n",
|
||
"Red-Earthy\t\tNone\t Dry Pinot Noir\n",
|
||
"\n",
|
||
"\n",
|
||
"Based on the data generate 10 different choices and recommended based on the choices\n",
|
||
"'''\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 39,
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/"
|
||
},
|
||
"id": "NBVKb7ZOBTtg",
|
||
"outputId": "98da1540-213a-4221-c866-ca0f880aaf05"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"output_type": "stream",
|
||
"name": "stdout",
|
||
"text": [
|
||
"\n",
|
||
"1. Pinot Noir (Red-Fruity, Light-Bodied, Sweet) \n",
|
||
"2. Sauvignon Blanc (White-Crisp, Dry)\n",
|
||
"3. Chardonnay (White-Creamy, Sweet)\n",
|
||
"4. Chianti (Red-Earthy, Sweet) \n",
|
||
"5. Riesling (White-Citrus, Sweet)\n",
|
||
"6. Shiraz or Zinfandel (Red-Spicy, Full-Bodied)\n",
|
||
"7. Cabernet Sauvignon (Red-Rich, Full-Bodied)\n",
|
||
"8. Gewurztraminer (White-Floral, Sweet) \n",
|
||
"9. Pinot Noir (Red-Earthy, Light-Bodied)\n",
|
||
"10. Pinot Noir (Red-Fruity, Dry)\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"print(call(data))"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 40,
|
||
"metadata": {
|
||
"id": "hvcX7UWqBblL"
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"data1 = '''\n",
|
||
"Preference\t Red_Wine\t White_Wine\t Recommendation\n",
|
||
"Red\t Light-Bodied\t\tNone Pinot Noir\n",
|
||
"Red\t Full-Bodied\t\t None Shiraz or Zinfandel\n",
|
||
"White\t\t None Dry Sauvignon Blanc\n",
|
||
"White\t\t None None Sweet\tGewurztraminer\n",
|
||
"Red-Fruity\t None\t\t None Pinot Noir\n",
|
||
"Red-Earthy\t None\t\t None Chianti\n",
|
||
"White-Crisp\t None\t\t None Sauvignon Blanc\n",
|
||
"White-Creamy None\t\t\t None Chardonnay\n",
|
||
"Red-Spicy\t\t None\t None Shiraz or Zinfandel\n",
|
||
"Red-Rich\t\t None \t None Cabernet Sauvignon\n",
|
||
"White-Floral None\t\t\t None Gewurztraminer\n",
|
||
"White-Citrus None\t\t\t None Riesling\n",
|
||
"Red\t\t\t None None Pinot Noir\n",
|
||
"Red\t\t\t None None Chianti\n",
|
||
"White\t\t\t None None Sauvignon Blanc\n",
|
||
"White\t\t\t None None Chardonnay\n",
|
||
"Red\t\t\t None None Shiraz or Zinfandel\n",
|
||
"Red\t\t\t None None Cabernet Sauvignon\n",
|
||
"White\t\t\t None None Gewurztraminer\n",
|
||
"White\t\t\t None None Riesling\n",
|
||
"Red-Fruity\t Light-Bodied\t\tNone Pinot Noir\n",
|
||
"Red-Fruity\t Full-Bodied\t\t None Shiraz or Zinfandel\n",
|
||
"Red-Earthy\t Light-Bodied\t\tNone Pinot Noir\n",
|
||
"Red-Earthy\t Full-Bodied\t\t None Cabernet Sauvignon\n",
|
||
"White-Crisp\t Dry\t\t None Sauvignon Blanc\n",
|
||
"White-Crisp\t Sweet\t\t None Pinot Noir\n",
|
||
"White-Creamy Dry\t\t None Pinot Noir\n",
|
||
"White-Creamy Sweet\t\t None Chardonnay\n",
|
||
"Red-Spicy\t Light-Bodied\t\tNone Pinot Noir\n",
|
||
"Red-Spicy\t Full-Bodied\t\t None Shiraz or Zinfandel\n",
|
||
"Red-Rich\t Light-Bodied\t\tNone Pinot Noir\n",
|
||
"Red-Rich\t Full-Bodied\t\t None Cabernet Sauvignon\n",
|
||
"White-Floral\tDry\t\t None Pinot Noir\n",
|
||
"White-Floral\tSweet\t\t None Gewurztraminer\n",
|
||
"White-Citrus\tDry\t\t None Sauvignon Blanc\n",
|
||
"White-Citrus\tSweet\t\t None Riesling\n",
|
||
"Red-Fruity\t\tNone\t Sweet Pinot Noir\n",
|
||
"Red-Fruity\t\tNone\t Dry Pinot Noir\n",
|
||
"Red-Earthy\t\tNone\t Sweet Chianti\n",
|
||
"Red-Earthy\t\tNone\t Dry Pinot Noir\n",
|
||
"\n",
|
||
"\n",
|
||
"Customer 1: Red,Dry?\n",
|
||
"Customer 2: White?\n",
|
||
"Customer 3: White-Earthry?\n",
|
||
"Customer 4: White-Floral,Light-Bodied?\n",
|
||
"Customer 5: Red-Spicy,Dry?\n",
|
||
"Customer 6: Red-Rich,Full-Bodied?\n",
|
||
"Customer 7: White-Creamy?\n",
|
||
"Customer 8: White-Crisp,Light-Bodied?\n",
|
||
"Customer 9: White-Crisp,Full-Bodied?\n",
|
||
"Customer 10: White-Crisp,Dry?\n",
|
||
"'''\n",
|
||
"result = call(data1)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 41,
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/",
|
||
"height": 54
|
||
},
|
||
"id": "j2huyLpSByd7",
|
||
"outputId": "b97dd46c-43b4-44b3-960c-4f2250bf1e27"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"output_type": "execute_result",
|
||
"data": {
|
||
"text/plain": [
|
||
"'\\nRecommendation\\nCustomer 1: Pinot Noir\\nCustomer 2: Sauvignon Blanc\\nCustomer 3: Pinot Noir\\nCustomer 4: Pinot Noir \\nCustomer 5: Shiraz or Zinfandel\\nCustomer 6: Cabernet Sauvignon\\nCustomer 7: Chardonnay\\nCustomer 8: Sauvignon Blanc\\nCustomer 9: Pinot Noir\\nCustomer 10: Sauvignon Blanc'"
|
||
],
|
||
"application/vnd.google.colaboratory.intrinsic+json": {
|
||
"type": "string"
|
||
}
|
||
},
|
||
"metadata": {},
|
||
"execution_count": 41
|
||
}
|
||
],
|
||
"source": [
|
||
"result"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 42,
|
||
"metadata": {
|
||
"id": "WQ0o-f8ZDorN"
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import re\n",
|
||
"results = re.split('Customer |[0-9]|:|\\n|Recommendation',result)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 43,
|
||
"metadata": {
|
||
"id": "D1NJZE5zHcHE"
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"fin_res = [res for res in results if len(res)>0]"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 44,
|
||
"metadata": {
|
||
"id": "GSW3EX85DraE"
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"data = {\n",
|
||
" 'Query':['Red,Dry?','White?','White-Earthry?','White-Floral,Light-Bodied?','Red-Spicy,Dry?','Red-Rich,Full-Bodied?','White-Creamy?','White-Crisp,Light-Bodied?','White-Crisp,Full-Bodied?','White-Crisp,Dry?'],\n",
|
||
" 'Recommendation': fin_res\n",
|
||
"}"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 45,
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/"
|
||
},
|
||
"id": "fJbCVsgNHotD",
|
||
"outputId": "8f6571f8-ceba-43f0-bf2a-0e6253f903ec"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"output_type": "execute_result",
|
||
"data": {
|
||
"text/plain": [
|
||
"{'Query': ['Red,Dry?',\n",
|
||
" 'White?',\n",
|
||
" 'White-Earthry?',\n",
|
||
" 'White-Floral,Light-Bodied?',\n",
|
||
" 'Red-Spicy,Dry?',\n",
|
||
" 'Red-Rich,Full-Bodied?',\n",
|
||
" 'White-Creamy?',\n",
|
||
" 'White-Crisp,Light-Bodied?',\n",
|
||
" 'White-Crisp,Full-Bodied?',\n",
|
||
" 'White-Crisp,Dry?'],\n",
|
||
" 'Recommendation': [' Pinot Noir',\n",
|
||
" ' Sauvignon Blanc',\n",
|
||
" ' Pinot Noir',\n",
|
||
" ' Pinot Noir ',\n",
|
||
" ' Shiraz or Zinfandel',\n",
|
||
" ' Cabernet Sauvignon',\n",
|
||
" ' Chardonnay',\n",
|
||
" ' Sauvignon Blanc',\n",
|
||
" ' Pinot Noir',\n",
|
||
" ' Sauvignon Blanc']}"
|
||
]
|
||
},
|
||
"metadata": {},
|
||
"execution_count": 45
|
||
}
|
||
],
|
||
"source": [
|
||
"data"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 46,
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/",
|
||
"height": 206
|
||
},
|
||
"id": "lq1YFA-FHtmq",
|
||
"outputId": "9f2b43e9-1f61-49b0-d324-4a6dbeea6133"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"output_type": "execute_result",
|
||
"data": {
|
||
"text/plain": [
|
||
" Query Recommendation\n",
|
||
"0 Red,Dry? Pinot Noir\n",
|
||
"1 White? Sauvignon Blanc\n",
|
||
"2 White-Earthry? Pinot Noir\n",
|
||
"3 White-Floral,Light-Bodied? Pinot Noir \n",
|
||
"4 Red-Spicy,Dry? Shiraz or Zinfandel"
|
||
],
|
||
"text/html": [
|
||
"\n",
|
||
" <div id=\"df-bec9c883-0031-471d-8d7c-d9712f409ff6\">\n",
|
||
" <div 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>Query</th>\n",
|
||
" <th>Recommendation</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>Red,Dry?</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>White?</td>\n",
|
||
" <td>Sauvignon Blanc</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>White-Earthry?</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>White-Floral,Light-Bodied?</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>Red-Spicy,Dry?</td>\n",
|
||
" <td>Shiraz or Zinfandel</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>\n",
|
||
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-bec9c883-0031-471d-8d7c-d9712f409ff6')\"\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 0 24 24\"\n",
|
||
" width=\"24px\">\n",
|
||
" <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n",
|
||
" <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n",
|
||
" </svg>\n",
|
||
" </button>\n",
|
||
" \n",
|
||
" <style>\n",
|
||
" .colab-df-container {\n",
|
||
" display:flex;\n",
|
||
" flex-wrap:wrap;\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",
|
||
" [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-bec9c883-0031-471d-8d7c-d9712f409ff6 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-bec9c883-0031-471d-8d7c-d9712f409ff6');\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",
|
||
" </div>\n",
|
||
" "
|
||
]
|
||
},
|
||
"metadata": {},
|
||
"execution_count": 46
|
||
}
|
||
],
|
||
"source": [
|
||
"import pandas as pd\n",
|
||
"df = pd.DataFrame(data)\n",
|
||
"df.head()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 47,
|
||
"metadata": {
|
||
"id": "hZJksWOkH6VS"
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"data_4 = ''' \n",
|
||
"Preference\t Red_Wine\t White_Wine\t Recommendation\n",
|
||
"Red\t Light-Bodied\t\tNone Pinot Noir\n",
|
||
"Red\t Full-Bodied\t\t None Shiraz or Zinfandel\n",
|
||
"White\t\t None Dry Sauvignon Blanc\n",
|
||
"White\t\t None None Sweet\tGewurztraminer\n",
|
||
"Red-Fruity\t None\t\t None Pinot Noir\n",
|
||
"Red-Earthy\t None\t\t None Chianti\n",
|
||
"White-Crisp\t None\t\t None Sauvignon Blanc\n",
|
||
"White-Creamy None\t\t\t None Chardonnay\n",
|
||
"Red-Spicy\t\t None\t None Shiraz or Zinfandel\n",
|
||
"Red-Rich\t\t None \t None Cabernet Sauvignon\n",
|
||
"White-Floral None\t\t\t None Gewurztraminer\n",
|
||
"White-Citrus None\t\t\t None Riesling\n",
|
||
"Red\t\t\t None None Pinot Noir\n",
|
||
"Red\t\t\t None None Chianti\n",
|
||
"White\t\t\t None None Sauvignon Blanc\n",
|
||
"White\t\t\t None None Chardonnay\n",
|
||
"Red\t\t\t None None Shiraz or Zinfandel\n",
|
||
"Red\t\t\t None None Cabernet Sauvignon\n",
|
||
"White\t\t\t None None Gewurztraminer\n",
|
||
"White\t\t\t None None Riesling\n",
|
||
"Red-Fruity\t Light-Bodied\t\tNone Pinot Noir\n",
|
||
"Red-Fruity\t Full-Bodied\t\t None Shiraz or Zinfandel\n",
|
||
"Red-Earthy\t Light-Bodied\t\tNone Pinot Noir\n",
|
||
"Red-Earthy\t Full-Bodied\t\t None Cabernet Sauvignon\n",
|
||
"White-Crisp\t Dry\t\t None Sauvignon Blanc\n",
|
||
"White-Crisp\t Sweet\t\t None Pinot Noir\n",
|
||
"White-Creamy Dry\t\t None Pinot Noir\n",
|
||
"White-Creamy Sweet\t\t None Chardonnay\n",
|
||
"Red-Spicy\t Light-Bodied\t\tNone Pinot Noir\n",
|
||
"Red-Spicy\t Full-Bodied\t\t None Shiraz or Zinfandel\n",
|
||
"Red-Rich\t Light-Bodied\t\tNone Pinot Noir\n",
|
||
"Red-Rich\t Full-Bodied\t\t None Cabernet Sauvignon\n",
|
||
"White-Floral\tDry\t\t None Pinot Noir\n",
|
||
"White-Floral\tSweet\t\t None Gewurztraminer\n",
|
||
"White-Citrus\tDry\t\t None Sauvignon Blanc\n",
|
||
"White-Citrus\tSweet\t\t None Riesling\n",
|
||
"Red-Fruity\t\tNone\t Sweet Pinot Noir\n",
|
||
"Red-Fruity\t\tNone\t Dry Pinot Noir\n",
|
||
"Red-Earthy\t\tNone\t Sweet Chianti\n",
|
||
"Red-Earthy\t\tNone\t Dry Pinot Noir\n",
|
||
"\n",
|
||
"\n",
|
||
"Based on the data generate 20 different choices and recommended based on the choices\n",
|
||
"'''\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 48,
|
||
"metadata": {
|
||
"id": "VF7kwoFuYIT4"
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"Questions = call(data_4)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 49,
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/",
|
||
"height": 109
|
||
},
|
||
"id": "zSwiyj-QYNYo",
|
||
"outputId": "042d5f15-2dc9-4856-e2bc-2e59b43643a9"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"output_type": "execute_result",
|
||
"data": {
|
||
"text/plain": [
|
||
"'\\n1. Pinot Noir (Red-Fruity, Dry)\\n2. Shiraz or Zinfandel (Red-Fruity, Full-Bodied)\\n3. Sauvignon Blanc (White-Crisp, Dry)\\n4. Sweet Gewurztraminer (White, None)\\n5. Chianti (Red-Earthy, None)\\n6. Chardonnay (White-Creamy, Sweet)\\n7. Cabernet Sauvignon (Red-Rich, Full-Bodied)\\n8. Pinot Noir (Red, Light-Bodied)\\n9. Shiraz or Zinfandel (Red-Spicy, Light-Bodied)\\n10. Pinot Noir (Red, None)\\n11. Chianti (Red, None)\\n12. Sauvignon Blanc (White, None)\\n13. Chardonnay (White, None)\\n14. Shiraz or Zinfandel (Red, None)\\n15. Cabernet Sauvignon (Red, None)\\n16. Gewurztraminer (White-Floral, Sweet)\\n17. Riesling (White-Citrus, Sweet)\\n18. Pinot Noir (Red-Earthy, Light-Bodied)\\n19. Cabernet Sauvignon (Red-Rich, Light-Bodied)\\n20. Pinot Noir (White-Crisp, Sweet)'"
|
||
],
|
||
"application/vnd.google.colaboratory.intrinsic+json": {
|
||
"type": "string"
|
||
}
|
||
},
|
||
"metadata": {},
|
||
"execution_count": 49
|
||
}
|
||
],
|
||
"source": [
|
||
"Questions"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 51,
|
||
"metadata": {
|
||
"id": "YaP0OU8MYtJ4"
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"temp = re.split('[0-9]|\\n|\\.',Questions)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 52,
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/"
|
||
},
|
||
"id": "pGeywgUbZC1w",
|
||
"outputId": "6d3fff60-6c31-4a24-d50b-7f7e8c9a1a54"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"output_type": "execute_result",
|
||
"data": {
|
||
"text/plain": [
|
||
"[' Pinot Noir (Red-Fruity, Dry)',\n",
|
||
" ' Shiraz or Zinfandel (Red-Fruity, Full-Bodied)',\n",
|
||
" ' Sauvignon Blanc (White-Crisp, Dry)',\n",
|
||
" ' Sweet Gewurztraminer (White, None)',\n",
|
||
" ' Chianti (Red-Earthy, None)',\n",
|
||
" ' Chardonnay (White-Creamy, Sweet)',\n",
|
||
" ' Cabernet Sauvignon (Red-Rich, Full-Bodied)',\n",
|
||
" ' Pinot Noir (Red, Light-Bodied)',\n",
|
||
" ' Shiraz or Zinfandel (Red-Spicy, Light-Bodied)',\n",
|
||
" ' Pinot Noir (Red, None)',\n",
|
||
" ' Chianti (Red, None)',\n",
|
||
" ' Sauvignon Blanc (White, None)',\n",
|
||
" ' Chardonnay (White, None)',\n",
|
||
" ' Shiraz or Zinfandel (Red, None)',\n",
|
||
" ' Cabernet Sauvignon (Red, None)',\n",
|
||
" ' Gewurztraminer (White-Floral, Sweet)',\n",
|
||
" ' Riesling (White-Citrus, Sweet)',\n",
|
||
" ' Pinot Noir (Red-Earthy, Light-Bodied)',\n",
|
||
" ' Cabernet Sauvignon (Red-Rich, Light-Bodied)',\n",
|
||
" ' Pinot Noir (White-Crisp, Sweet)']"
|
||
]
|
||
},
|
||
"metadata": {},
|
||
"execution_count": 52
|
||
}
|
||
],
|
||
"source": [
|
||
"QA = [tem for tem in temp if len(tem)>0]\n",
|
||
"QA"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 53,
|
||
"metadata": {
|
||
"id": "LtK-srHkaHU4"
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"ques = []\n",
|
||
"ans = []\n",
|
||
"\n",
|
||
"for item in QA:\n",
|
||
" a = item\n",
|
||
" b = re.split('[()]|\\|',a)\n",
|
||
" ans.append(b[0])\n",
|
||
" j = 0\n",
|
||
" str_temp = \"(\"\n",
|
||
" for i in b:\n",
|
||
" if j==0:\n",
|
||
" j = -1\n",
|
||
" continue\n",
|
||
" elif len(i):\n",
|
||
" str_temp += i\n",
|
||
" str_temp += \"|\"\n",
|
||
"\n",
|
||
" str_temp = str_temp.rstrip(\"|\")\n",
|
||
" str_temp += \")\" \n",
|
||
" ques.append(str_temp)\n",
|
||
" str_temp = \"\"\n",
|
||
" "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 54,
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/"
|
||
},
|
||
"id": "KpOLQ105an9v",
|
||
"outputId": "e3f94de1-e03b-48ae-fc9e-809221f0b111"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"output_type": "execute_result",
|
||
"data": {
|
||
"text/plain": [
|
||
"['(Red-Fruity, Dry)',\n",
|
||
" '(Red-Fruity, Full-Bodied)',\n",
|
||
" '(White-Crisp, Dry)',\n",
|
||
" '(White, None)',\n",
|
||
" '(Red-Earthy, None)',\n",
|
||
" '(White-Creamy, Sweet)',\n",
|
||
" '(Red-Rich, Full-Bodied)',\n",
|
||
" '(Red, Light-Bodied)',\n",
|
||
" '(Red-Spicy, Light-Bodied)',\n",
|
||
" '(Red, None)',\n",
|
||
" '(Red, None)',\n",
|
||
" '(White, None)',\n",
|
||
" '(White, None)',\n",
|
||
" '(Red, None)',\n",
|
||
" '(Red, None)',\n",
|
||
" '(White-Floral, Sweet)',\n",
|
||
" '(White-Citrus, Sweet)',\n",
|
||
" '(Red-Earthy, Light-Bodied)',\n",
|
||
" '(Red-Rich, Light-Bodied)',\n",
|
||
" '(White-Crisp, Sweet)']"
|
||
]
|
||
},
|
||
"metadata": {},
|
||
"execution_count": 54
|
||
}
|
||
],
|
||
"source": [
|
||
"ques"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 55,
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/"
|
||
},
|
||
"id": "SBRw37z7cQ9I",
|
||
"outputId": "78c414b2-397f-41f6-8cb4-793bd72eed7f"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"output_type": "execute_result",
|
||
"data": {
|
||
"text/plain": [
|
||
"[' Pinot Noir ',\n",
|
||
" ' Shiraz or Zinfandel ',\n",
|
||
" ' Sauvignon Blanc ',\n",
|
||
" ' Sweet Gewurztraminer ',\n",
|
||
" ' Chianti ',\n",
|
||
" ' Chardonnay ',\n",
|
||
" ' Cabernet Sauvignon ',\n",
|
||
" ' Pinot Noir ',\n",
|
||
" ' Shiraz or Zinfandel ',\n",
|
||
" ' Pinot Noir ',\n",
|
||
" ' Chianti ',\n",
|
||
" ' Sauvignon Blanc ',\n",
|
||
" ' Chardonnay ',\n",
|
||
" ' Shiraz or Zinfandel ',\n",
|
||
" ' Cabernet Sauvignon ',\n",
|
||
" ' Gewurztraminer ',\n",
|
||
" ' Riesling ',\n",
|
||
" ' Pinot Noir ',\n",
|
||
" ' Cabernet Sauvignon ',\n",
|
||
" ' Pinot Noir ']"
|
||
]
|
||
},
|
||
"metadata": {},
|
||
"execution_count": 55
|
||
}
|
||
],
|
||
"source": [
|
||
"ans"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 70,
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/",
|
||
"height": 206
|
||
},
|
||
"id": "iBEOQXdCdg1A",
|
||
"outputId": "bf03a995-170e-455f-8e98-433bb254fdfd"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"output_type": "execute_result",
|
||
"data": {
|
||
"text/plain": [
|
||
" Question Answer\n",
|
||
"0 (Red-Fruity, Dry) Pinot Noir \n",
|
||
"1 (Red-Fruity, Full-Bodied) Shiraz or Zinfandel \n",
|
||
"2 (White-Crisp, Dry) Sauvignon Blanc \n",
|
||
"3 (White, None) Sweet Gewurztraminer \n",
|
||
"4 (Red-Earthy, None) Chianti "
|
||
],
|
||
"text/html": [
|
||
"\n",
|
||
" <div id=\"df-785bb9e3-9c2a-4582-aefc-bc14073f40ed\">\n",
|
||
" <div 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>Question</th>\n",
|
||
" <th>Answer</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>(Red-Fruity, Dry)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>(Red-Fruity, Full-Bodied)</td>\n",
|
||
" <td>Shiraz or Zinfandel</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>(White-Crisp, Dry)</td>\n",
|
||
" <td>Sauvignon Blanc</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>(White, None)</td>\n",
|
||
" <td>Sweet Gewurztraminer</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>(Red-Earthy, None)</td>\n",
|
||
" <td>Chianti</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>\n",
|
||
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-785bb9e3-9c2a-4582-aefc-bc14073f40ed')\"\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 0 24 24\"\n",
|
||
" width=\"24px\">\n",
|
||
" <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n",
|
||
" <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n",
|
||
" </svg>\n",
|
||
" </button>\n",
|
||
" \n",
|
||
" <style>\n",
|
||
" .colab-df-container {\n",
|
||
" display:flex;\n",
|
||
" flex-wrap:wrap;\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",
|
||
" [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-785bb9e3-9c2a-4582-aefc-bc14073f40ed 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-785bb9e3-9c2a-4582-aefc-bc14073f40ed');\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",
|
||
" </div>\n",
|
||
" "
|
||
]
|
||
},
|
||
"metadata": {},
|
||
"execution_count": 70
|
||
}
|
||
],
|
||
"source": [
|
||
"data_temp = {'Question':ques,'Answer':ans}\n",
|
||
"df1 = pd.DataFrame(data_temp)\n",
|
||
"df1.head()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 71,
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/",
|
||
"height": 676
|
||
},
|
||
"id": "mrcR7rr7d2W3",
|
||
"outputId": "6f530435-9415-41f4-f4d4-8eca01ea877a"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"output_type": "execute_result",
|
||
"data": {
|
||
"text/plain": [
|
||
" Question Answer\n",
|
||
"0 (Red-Fruity, Dry) Pinot Noir \n",
|
||
"1 (Red-Fruity, Full-Bodied) Shiraz or Zinfandel \n",
|
||
"2 (White-Crisp, Dry) Sauvignon Blanc \n",
|
||
"3 (White, None) Sweet Gewurztraminer \n",
|
||
"4 (Red-Earthy, None) Chianti \n",
|
||
"5 (White-Creamy, Sweet) Chardonnay \n",
|
||
"6 (Red-Rich, Full-Bodied) Cabernet Sauvignon \n",
|
||
"7 (Red, Light-Bodied) Pinot Noir \n",
|
||
"8 (Red-Spicy, Light-Bodied) Shiraz or Zinfandel \n",
|
||
"9 (Red, None) Pinot Noir \n",
|
||
"10 (Red, None) Chianti \n",
|
||
"11 (White, None) Sauvignon Blanc \n",
|
||
"12 (White, None) Chardonnay \n",
|
||
"13 (Red, None) Shiraz or Zinfandel \n",
|
||
"14 (Red, None) Cabernet Sauvignon \n",
|
||
"15 (White-Floral, Sweet) Gewurztraminer \n",
|
||
"16 (White-Citrus, Sweet) Riesling \n",
|
||
"17 (Red-Earthy, Light-Bodied) Pinot Noir \n",
|
||
"18 (Red-Rich, Light-Bodied) Cabernet Sauvignon \n",
|
||
"19 (White-Crisp, Sweet) Pinot Noir "
|
||
],
|
||
"text/html": [
|
||
"\n",
|
||
" <div id=\"df-cb85b06d-cde7-4a31-975b-25997ec854ed\">\n",
|
||
" <div 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>Question</th>\n",
|
||
" <th>Answer</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>(Red-Fruity, Dry)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>(Red-Fruity, Full-Bodied)</td>\n",
|
||
" <td>Shiraz or Zinfandel</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>(White-Crisp, Dry)</td>\n",
|
||
" <td>Sauvignon Blanc</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>(White, None)</td>\n",
|
||
" <td>Sweet Gewurztraminer</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>(Red-Earthy, None)</td>\n",
|
||
" <td>Chianti</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>5</th>\n",
|
||
" <td>(White-Creamy, Sweet)</td>\n",
|
||
" <td>Chardonnay</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>6</th>\n",
|
||
" <td>(Red-Rich, Full-Bodied)</td>\n",
|
||
" <td>Cabernet Sauvignon</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>7</th>\n",
|
||
" <td>(Red, Light-Bodied)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>8</th>\n",
|
||
" <td>(Red-Spicy, Light-Bodied)</td>\n",
|
||
" <td>Shiraz or Zinfandel</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>9</th>\n",
|
||
" <td>(Red, None)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>10</th>\n",
|
||
" <td>(Red, None)</td>\n",
|
||
" <td>Chianti</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>11</th>\n",
|
||
" <td>(White, None)</td>\n",
|
||
" <td>Sauvignon Blanc</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>12</th>\n",
|
||
" <td>(White, None)</td>\n",
|
||
" <td>Chardonnay</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>13</th>\n",
|
||
" <td>(Red, None)</td>\n",
|
||
" <td>Shiraz or Zinfandel</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>14</th>\n",
|
||
" <td>(Red, None)</td>\n",
|
||
" <td>Cabernet Sauvignon</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>15</th>\n",
|
||
" <td>(White-Floral, Sweet)</td>\n",
|
||
" <td>Gewurztraminer</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>16</th>\n",
|
||
" <td>(White-Citrus, Sweet)</td>\n",
|
||
" <td>Riesling</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>17</th>\n",
|
||
" <td>(Red-Earthy, Light-Bodied)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>18</th>\n",
|
||
" <td>(Red-Rich, Light-Bodied)</td>\n",
|
||
" <td>Cabernet Sauvignon</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>19</th>\n",
|
||
" <td>(White-Crisp, Sweet)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>\n",
|
||
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-cb85b06d-cde7-4a31-975b-25997ec854ed')\"\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 0 24 24\"\n",
|
||
" width=\"24px\">\n",
|
||
" <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n",
|
||
" <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n",
|
||
" </svg>\n",
|
||
" </button>\n",
|
||
" \n",
|
||
" <style>\n",
|
||
" .colab-df-container {\n",
|
||
" display:flex;\n",
|
||
" flex-wrap:wrap;\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",
|
||
" [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-cb85b06d-cde7-4a31-975b-25997ec854ed 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-cb85b06d-cde7-4a31-975b-25997ec854ed');\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",
|
||
" </div>\n",
|
||
" "
|
||
]
|
||
},
|
||
"metadata": {},
|
||
"execution_count": 71
|
||
}
|
||
],
|
||
"source": [
|
||
"df1"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"source": [
|
||
"df1['Answer'] = df1['Answer'].str.replace(' END', '')"
|
||
],
|
||
"metadata": {
|
||
"id": "C02VOrRdsJF1"
|
||
},
|
||
"execution_count": 72,
|
||
"outputs": []
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"source": [
|
||
"df1"
|
||
],
|
||
"metadata": {
|
||
"id": "o7JXsozXsMV9",
|
||
"outputId": "0d0e9530-d0d8-4dca-dd13-70f290220bfe",
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/",
|
||
"height": 676
|
||
}
|
||
},
|
||
"execution_count": 73,
|
||
"outputs": [
|
||
{
|
||
"output_type": "execute_result",
|
||
"data": {
|
||
"text/plain": [
|
||
" Question Answer\n",
|
||
"0 (Red-Fruity, Dry) Pinot Noir \n",
|
||
"1 (Red-Fruity, Full-Bodied) Shiraz or Zinfandel \n",
|
||
"2 (White-Crisp, Dry) Sauvignon Blanc \n",
|
||
"3 (White, None) Sweet Gewurztraminer \n",
|
||
"4 (Red-Earthy, None) Chianti \n",
|
||
"5 (White-Creamy, Sweet) Chardonnay \n",
|
||
"6 (Red-Rich, Full-Bodied) Cabernet Sauvignon \n",
|
||
"7 (Red, Light-Bodied) Pinot Noir \n",
|
||
"8 (Red-Spicy, Light-Bodied) Shiraz or Zinfandel \n",
|
||
"9 (Red, None) Pinot Noir \n",
|
||
"10 (Red, None) Chianti \n",
|
||
"11 (White, None) Sauvignon Blanc \n",
|
||
"12 (White, None) Chardonnay \n",
|
||
"13 (Red, None) Shiraz or Zinfandel \n",
|
||
"14 (Red, None) Cabernet Sauvignon \n",
|
||
"15 (White-Floral, Sweet) Gewurztraminer \n",
|
||
"16 (White-Citrus, Sweet) Riesling \n",
|
||
"17 (Red-Earthy, Light-Bodied) Pinot Noir \n",
|
||
"18 (Red-Rich, Light-Bodied) Cabernet Sauvignon \n",
|
||
"19 (White-Crisp, Sweet) Pinot Noir "
|
||
],
|
||
"text/html": [
|
||
"\n",
|
||
" <div id=\"df-46124bec-e2f0-4b3a-bf40-0fdb37eb9dad\">\n",
|
||
" <div 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>Question</th>\n",
|
||
" <th>Answer</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>(Red-Fruity, Dry)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>(Red-Fruity, Full-Bodied)</td>\n",
|
||
" <td>Shiraz or Zinfandel</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>(White-Crisp, Dry)</td>\n",
|
||
" <td>Sauvignon Blanc</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>(White, None)</td>\n",
|
||
" <td>Sweet Gewurztraminer</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>(Red-Earthy, None)</td>\n",
|
||
" <td>Chianti</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>5</th>\n",
|
||
" <td>(White-Creamy, Sweet)</td>\n",
|
||
" <td>Chardonnay</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>6</th>\n",
|
||
" <td>(Red-Rich, Full-Bodied)</td>\n",
|
||
" <td>Cabernet Sauvignon</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>7</th>\n",
|
||
" <td>(Red, Light-Bodied)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>8</th>\n",
|
||
" <td>(Red-Spicy, Light-Bodied)</td>\n",
|
||
" <td>Shiraz or Zinfandel</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>9</th>\n",
|
||
" <td>(Red, None)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>10</th>\n",
|
||
" <td>(Red, None)</td>\n",
|
||
" <td>Chianti</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>11</th>\n",
|
||
" <td>(White, None)</td>\n",
|
||
" <td>Sauvignon Blanc</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>12</th>\n",
|
||
" <td>(White, None)</td>\n",
|
||
" <td>Chardonnay</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>13</th>\n",
|
||
" <td>(Red, None)</td>\n",
|
||
" <td>Shiraz or Zinfandel</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>14</th>\n",
|
||
" <td>(Red, None)</td>\n",
|
||
" <td>Cabernet Sauvignon</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>15</th>\n",
|
||
" <td>(White-Floral, Sweet)</td>\n",
|
||
" <td>Gewurztraminer</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>16</th>\n",
|
||
" <td>(White-Citrus, Sweet)</td>\n",
|
||
" <td>Riesling</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>17</th>\n",
|
||
" <td>(Red-Earthy, Light-Bodied)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>18</th>\n",
|
||
" <td>(Red-Rich, Light-Bodied)</td>\n",
|
||
" <td>Cabernet Sauvignon</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>19</th>\n",
|
||
" <td>(White-Crisp, Sweet)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>\n",
|
||
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-46124bec-e2f0-4b3a-bf40-0fdb37eb9dad')\"\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 0 24 24\"\n",
|
||
" width=\"24px\">\n",
|
||
" <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n",
|
||
" <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n",
|
||
" </svg>\n",
|
||
" </button>\n",
|
||
" \n",
|
||
" <style>\n",
|
||
" .colab-df-container {\n",
|
||
" display:flex;\n",
|
||
" flex-wrap:wrap;\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",
|
||
" [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-46124bec-e2f0-4b3a-bf40-0fdb37eb9dad 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-46124bec-e2f0-4b3a-bf40-0fdb37eb9dad');\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",
|
||
" </div>\n",
|
||
" "
|
||
]
|
||
},
|
||
"metadata": {},
|
||
"execution_count": 73
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"source": [
|
||
"df1['Question'] = df1['Question'].str.strip()"
|
||
],
|
||
"metadata": {
|
||
"id": "d66os-iBsRrf"
|
||
},
|
||
"execution_count": 74,
|
||
"outputs": []
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"source": [
|
||
"df1"
|
||
],
|
||
"metadata": {
|
||
"id": "YfWJRjzps_Xe",
|
||
"outputId": "2a3e9599-458b-45b0-ab62-a2579ff48b8c",
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/",
|
||
"height": 676
|
||
}
|
||
},
|
||
"execution_count": 75,
|
||
"outputs": [
|
||
{
|
||
"output_type": "execute_result",
|
||
"data": {
|
||
"text/plain": [
|
||
" Question Answer\n",
|
||
"0 (Red-Fruity, Dry) Pinot Noir \n",
|
||
"1 (Red-Fruity, Full-Bodied) Shiraz or Zinfandel \n",
|
||
"2 (White-Crisp, Dry) Sauvignon Blanc \n",
|
||
"3 (White, None) Sweet Gewurztraminer \n",
|
||
"4 (Red-Earthy, None) Chianti \n",
|
||
"5 (White-Creamy, Sweet) Chardonnay \n",
|
||
"6 (Red-Rich, Full-Bodied) Cabernet Sauvignon \n",
|
||
"7 (Red, Light-Bodied) Pinot Noir \n",
|
||
"8 (Red-Spicy, Light-Bodied) Shiraz or Zinfandel \n",
|
||
"9 (Red, None) Pinot Noir \n",
|
||
"10 (Red, None) Chianti \n",
|
||
"11 (White, None) Sauvignon Blanc \n",
|
||
"12 (White, None) Chardonnay \n",
|
||
"13 (Red, None) Shiraz or Zinfandel \n",
|
||
"14 (Red, None) Cabernet Sauvignon \n",
|
||
"15 (White-Floral, Sweet) Gewurztraminer \n",
|
||
"16 (White-Citrus, Sweet) Riesling \n",
|
||
"17 (Red-Earthy, Light-Bodied) Pinot Noir \n",
|
||
"18 (Red-Rich, Light-Bodied) Cabernet Sauvignon \n",
|
||
"19 (White-Crisp, Sweet) Pinot Noir "
|
||
],
|
||
"text/html": [
|
||
"\n",
|
||
" <div id=\"df-974cd290-f9e3-46a5-9975-49dcd42c88b4\">\n",
|
||
" <div 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>Question</th>\n",
|
||
" <th>Answer</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>(Red-Fruity, Dry)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>(Red-Fruity, Full-Bodied)</td>\n",
|
||
" <td>Shiraz or Zinfandel</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>(White-Crisp, Dry)</td>\n",
|
||
" <td>Sauvignon Blanc</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>(White, None)</td>\n",
|
||
" <td>Sweet Gewurztraminer</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>(Red-Earthy, None)</td>\n",
|
||
" <td>Chianti</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>5</th>\n",
|
||
" <td>(White-Creamy, Sweet)</td>\n",
|
||
" <td>Chardonnay</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>6</th>\n",
|
||
" <td>(Red-Rich, Full-Bodied)</td>\n",
|
||
" <td>Cabernet Sauvignon</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>7</th>\n",
|
||
" <td>(Red, Light-Bodied)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>8</th>\n",
|
||
" <td>(Red-Spicy, Light-Bodied)</td>\n",
|
||
" <td>Shiraz or Zinfandel</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>9</th>\n",
|
||
" <td>(Red, None)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>10</th>\n",
|
||
" <td>(Red, None)</td>\n",
|
||
" <td>Chianti</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>11</th>\n",
|
||
" <td>(White, None)</td>\n",
|
||
" <td>Sauvignon Blanc</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>12</th>\n",
|
||
" <td>(White, None)</td>\n",
|
||
" <td>Chardonnay</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>13</th>\n",
|
||
" <td>(Red, None)</td>\n",
|
||
" <td>Shiraz or Zinfandel</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>14</th>\n",
|
||
" <td>(Red, None)</td>\n",
|
||
" <td>Cabernet Sauvignon</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>15</th>\n",
|
||
" <td>(White-Floral, Sweet)</td>\n",
|
||
" <td>Gewurztraminer</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>16</th>\n",
|
||
" <td>(White-Citrus, Sweet)</td>\n",
|
||
" <td>Riesling</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>17</th>\n",
|
||
" <td>(Red-Earthy, Light-Bodied)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>18</th>\n",
|
||
" <td>(Red-Rich, Light-Bodied)</td>\n",
|
||
" <td>Cabernet Sauvignon</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>19</th>\n",
|
||
" <td>(White-Crisp, Sweet)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>\n",
|
||
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-974cd290-f9e3-46a5-9975-49dcd42c88b4')\"\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 0 24 24\"\n",
|
||
" width=\"24px\">\n",
|
||
" <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n",
|
||
" <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n",
|
||
" </svg>\n",
|
||
" </button>\n",
|
||
" \n",
|
||
" <style>\n",
|
||
" .colab-df-container {\n",
|
||
" display:flex;\n",
|
||
" flex-wrap:wrap;\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",
|
||
" [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-974cd290-f9e3-46a5-9975-49dcd42c88b4 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-974cd290-f9e3-46a5-9975-49dcd42c88b4');\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",
|
||
" </div>\n",
|
||
" "
|
||
]
|
||
},
|
||
"metadata": {},
|
||
"execution_count": 75
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"source": [
|
||
"df1['Question'] = 'Question: ' + df1['Question']"
|
||
],
|
||
"metadata": {
|
||
"id": "x2U6hCOxtBef"
|
||
},
|
||
"execution_count": 76,
|
||
"outputs": []
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"source": [
|
||
"df1"
|
||
],
|
||
"metadata": {
|
||
"id": "YXChQOBzsVNl",
|
||
"outputId": "d0f70f77-8e4f-4ec1-bf4b-778fd016dfd2",
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/",
|
||
"height": 676
|
||
}
|
||
},
|
||
"execution_count": 77,
|
||
"outputs": [
|
||
{
|
||
"output_type": "execute_result",
|
||
"data": {
|
||
"text/plain": [
|
||
" Question Answer\n",
|
||
"0 Question: (Red-Fruity, Dry) Pinot Noir \n",
|
||
"1 Question: (Red-Fruity, Full-Bodied) Shiraz or Zinfandel \n",
|
||
"2 Question: (White-Crisp, Dry) Sauvignon Blanc \n",
|
||
"3 Question: (White, None) Sweet Gewurztraminer \n",
|
||
"4 Question: (Red-Earthy, None) Chianti \n",
|
||
"5 Question: (White-Creamy, Sweet) Chardonnay \n",
|
||
"6 Question: (Red-Rich, Full-Bodied) Cabernet Sauvignon \n",
|
||
"7 Question: (Red, Light-Bodied) Pinot Noir \n",
|
||
"8 Question: (Red-Spicy, Light-Bodied) Shiraz or Zinfandel \n",
|
||
"9 Question: (Red, None) Pinot Noir \n",
|
||
"10 Question: (Red, None) Chianti \n",
|
||
"11 Question: (White, None) Sauvignon Blanc \n",
|
||
"12 Question: (White, None) Chardonnay \n",
|
||
"13 Question: (Red, None) Shiraz or Zinfandel \n",
|
||
"14 Question: (Red, None) Cabernet Sauvignon \n",
|
||
"15 Question: (White-Floral, Sweet) Gewurztraminer \n",
|
||
"16 Question: (White-Citrus, Sweet) Riesling \n",
|
||
"17 Question: (Red-Earthy, Light-Bodied) Pinot Noir \n",
|
||
"18 Question: (Red-Rich, Light-Bodied) Cabernet Sauvignon \n",
|
||
"19 Question: (White-Crisp, Sweet) Pinot Noir "
|
||
],
|
||
"text/html": [
|
||
"\n",
|
||
" <div id=\"df-d7239199-8598-4883-8f85-605b218a4b0c\">\n",
|
||
" <div 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>Question</th>\n",
|
||
" <th>Answer</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>Question: (Red-Fruity, Dry)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>Question: (Red-Fruity, Full-Bodied)</td>\n",
|
||
" <td>Shiraz or Zinfandel</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>Question: (White-Crisp, Dry)</td>\n",
|
||
" <td>Sauvignon Blanc</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>Question: (White, None)</td>\n",
|
||
" <td>Sweet Gewurztraminer</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>Question: (Red-Earthy, None)</td>\n",
|
||
" <td>Chianti</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>5</th>\n",
|
||
" <td>Question: (White-Creamy, Sweet)</td>\n",
|
||
" <td>Chardonnay</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>6</th>\n",
|
||
" <td>Question: (Red-Rich, Full-Bodied)</td>\n",
|
||
" <td>Cabernet Sauvignon</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>7</th>\n",
|
||
" <td>Question: (Red, Light-Bodied)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>8</th>\n",
|
||
" <td>Question: (Red-Spicy, Light-Bodied)</td>\n",
|
||
" <td>Shiraz or Zinfandel</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>9</th>\n",
|
||
" <td>Question: (Red, None)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>10</th>\n",
|
||
" <td>Question: (Red, None)</td>\n",
|
||
" <td>Chianti</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>11</th>\n",
|
||
" <td>Question: (White, None)</td>\n",
|
||
" <td>Sauvignon Blanc</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>12</th>\n",
|
||
" <td>Question: (White, None)</td>\n",
|
||
" <td>Chardonnay</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>13</th>\n",
|
||
" <td>Question: (Red, None)</td>\n",
|
||
" <td>Shiraz or Zinfandel</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>14</th>\n",
|
||
" <td>Question: (Red, None)</td>\n",
|
||
" <td>Cabernet Sauvignon</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>15</th>\n",
|
||
" <td>Question: (White-Floral, Sweet)</td>\n",
|
||
" <td>Gewurztraminer</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>16</th>\n",
|
||
" <td>Question: (White-Citrus, Sweet)</td>\n",
|
||
" <td>Riesling</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>17</th>\n",
|
||
" <td>Question: (Red-Earthy, Light-Bodied)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>18</th>\n",
|
||
" <td>Question: (Red-Rich, Light-Bodied)</td>\n",
|
||
" <td>Cabernet Sauvignon</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>19</th>\n",
|
||
" <td>Question: (White-Crisp, Sweet)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>\n",
|
||
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-d7239199-8598-4883-8f85-605b218a4b0c')\"\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 0 24 24\"\n",
|
||
" width=\"24px\">\n",
|
||
" <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n",
|
||
" <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n",
|
||
" </svg>\n",
|
||
" </button>\n",
|
||
" \n",
|
||
" <style>\n",
|
||
" .colab-df-container {\n",
|
||
" display:flex;\n",
|
||
" flex-wrap:wrap;\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",
|
||
" [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-d7239199-8598-4883-8f85-605b218a4b0c 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-d7239199-8598-4883-8f85-605b218a4b0c');\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",
|
||
" </div>\n",
|
||
" "
|
||
]
|
||
},
|
||
"metadata": {},
|
||
"execution_count": 77
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"source": [
|
||
"df1.loc[0] = [\"Question: \\n\\nAnswer:\\n\\n\",\"END\"]"
|
||
],
|
||
"metadata": {
|
||
"id": "IsUtstXYt-j1"
|
||
},
|
||
"execution_count": 78,
|
||
"outputs": []
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"source": [
|
||
"df1"
|
||
],
|
||
"metadata": {
|
||
"id": "JaRMnbmbuWIF",
|
||
"outputId": "95acf69b-6538-4270-bc03-f187eaa28e05",
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/",
|
||
"height": 676
|
||
}
|
||
},
|
||
"execution_count": 79,
|
||
"outputs": [
|
||
{
|
||
"output_type": "execute_result",
|
||
"data": {
|
||
"text/plain": [
|
||
" Question Answer\n",
|
||
"0 Question: \\n\\nAnswer:\\n\\n END\n",
|
||
"1 Question: (Red-Fruity, Full-Bodied) Shiraz or Zinfandel \n",
|
||
"2 Question: (White-Crisp, Dry) Sauvignon Blanc \n",
|
||
"3 Question: (White, None) Sweet Gewurztraminer \n",
|
||
"4 Question: (Red-Earthy, None) Chianti \n",
|
||
"5 Question: (White-Creamy, Sweet) Chardonnay \n",
|
||
"6 Question: (Red-Rich, Full-Bodied) Cabernet Sauvignon \n",
|
||
"7 Question: (Red, Light-Bodied) Pinot Noir \n",
|
||
"8 Question: (Red-Spicy, Light-Bodied) Shiraz or Zinfandel \n",
|
||
"9 Question: (Red, None) Pinot Noir \n",
|
||
"10 Question: (Red, None) Chianti \n",
|
||
"11 Question: (White, None) Sauvignon Blanc \n",
|
||
"12 Question: (White, None) Chardonnay \n",
|
||
"13 Question: (Red, None) Shiraz or Zinfandel \n",
|
||
"14 Question: (Red, None) Cabernet Sauvignon \n",
|
||
"15 Question: (White-Floral, Sweet) Gewurztraminer \n",
|
||
"16 Question: (White-Citrus, Sweet) Riesling \n",
|
||
"17 Question: (Red-Earthy, Light-Bodied) Pinot Noir \n",
|
||
"18 Question: (Red-Rich, Light-Bodied) Cabernet Sauvignon \n",
|
||
"19 Question: (White-Crisp, Sweet) Pinot Noir "
|
||
],
|
||
"text/html": [
|
||
"\n",
|
||
" <div id=\"df-f5f06bd4-4a09-41df-8eaa-9d27ae1f1aae\">\n",
|
||
" <div 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>Question</th>\n",
|
||
" <th>Answer</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>Question: \\n\\nAnswer:\\n\\n</td>\n",
|
||
" <td>END</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>Question: (Red-Fruity, Full-Bodied)</td>\n",
|
||
" <td>Shiraz or Zinfandel</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>Question: (White-Crisp, Dry)</td>\n",
|
||
" <td>Sauvignon Blanc</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>Question: (White, None)</td>\n",
|
||
" <td>Sweet Gewurztraminer</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>Question: (Red-Earthy, None)</td>\n",
|
||
" <td>Chianti</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>5</th>\n",
|
||
" <td>Question: (White-Creamy, Sweet)</td>\n",
|
||
" <td>Chardonnay</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>6</th>\n",
|
||
" <td>Question: (Red-Rich, Full-Bodied)</td>\n",
|
||
" <td>Cabernet Sauvignon</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>7</th>\n",
|
||
" <td>Question: (Red, Light-Bodied)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>8</th>\n",
|
||
" <td>Question: (Red-Spicy, Light-Bodied)</td>\n",
|
||
" <td>Shiraz or Zinfandel</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>9</th>\n",
|
||
" <td>Question: (Red, None)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>10</th>\n",
|
||
" <td>Question: (Red, None)</td>\n",
|
||
" <td>Chianti</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>11</th>\n",
|
||
" <td>Question: (White, None)</td>\n",
|
||
" <td>Sauvignon Blanc</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>12</th>\n",
|
||
" <td>Question: (White, None)</td>\n",
|
||
" <td>Chardonnay</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>13</th>\n",
|
||
" <td>Question: (Red, None)</td>\n",
|
||
" <td>Shiraz or Zinfandel</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>14</th>\n",
|
||
" <td>Question: (Red, None)</td>\n",
|
||
" <td>Cabernet Sauvignon</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>15</th>\n",
|
||
" <td>Question: (White-Floral, Sweet)</td>\n",
|
||
" <td>Gewurztraminer</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>16</th>\n",
|
||
" <td>Question: (White-Citrus, Sweet)</td>\n",
|
||
" <td>Riesling</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>17</th>\n",
|
||
" <td>Question: (Red-Earthy, Light-Bodied)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>18</th>\n",
|
||
" <td>Question: (Red-Rich, Light-Bodied)</td>\n",
|
||
" <td>Cabernet Sauvignon</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>19</th>\n",
|
||
" <td>Question: (White-Crisp, Sweet)</td>\n",
|
||
" <td>Pinot Noir</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>\n",
|
||
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-f5f06bd4-4a09-41df-8eaa-9d27ae1f1aae')\"\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 0 24 24\"\n",
|
||
" width=\"24px\">\n",
|
||
" <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n",
|
||
" <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n",
|
||
" </svg>\n",
|
||
" </button>\n",
|
||
" \n",
|
||
" <style>\n",
|
||
" .colab-df-container {\n",
|
||
" display:flex;\n",
|
||
" flex-wrap:wrap;\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",
|
||
" [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-f5f06bd4-4a09-41df-8eaa-9d27ae1f1aae 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-f5f06bd4-4a09-41df-8eaa-9d27ae1f1aae');\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",
|
||
" </div>\n",
|
||
" "
|
||
]
|
||
},
|
||
"metadata": {},
|
||
"execution_count": 79
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 80,
|
||
"metadata": {
|
||
"id": "z3ghh7CWd8KC"
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"df1.columns = ['prompt', 'completion']"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 81,
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/",
|
||
"height": 206
|
||
},
|
||
"id": "gjDCSFdleC5n",
|
||
"outputId": "1b73d9ea-a7e4-43ff-82dc-813e84eb1c49"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"output_type": "execute_result",
|
||
"data": {
|
||
"text/plain": [
|
||
" prompt completion\n",
|
||
"0 Question: \\n\\nAnswer:\\n\\n END\n",
|
||
"1 Question: (Red-Fruity, Full-Bodied) Shiraz or Zinfandel \n",
|
||
"2 Question: (White-Crisp, Dry) Sauvignon Blanc \n",
|
||
"3 Question: (White, None) Sweet Gewurztraminer \n",
|
||
"4 Question: (Red-Earthy, None) Chianti "
|
||
],
|
||
"text/html": [
|
||
"\n",
|
||
" <div id=\"df-bbb306c0-7700-4037-a5aa-a539042b7b61\">\n",
|
||
" <div 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>prompt</th>\n",
|
||
" <th>completion</th>\n",
|
||
" </tr>\n",
|
||
" </thead>\n",
|
||
" <tbody>\n",
|
||
" <tr>\n",
|
||
" <th>0</th>\n",
|
||
" <td>Question: \\n\\nAnswer:\\n\\n</td>\n",
|
||
" <td>END</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>1</th>\n",
|
||
" <td>Question: (Red-Fruity, Full-Bodied)</td>\n",
|
||
" <td>Shiraz or Zinfandel</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>2</th>\n",
|
||
" <td>Question: (White-Crisp, Dry)</td>\n",
|
||
" <td>Sauvignon Blanc</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>3</th>\n",
|
||
" <td>Question: (White, None)</td>\n",
|
||
" <td>Sweet Gewurztraminer</td>\n",
|
||
" </tr>\n",
|
||
" <tr>\n",
|
||
" <th>4</th>\n",
|
||
" <td>Question: (Red-Earthy, None)</td>\n",
|
||
" <td>Chianti</td>\n",
|
||
" </tr>\n",
|
||
" </tbody>\n",
|
||
"</table>\n",
|
||
"</div>\n",
|
||
" <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-bbb306c0-7700-4037-a5aa-a539042b7b61')\"\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 0 24 24\"\n",
|
||
" width=\"24px\">\n",
|
||
" <path d=\"M0 0h24v24H0V0z\" fill=\"none\"/>\n",
|
||
" <path d=\"M18.56 5.44l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94zm-11 1L8.5 8.5l.94-2.06 2.06-.94-2.06-.94L8.5 2.5l-.94 2.06-2.06.94zm10 10l.94 2.06.94-2.06 2.06-.94-2.06-.94-.94-2.06-.94 2.06-2.06.94z\"/><path d=\"M17.41 7.96l-1.37-1.37c-.4-.4-.92-.59-1.43-.59-.52 0-1.04.2-1.43.59L10.3 9.45l-7.72 7.72c-.78.78-.78 2.05 0 2.83L4 21.41c.39.39.9.59 1.41.59.51 0 1.02-.2 1.41-.59l7.78-7.78 2.81-2.81c.8-.78.8-2.07 0-2.86zM5.41 20L4 18.59l7.72-7.72 1.47 1.35L5.41 20z\"/>\n",
|
||
" </svg>\n",
|
||
" </button>\n",
|
||
" \n",
|
||
" <style>\n",
|
||
" .colab-df-container {\n",
|
||
" display:flex;\n",
|
||
" flex-wrap:wrap;\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",
|
||
" [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-bbb306c0-7700-4037-a5aa-a539042b7b61 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-bbb306c0-7700-4037-a5aa-a539042b7b61');\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",
|
||
" </div>\n",
|
||
" "
|
||
]
|
||
},
|
||
"metadata": {},
|
||
"execution_count": 81
|
||
}
|
||
],
|
||
"source": [
|
||
"df1.head()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 82,
|
||
"metadata": {
|
||
"id": "bUCjN6UVeERH"
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"df1.to_json('qa_sample.jsonl', orient='records', lines=True)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 83,
|
||
"metadata": {
|
||
"id": "5pNltIc1eKpP"
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import os\n",
|
||
"os.environ['OPENAI_API_KEY'] = \"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\""
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 84,
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/"
|
||
},
|
||
"id": "qMKRiq8jeVN6",
|
||
"outputId": "68747b92-83c8-47c2-a7f5-690c0475df48"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"output_type": "stream",
|
||
"name": "stdout",
|
||
"text": [
|
||
"Analyzing...\n",
|
||
"\n",
|
||
"- Your file contains 20 prompt-completion pairs. In general, we recommend having at least a few hundred examples. We've found that performance tends to linearly increase for every doubling of the number of examples\n",
|
||
"- Your data does not contain a common separator at the end of your prompts. Having a separator string appended to the end of the prompt makes it clearer to the fine-tuned model where the completion should begin. See https://platform.openai.com/docs/guides/fine-tuning/preparing-your-dataset for more detail and examples. If you intend to do open-ended generation, then you should leave the prompts empty\n",
|
||
"- All prompts start with prefix `Question: `\n",
|
||
"- Your data does not contain a common ending at the end of your completions. Having a common ending string appended to the end of the completion makes it clearer to the fine-tuned model where the completion should end. See https://platform.openai.com/docs/guides/fine-tuning/preparing-your-dataset for more detail and examples.\n",
|
||
"- The completion should start with a whitespace character (` `). This tends to produce better results due to the tokenization we use. See https://platform.openai.com/docs/guides/fine-tuning/preparing-your-dataset for more details\n",
|
||
"\n",
|
||
"Based on the analysis we will perform the following actions:\n",
|
||
"- [Recommended] Add a suffix separator `\\n\\n###\\n\\n` to all prompts [Y/n]: Y\n",
|
||
"- [Recommended] Add a suffix ending `\\n` to all completions [Y/n]: Y\n",
|
||
"- [Recommended] Add a whitespace character to the beginning of the completion [Y/n]: Y\n",
|
||
"\n",
|
||
"\n",
|
||
"Your data will be written to a new JSONL file. Proceed [Y/n]: Y\n",
|
||
"\n",
|
||
"Wrote modified file to `qa_sample_prepared.jsonl`\n",
|
||
"Feel free to take a look!\n",
|
||
"\n",
|
||
"Now use that file when fine-tuning:\n",
|
||
"> openai api fine_tunes.create -t \"qa_sample_prepared.jsonl\"\n",
|
||
"\n",
|
||
"After you’ve fine-tuned a model, remember that your prompt has to end with the indicator string `\\n\\n###\\n\\n` for the model to start generating completions, rather than continuing with the prompt. Make sure to include `stop=[\"\\n\"]` so that the generated texts ends at the expected place.\n",
|
||
"Once your model starts training, it'll approximately take 2.72 minutes to train a `curie` model, and less for `ada` and `babbage`. Queue will approximately take half an hour per job ahead of you.\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"!openai tools fine_tunes.prepare_data -f qa_sample.jsonl"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 85,
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/"
|
||
},
|
||
"id": "rB6S552FeNmn",
|
||
"outputId": "df95cacd-e10e-4f12-fd7d-b93047e03ed8"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"output_type": "stream",
|
||
"name": "stdout",
|
||
"text": [
|
||
"\rUpload progress: 0% 0.00/1.72k [00:00<?, ?it/s]\rUpload progress: 100% 1.72k/1.72k [00:00<00:00, 2.53Mit/s]\n",
|
||
"Uploaded file from qa_sample_prepared.jsonl: file-EJzP9CiMe5CeL9ub20pEVPDr\n",
|
||
"Created fine-tune: ft-rtDJX5c4gZGQsathmhgkAdMZ\n",
|
||
"Streaming events until fine-tuning is complete...\n",
|
||
"\n",
|
||
"(Ctrl-C will interrupt the stream, but not cancel the fine-tune)\n",
|
||
"[2023-03-23 18:29:02] Created fine-tune: ft-rtDJX5c4gZGQsathmhgkAdMZ\n",
|
||
"\n",
|
||
"Stream interrupted (client disconnected).\n",
|
||
"To resume the stream, run:\n",
|
||
"\n",
|
||
" openai api fine_tunes.follow -i ft-rtDJX5c4gZGQsathmhgkAdMZ\n",
|
||
"\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"!openai api fine_tunes.create -t 'qa_sample_prepared.jsonl' -m 'davinci'"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 94,
|
||
"metadata": {
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/"
|
||
},
|
||
"id": "Sav-4eTkekpn",
|
||
"outputId": "4178cdcf-c0d6-436d-90e0-6caf82cb37cb"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"output_type": "stream",
|
||
"name": "stdout",
|
||
"text": [
|
||
"[2023-03-23 18:29:02] Created fine-tune: ft-rtDJX5c4gZGQsathmhgkAdMZ\n",
|
||
"[2023-03-23 18:32:38] Fine-tune costs $0.05\n",
|
||
"[2023-03-23 18:32:38] Fine-tune enqueued. Queue number: 5\n",
|
||
"[2023-03-23 18:33:28] Fine-tune is in the queue. Queue number: 4\n",
|
||
"[2023-03-23 18:33:46] Fine-tune is in the queue. Queue number: 3\n",
|
||
"[2023-03-23 18:34:34] Fine-tune is in the queue. Queue number: 2\n",
|
||
"[2023-03-23 18:36:03] Fine-tune is in the queue. Queue number: 1\n",
|
||
"[2023-03-23 18:36:46] Fine-tune is in the queue. Queue number: 0\n",
|
||
"[2023-03-23 18:36:52] Fine-tune started\n",
|
||
"[2023-03-23 18:39:01] Completed epoch 1/4\n",
|
||
"[2023-03-23 18:39:07] Completed epoch 2/4\n",
|
||
"[2023-03-23 18:39:12] Completed epoch 3/4\n",
|
||
"[2023-03-23 18:39:18] Completed epoch 4/4\n",
|
||
"[2023-03-23 18:39:56] Uploaded model: davinci:ft-global-corporate-holdings-2023-03-23-18-39-55\n",
|
||
"[2023-03-23 18:39:57] Uploaded result file: file-my0JOmf92CH1KdwI9SG6czp6\n",
|
||
"[2023-03-23 18:39:57] Fine-tune succeeded\n",
|
||
"\n",
|
||
"Job complete! Status: succeeded 🎉\n",
|
||
"Try out your fine-tuned model:\n",
|
||
"\n",
|
||
"openai api completions.create -m davinci:ft-global-corporate-holdings-2023-03-23-18-39-55 -p <YOUR_PROMPT>\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"!openai api fine_tunes.follow -i ft-rtDJX5c4gZGQsathmhgkAdMZ"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 97,
|
||
"metadata": {
|
||
"id": "pwdFktBKe_On",
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/"
|
||
},
|
||
"outputId": "3a817df0-479b-430b-995b-a184878aff87"
|
||
},
|
||
"outputs": [
|
||
{
|
||
"output_type": "stream",
|
||
"name": "stdout",
|
||
"text": [
|
||
"Answer the question based on DataSet Q: (White-Floral, Sweet) \n",
|
||
" Answer: Moscato d'Asti\n",
|
||
"\n",
|
||
"Q:\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"!openai api completions.create -m davinci:ft-global-corporate-holdings-2023-03-23-18-39-55 -p \"Answer the question based on DataSet Q: (White-Floral, Sweet)\""
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"source": [
|
||
"import openai\n",
|
||
"def get_answers_api(question):\n",
|
||
" try:\n",
|
||
" response = openai.Completion.create(\n",
|
||
" api_key = \"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\",\n",
|
||
" engine=\"davinci:ft-global-corporate-holdings-2023-03-23-18-39-55\",\n",
|
||
" prompt=f\"Answer the question based on DataSet Q:\\n{question}\\n\\nAnswer:\",\n",
|
||
" temperature=0,\n",
|
||
" max_tokens=900,\n",
|
||
" top_p=1,\n",
|
||
" frequency_penalty=0,\n",
|
||
" presence_penalty=0\n",
|
||
" )\n",
|
||
" return response['choices'][0]['text']\n",
|
||
" except Exception as e:\n",
|
||
" print (e)\n",
|
||
" return \"\"\n",
|
||
"\n",
|
||
"print(get_answers_api('White-Floral, Sweet'))"
|
||
],
|
||
"metadata": {
|
||
"id": "FOpiYqihxjUo",
|
||
"outputId": "87e7b8a2-c785-492c-b844-9535036aa9bc",
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/"
|
||
}
|
||
},
|
||
"execution_count": 99,
|
||
"outputs": [
|
||
{
|
||
"output_type": "stream",
|
||
"name": "stdout",
|
||
"text": [
|
||
"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n",
|
||
"\n",
|
||
"The correct answer is:\n",
|
||
"\n",
|
||
"\"Chardonnay\"\n"
|
||
]
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"source": [
|
||
"import openai\n",
|
||
"openai.api_key = \"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\"\n",
|
||
"response = openai.ChatCompletion.create(\n",
|
||
" model=\"gpt-3.5-turbo\",\n",
|
||
" messages= [{\n",
|
||
" \"role\": \"system\",\n",
|
||
" \"content\": \"You are a assistant\"\n",
|
||
" },\n",
|
||
"\n",
|
||
" {\n",
|
||
" \"role\": \"user\",\n",
|
||
" \"content\": \"Can you recommend wine based on my taste?\"\n",
|
||
" },\n",
|
||
"\n",
|
||
" {\n",
|
||
" \"content\": \"Of course! Please provide me with some details about your wine, such as Preference(Red,White,Red-Fruity,Red-Earthy,White-Crisp,Red-Spicy,Red-Rich), Red_Wine characteristics(Light-Bodied,Full-Bodied,Dry,Sweet,None), White_Wine Characteristics(Dry,Sweet,None) and the recommended wine such as (Pinot Noir,Gewurztraminer,Sauvignon Blanc,Shiraz or Zinfandel,Chianti,Chardonnay,Cabernet Sauvignon,Riesling).\",\n",
|
||
" \"role\": \"assistant\"\n",
|
||
" }, \n",
|
||
" {\n",
|
||
" \"role\": \"user\",\n",
|
||
" \"content\": \"(Red,Light-Bodied,None)\"\n",
|
||
" }\n",
|
||
"\n",
|
||
" \n",
|
||
" ]\n",
|
||
" )\n",
|
||
"print(response)"
|
||
],
|
||
"metadata": {
|
||
"id": "nbEDdjmgyNLE",
|
||
"outputId": "c5b79e79-346d-4bde-b750-98e2cb58c813",
|
||
"colab": {
|
||
"base_uri": "https://localhost:8080/"
|
||
}
|
||
},
|
||
"execution_count": 101,
|
||
"outputs": [
|
||
{
|
||
"output_type": "stream",
|
||
"name": "stdout",
|
||
"text": [
|
||
"{\n",
|
||
" \"choices\": [\n",
|
||
" {\n",
|
||
" \"finish_reason\": \"stop\",\n",
|
||
" \"index\": 0,\n",
|
||
" \"message\": {\n",
|
||
" \"content\": \"Based on your preferences, I would suggest trying a Pinot Noir from Oregon or Burgundy. Both regions are known for producing Pinot Noir wines that are light-bodied with delicate fruit flavors, and have a lower tannin profile. Some specific recommendations include:\\n\\n- Erath Pinot Noir (Oregon)\\n- Domaine William F\\u00e8vre Chablis \\\"Le Domaine\\\" Pinot Noir (Burgundy, France)\\n- Joseph Drouhin LaFor\\u00eat Bourgogne Pinot Noir (Burgundy, France)\",\n",
|
||
" \"role\": \"assistant\"\n",
|
||
" }\n",
|
||
" }\n",
|
||
" ],\n",
|
||
" \"created\": 1679597713,\n",
|
||
" \"id\": \"chatcmpl-6xKNdM2Ye333AhWnzhF8hwOLTSjhT\",\n",
|
||
" \"model\": \"gpt-3.5-turbo-0301\",\n",
|
||
" \"object\": \"chat.completion\",\n",
|
||
" \"usage\": {\n",
|
||
" \"completion_tokens\": 108,\n",
|
||
" \"prompt_tokens\": 164,\n",
|
||
" \"total_tokens\": 272\n",
|
||
" }\n",
|
||
"}\n"
|
||
]
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"source": [],
|
||
"metadata": {
|
||
"id": "F_H-PxFL0lzw"
|
||
},
|
||
"execution_count": null,
|
||
"outputs": []
|
||
}
|
||
],
|
||
"metadata": {
|
||
"colab": {
|
||
"provenance": []
|
||
},
|
||
"kernelspec": {
|
||
"display_name": "Python 3",
|
||
"name": "python3"
|
||
},
|
||
"language_info": {
|
||
"name": "python"
|
||
},
|
||
"accelerator": "GPU",
|
||
"gpuClass": "standard"
|
||
},
|
||
"nbformat": 4,
|
||
"nbformat_minor": 0
|
||
} |