{ "cells": [ { "cell_type": "code", "execution_count": 26, "id": "51d0f551", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: nltk in ./anaconda3/lib/python3.11/site-packages (3.8.1)\n", "Requirement already satisfied: click in ./anaconda3/lib/python3.11/site-packages (from nltk) (8.0.4)\n", "Requirement already satisfied: joblib in ./anaconda3/lib/python3.11/site-packages (from nltk) (1.2.0)\n", "Requirement already satisfied: regex>=2021.8.3 in ./anaconda3/lib/python3.11/site-packages (from nltk) (2022.7.9)\n", "Requirement already satisfied: tqdm in ./anaconda3/lib/python3.11/site-packages (from nltk) (4.65.0)\n", "Requirement already satisfied: tensorflow in ./anaconda3/lib/python3.11/site-packages (2.17.0)\n", "Requirement already satisfied: absl-py>=1.0.0 in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (2.1.0)\n", "Requirement already satisfied: astunparse>=1.6.0 in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (1.6.3)\n", "Requirement already satisfied: flatbuffers>=24.3.25 in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (24.3.25)\n", "Requirement already satisfied: gast!=0.5.0,!=0.5.1,!=0.5.2,>=0.2.1 in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (0.6.0)\n", "Requirement already satisfied: google-pasta>=0.1.1 in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (0.2.0)\n", "Requirement already satisfied: h5py>=3.10.0 in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (3.11.0)\n", "Requirement already satisfied: libclang>=13.0.0 in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (18.1.1)\n", "Requirement already satisfied: ml-dtypes<0.5.0,>=0.3.1 in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (0.4.0)\n", "Requirement already satisfied: opt-einsum>=2.3.2 in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (3.3.0)\n", "Requirement already satisfied: packaging in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (23.1)\n", "Requirement already satisfied: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.20.3 in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (4.25.4)\n", "Requirement already satisfied: requests<3,>=2.21.0 in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (2.31.0)\n", "Requirement already satisfied: setuptools in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (68.0.0)\n", "Requirement already satisfied: six>=1.12.0 in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (1.16.0)\n", "Requirement already satisfied: termcolor>=1.1.0 in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (2.4.0)\n", "Requirement already satisfied: typing-extensions>=3.6.6 in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (4.9.0)\n", "Requirement already satisfied: wrapt>=1.11.0 in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (1.14.1)\n", "Requirement already satisfied: grpcio<2.0,>=1.24.3 in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (1.65.4)\n", "Requirement already satisfied: tensorboard<2.18,>=2.17 in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (2.17.0)\n", "Requirement already satisfied: keras>=3.2.0 in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (3.4.1)\n", "Requirement already satisfied: tensorflow-io-gcs-filesystem>=0.23.1 in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (0.37.1)\n", "Requirement already satisfied: numpy<2.0.0,>=1.23.5 in ./anaconda3/lib/python3.11/site-packages (from tensorflow) (1.24.3)\n", "Requirement already satisfied: wheel<1.0,>=0.23.0 in ./anaconda3/lib/python3.11/site-packages (from astunparse>=1.6.0->tensorflow) (0.38.4)\n", "Requirement already satisfied: rich in ./anaconda3/lib/python3.11/site-packages (from keras>=3.2.0->tensorflow) (13.7.1)\n", "Requirement already satisfied: namex in ./anaconda3/lib/python3.11/site-packages (from keras>=3.2.0->tensorflow) (0.0.8)\n", "Requirement already satisfied: optree in ./anaconda3/lib/python3.11/site-packages (from keras>=3.2.0->tensorflow) (0.12.1)\n", "Requirement already satisfied: charset-normalizer<4,>=2 in ./anaconda3/lib/python3.11/site-packages (from requests<3,>=2.21.0->tensorflow) (2.0.4)\n", "Requirement already satisfied: idna<4,>=2.5 in ./anaconda3/lib/python3.11/site-packages (from requests<3,>=2.21.0->tensorflow) (3.4)\n", "Requirement already satisfied: urllib3<3,>=1.21.1 in ./anaconda3/lib/python3.11/site-packages (from requests<3,>=2.21.0->tensorflow) (1.26.16)\n", "Requirement already satisfied: certifi>=2017.4.17 in ./anaconda3/lib/python3.11/site-packages (from requests<3,>=2.21.0->tensorflow) (2023.7.22)\n", "Requirement already satisfied: markdown>=2.6.8 in ./anaconda3/lib/python3.11/site-packages (from tensorboard<2.18,>=2.17->tensorflow) (3.4.1)\n", "Requirement already satisfied: tensorboard-data-server<0.8.0,>=0.7.0 in ./anaconda3/lib/python3.11/site-packages (from tensorboard<2.18,>=2.17->tensorflow) (0.7.2)\n", "Requirement already satisfied: werkzeug>=1.0.1 in ./anaconda3/lib/python3.11/site-packages (from tensorboard<2.18,>=2.17->tensorflow) (2.2.3)\n", "Requirement already satisfied: MarkupSafe>=2.1.1 in ./anaconda3/lib/python3.11/site-packages (from werkzeug>=1.0.1->tensorboard<2.18,>=2.17->tensorflow) (2.1.1)\n", "Requirement already satisfied: markdown-it-py>=2.2.0 in ./anaconda3/lib/python3.11/site-packages (from rich->keras>=3.2.0->tensorflow) (2.2.0)\n", "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in ./anaconda3/lib/python3.11/site-packages (from rich->keras>=3.2.0->tensorflow) (2.15.1)\n", "Requirement already satisfied: mdurl~=0.1 in ./anaconda3/lib/python3.11/site-packages (from markdown-it-py>=2.2.0->rich->keras>=3.2.0->tensorflow) (0.1.0)\n" ] } ], "source": [ "!pip install nltk\n", "!pip install tensorflow" ] }, { "cell_type": "code", "execution_count": 27, "id": "16af452c", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "[nltk_data] Downloading package punkt to\n", "[nltk_data] /Users/preethamreddygollapalli/nltk_data...\n", "[nltk_data] Package punkt is already up-to-date!\n" ] }, { "data": { "text/plain": [ "True" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandas as pd\n", "import numpy as np\n", "import re\n", "import string\n", "import nltk\n", "from nltk.tokenize import sent_tokenize # tries to convert paragraph to sentences\n", "from nltk.tokenize import word_tokenize\n", "from nltk.stem import WordNetLemmatizer\n", "from nltk.corpus import stopwords\n", "from gensim.models import Word2Vec\n", "import ast\n", "import tensorflow as tf\n", "from sklearn.model_selection import train_test_split\n", "from sklearn.preprocessing import LabelEncoder\n", "from keras.preprocessing.sequence import pad_sequences\n", "from tensorflow.keras.models import Sequential\n", "from tensorflow.keras.layers import Dense, Dropout, LSTM, Embedding\n", "from tensorflow.keras.metrics import MeanAbsoluteError\n", "from sklearn.metrics import r2_score\n", "\n", "nltk.download('punkt')" ] }, { "cell_type": "code", "execution_count": 28, "id": "4ada6af5", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Story NameTest case Acceptance criteriaTest StepsTest DataExpected Result
0ACIP-247941Weekly Ad - tap on any product offer - tap on ...User logs into UMA application with valid user...Email: dnfcontentqa2_2@mail7.io, Albertsons= 8...User navigates to Home page on UMA application...
1ACIP-95038As a PdM, I want to ensure that the L2 entry p...Login UMA app with valid email/ mobile no. Ver...NaNUser should be able to login successfully and ...
2US-41769As a customer, I should see age restriction me...Login UMA app with valid email/ mobile no. Ent...NaNYour order contains age-restricted items. Some...
3ACIP-237923Verify Banner navigation for the below banners...User logs into UMA application with valid user...Email: dnfcontentqa2_2@mail7.io, Albertsons= 8...User navigates to Home page on UMA application...
4ACIP-234885Display the Meal Plans banner based on the ban...User logs into UMA application with valid user...Email: dnfcontentqa2_2@mail7.io / any new user...User navigates to Home page on UMA application...
\n", "
" ], "text/plain": [ " Story Name Test case Acceptance criteria \\\n", "0 ACIP-247941 Weekly Ad - tap on any product offer - tap on ... \n", "1 ACIP-95038 As a PdM, I want to ensure that the L2 entry p... \n", "2 US-41769 As a customer, I should see age restriction me... \n", "3 ACIP-237923 Verify Banner navigation for the below banners... \n", "4 ACIP-234885 Display the Meal Plans banner based on the ban... \n", "\n", " Test Steps \\\n", "0 User logs into UMA application with valid user... \n", "1 Login UMA app with valid email/ mobile no. Ver... \n", "2 Login UMA app with valid email/ mobile no. Ent... \n", "3 User logs into UMA application with valid user... \n", "4 User logs into UMA application with valid user... \n", "\n", " Test Data \\\n", "0 Email: dnfcontentqa2_2@mail7.io, Albertsons= 8... \n", "1 NaN \n", "2 NaN \n", "3 Email: dnfcontentqa2_2@mail7.io, Albertsons= 8... \n", "4 Email: dnfcontentqa2_2@mail7.io / any new user... \n", "\n", " Expected Result \n", "0 User navigates to Home page on UMA application... \n", "1 User should be able to login successfully and ... \n", "2 Your order contains age-restricted items. Some... \n", "3 User navigates to Home page on UMA application... \n", "4 User navigates to Home page on UMA application... " ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pd.read_csv(\"/Users/preethamreddygollapalli/Downloads/AI Test cases (2).csv\")\n", "df.head(5)" ] }, { "cell_type": "code", "execution_count": 29, "id": "b74aecf9", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Story Name object\n", "Test case Acceptance criteria object\n", "Test Steps object\n", "Test Data object\n", "Expected Result object\n", "dtype: object" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.dtypes" ] }, { "cell_type": "code", "execution_count": 30, "id": "1468adf1", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(5, 5)" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.shape" ] }, { "cell_type": "code", "execution_count": 31, "id": "bf818e79", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Story NameTest case Acceptance criteriaTest StepsTest DataExpected Result
count55535
unique55535
topACIP-247941Weekly Ad - tap on any product offer - tap on ...User logs into UMA application with valid user...Email: dnfcontentqa2_2@mail7.io, Albertsons= 8...User navigates to Home page on UMA application...
freq11111
\n", "
" ], "text/plain": [ " Story Name Test case Acceptance criteria \\\n", "count 5 5 \n", "unique 5 5 \n", "top ACIP-247941 Weekly Ad - tap on any product offer - tap on ... \n", "freq 1 1 \n", "\n", " Test Steps \\\n", "count 5 \n", "unique 5 \n", "top User logs into UMA application with valid user... \n", "freq 1 \n", "\n", " Test Data \\\n", "count 3 \n", "unique 3 \n", "top Email: dnfcontentqa2_2@mail7.io, Albertsons= 8... \n", "freq 1 \n", "\n", " Expected Result \n", "count 5 \n", "unique 5 \n", "top User navigates to Home page on UMA application... \n", "freq 1 " ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.describe()" ] }, { "cell_type": "code", "execution_count": 32, "id": "dd77a3b7", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Test case Acceptance criteriaTest StepsExpected Result
0Weekly Ad - tap on any product offer - tap on ...User logs into UMA application with valid user...User navigates to Home page on UMA application...
1As a PdM, I want to ensure that the L2 entry p...Login UMA app with valid email/ mobile no. Ver...User should be able to login successfully and ...
2As a customer, I should see age restriction me...Login UMA app with valid email/ mobile no. Ent...Your order contains age-restricted items. Some...
3Verify Banner navigation for the below banners...User logs into UMA application with valid user...User navigates to Home page on UMA application...
4Display the Meal Plans banner based on the ban...User logs into UMA application with valid user...User navigates to Home page on UMA application...
\n", "
" ], "text/plain": [ " Test case Acceptance criteria \\\n", "0 Weekly Ad - tap on any product offer - tap on ... \n", "1 As a PdM, I want to ensure that the L2 entry p... \n", "2 As a customer, I should see age restriction me... \n", "3 Verify Banner navigation for the below banners... \n", "4 Display the Meal Plans banner based on the ban... \n", "\n", " Test Steps \\\n", "0 User logs into UMA application with valid user... \n", "1 Login UMA app with valid email/ mobile no. Ver... \n", "2 Login UMA app with valid email/ mobile no. Ent... \n", "3 User logs into UMA application with valid user... \n", "4 User logs into UMA application with valid user... \n", "\n", " Expected Result \n", "0 User navigates to Home page on UMA application... \n", "1 User should be able to login successfully and ... \n", "2 Your order contains age-restricted items. Some... \n", "3 User navigates to Home page on UMA application... \n", "4 User navigates to Home page on UMA application... " ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = df.drop(['Story Name', 'Test Data'], axis = 1)\n", "df.head(5)" ] }, { "cell_type": "code", "execution_count": 9, "id": "b775b74d", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Test case Acceptance criteriaTest StepsExpected ResultTest_case_Acceptance_criteriaTest_StepsExpected_Result
0Weekly Ad - tap on any product offer - tap on ...User logs into UMA application with valid user...User navigates to Home page on UMA application...[Weekly, Ad, -, tap, on, any, product, offer, ...[User, logs, into, UMA, application, with, val...[User, navigates, to, Home, page, on, UMA, app...
1As a PdM, I want to ensure that the L2 entry p...Login UMA app with valid email/ mobile no. Ver...User should be able to login successfully and ...[As, a, PdM,, I, want, to, ensure, that, the, ...[Login, UMA, app, with, valid, email/, mobile,...[User, should, be, able, to, login, successful...
2As a customer, I should see age restriction me...Login UMA app with valid email/ mobile no. Ent...Your order contains age-restricted items. Some...[As, a, customer,, I, should, see, age, restri...[Login, UMA, app, with, valid, email/, mobile,...[Your, order, contains, age-restricted, items....
3Verify Banner navigation for the below banners...User logs into UMA application with valid user...User navigates to Home page on UMA application...[Verify, Banner, navigation, for, the, below, ...[User, logs, into, UMA, application, with, val...[User, navigates, to, Home, page, on, UMA, app...
4Display the Meal Plans banner based on the ban...User logs into UMA application with valid user...User navigates to Home page on UMA application...[Display, the, Meal, Plans, banner, based, on,...[User, logs, into, UMA, application, with, val...[User, navigates, to, Home, page, on, UMA, app...
\n", "
" ], "text/plain": [ " Test case Acceptance criteria \\\n", "0 Weekly Ad - tap on any product offer - tap on ... \n", "1 As a PdM, I want to ensure that the L2 entry p... \n", "2 As a customer, I should see age restriction me... \n", "3 Verify Banner navigation for the below banners... \n", "4 Display the Meal Plans banner based on the ban... \n", "\n", " Test Steps \\\n", "0 User logs into UMA application with valid user... \n", "1 Login UMA app with valid email/ mobile no. Ver... \n", "2 Login UMA app with valid email/ mobile no. Ent... \n", "3 User logs into UMA application with valid user... \n", "4 User logs into UMA application with valid user... \n", "\n", " Expected Result \\\n", "0 User navigates to Home page on UMA application... \n", "1 User should be able to login successfully and ... \n", "2 Your order contains age-restricted items. Some... \n", "3 User navigates to Home page on UMA application... \n", "4 User navigates to Home page on UMA application... \n", "\n", " Test_case_Acceptance_criteria \\\n", "0 [Weekly, Ad, -, tap, on, any, product, offer, ... \n", "1 [As, a, PdM,, I, want, to, ensure, that, the, ... \n", "2 [As, a, customer,, I, should, see, age, restri... \n", "3 [Verify, Banner, navigation, for, the, below, ... \n", "4 [Display, the, Meal, Plans, banner, based, on,... \n", "\n", " Test_Steps \\\n", "0 [User, logs, into, UMA, application, with, val... \n", "1 [Login, UMA, app, with, valid, email/, mobile,... \n", "2 [Login, UMA, app, with, valid, email/, mobile,... \n", "3 [User, logs, into, UMA, application, with, val... \n", "4 [User, logs, into, UMA, application, with, val... \n", "\n", " Expected_Result \n", "0 [User, navigates, to, Home, page, on, UMA, app... \n", "1 [User, should, be, able, to, login, successful... \n", "2 [Your, order, contains, age-restricted, items.... \n", "3 [User, navigates, to, Home, page, on, UMA, app... \n", "4 [User, navigates, to, Home, page, on, UMA, app... " ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Tokenize the strings by splitting on spaces\n", "df['Test_case_Acceptance_criteria'] = df['Test case Acceptance criteria'].apply(lambda x: x.split() if isinstance(x, str) else [])\n", "df['Test_Steps'] = df['Test Steps'].apply(lambda x: x.split() if isinstance(x, str) else [])\n", "df['Expected_Result'] = df['Expected Result'].apply(lambda x: x.split() if isinstance(x, str) else [])\n", "\n", "# Inspect the tokenized data\n", "df.head(5)" ] }, { "cell_type": "code", "execution_count": 10, "id": "61e06a49", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Test case Acceptance criteria 0\n", "Test Steps 0\n", "Expected Result 0\n", "Test_case_Acceptance_criteria 0\n", "Test_Steps 0\n", "Expected_Result 0\n", "dtype: int64\n" ] } ], "source": [ "print(df.isna().sum())" ] }, { "cell_type": "code", "execution_count": 11, "id": "ca46d0a6", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Test_case_Acceptance_criteriaTest_StepsExpected_Result
0[Weekly, Ad, -, tap, on, any, product, offer, ...[User, logs, into, UMA, application, with, val...[User, navigates, to, Home, page, on, UMA, app...
1[As, a, PdM,, I, want, to, ensure, that, the, ...[Login, UMA, app, with, valid, email/, mobile,...[User, should, be, able, to, login, successful...
2[As, a, customer,, I, should, see, age, restri...[Login, UMA, app, with, valid, email/, mobile,...[Your, order, contains, age-restricted, items....
3[Verify, Banner, navigation, for, the, below, ...[User, logs, into, UMA, application, with, val...[User, navigates, to, Home, page, on, UMA, app...
4[Display, the, Meal, Plans, banner, based, on,...[User, logs, into, UMA, application, with, val...[User, navigates, to, Home, page, on, UMA, app...
\n", "
" ], "text/plain": [ " Test_case_Acceptance_criteria \\\n", "0 [Weekly, Ad, -, tap, on, any, product, offer, ... \n", "1 [As, a, PdM,, I, want, to, ensure, that, the, ... \n", "2 [As, a, customer,, I, should, see, age, restri... \n", "3 [Verify, Banner, navigation, for, the, below, ... \n", "4 [Display, the, Meal, Plans, banner, based, on,... \n", "\n", " Test_Steps \\\n", "0 [User, logs, into, UMA, application, with, val... \n", "1 [Login, UMA, app, with, valid, email/, mobile,... \n", "2 [Login, UMA, app, with, valid, email/, mobile,... \n", "3 [User, logs, into, UMA, application, with, val... \n", "4 [User, logs, into, UMA, application, with, val... \n", "\n", " Expected_Result \n", "0 [User, navigates, to, Home, page, on, UMA, app... \n", "1 [User, should, be, able, to, login, successful... \n", "2 [Your, order, contains, age-restricted, items.... \n", "3 [User, navigates, to, Home, page, on, UMA, app... \n", "4 [User, navigates, to, Home, page, on, UMA, app... " ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = df.drop(['Test case Acceptance criteria', 'Test Steps', 'Expected Result'], axis = 1)\n", "df.head(5)" ] }, { "cell_type": "code", "execution_count": 12, "id": "f211722a", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Test_case_Acceptance_criteriaTest_StepsExpected_Result
0[Weekly, Ad, -, tap, product, offer, -, tap, A...[User, logs, UMA, application, valid, user's, ...[User, navigates, Home, page, UMA, application...
1[PdM,, want, ensure, L2, entry, points, workin...[Login, UMA, app, valid, email/, mobile, no., ...[User, able, login, successfully, home, page, ...
2[customer,, see, age, restriction, message, ch...[Login, UMA, app, valid, email/, mobile, no., ...[order, contains, age-restricted, items., Some...
3[Verify, Banner, navigation, banners, places, ...[User, logs, UMA, application, valid, user's, ...[User, navigates, Home, page, UMA, application...
4[Display, Meal, Plans, banner, based, banner.,...[User, logs, UMA, application, valid, user's, ...[User, navigates, Home, page, UMA, application...
\n", "
" ], "text/plain": [ " Test_case_Acceptance_criteria \\\n", "0 [Weekly, Ad, -, tap, product, offer, -, tap, A... \n", "1 [PdM,, want, ensure, L2, entry, points, workin... \n", "2 [customer,, see, age, restriction, message, ch... \n", "3 [Verify, Banner, navigation, banners, places, ... \n", "4 [Display, Meal, Plans, banner, based, banner.,... \n", "\n", " Test_Steps \\\n", "0 [User, logs, UMA, application, valid, user's, ... \n", "1 [Login, UMA, app, valid, email/, mobile, no., ... \n", "2 [Login, UMA, app, valid, email/, mobile, no., ... \n", "3 [User, logs, UMA, application, valid, user's, ... \n", "4 [User, logs, UMA, application, valid, user's, ... \n", "\n", " Expected_Result \n", "0 [User, navigates, Home, page, UMA, application... \n", "1 [User, able, login, successfully, home, page, ... \n", "2 [order, contains, age-restricted, items., Some... \n", "3 [User, navigates, Home, page, UMA, application... \n", "4 [User, navigates, Home, page, UMA, application... " ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stop_words = set(stopwords.words('english'))\n", "\n", "# Function to remove stopwords\n", "def remove_stopwords(tokens):\n", " return [token for token in tokens if token.lower() not in stop_words]\n", "\n", "# Apply stopwords removal\n", "df['Test_case_Acceptance_criteria'] = df['Test_case_Acceptance_criteria'].apply(remove_stopwords)\n", "df['Test_Steps'] = df['Test_Steps'].apply(remove_stopwords)\n", "df['Expected_Result'] = df['Expected_Result'].apply(remove_stopwords)\n", "\n", "# Inspect the data after stopwords removal\n", "df.head(5)" ] }, { "cell_type": "code", "execution_count": 14, "id": "057555fe", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Test_case_Acceptance_criteriaTest_StepsExpected_Result
0[Weekly, Ad, -, tap, product, offer, -, tap, A...[User, log, UMA, application, valid, user's, c...[User, navigate, Home, page, UMA, application....
1[PdM,, want, ensure, L2, entry, point, work, f...[Login, UMA, app, valid, email/, mobile, no., ...[User, able, login, successfully, home, page, ...
2[customer,, see, age, restriction, message, ch...[Login, UMA, app, valid, email/, mobile, no., ...[order, contain, age-restricted, items., Someo...
3[Verify, Banner, navigation, banner, place, di...[User, log, UMA, application, valid, user's, c...[User, navigate, Home, page, UMA, application,...
4[Display, Meal, Plans, banner, base, banner., ...[User, log, UMA, application, valid, user's, c...[User, navigate, Home, page, UMA, application....
\n", "
" ], "text/plain": [ " Test_case_Acceptance_criteria \\\n", "0 [Weekly, Ad, -, tap, product, offer, -, tap, A... \n", "1 [PdM,, want, ensure, L2, entry, point, work, f... \n", "2 [customer,, see, age, restriction, message, ch... \n", "3 [Verify, Banner, navigation, banner, place, di... \n", "4 [Display, Meal, Plans, banner, base, banner., ... \n", "\n", " Test_Steps \\\n", "0 [User, log, UMA, application, valid, user's, c... \n", "1 [Login, UMA, app, valid, email/, mobile, no., ... \n", "2 [Login, UMA, app, valid, email/, mobile, no., ... \n", "3 [User, log, UMA, application, valid, user's, c... \n", "4 [User, log, UMA, application, valid, user's, c... \n", "\n", " Expected_Result \n", "0 [User, navigate, Home, page, UMA, application.... \n", "1 [User, able, login, successfully, home, page, ... \n", "2 [order, contain, age-restricted, items., Someo... \n", "3 [User, navigate, Home, page, UMA, application,... \n", "4 [User, navigate, Home, page, UMA, application.... " ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "lemmatizer = WordNetLemmatizer()\n", "\n", "# Function to lemmatize tokens\n", "def lemmatize_tokens(tokens):\n", " return [lemmatizer.lemmatize(token, pos = 'v') for token in tokens]\n", "\n", "# Apply lemmatization\n", "df['Test_case_Acceptance_criteria'] = df['Test_case_Acceptance_criteria'].apply(lemmatize_tokens)\n", "df['Test_Steps'] = df['Test_Steps'].apply(lemmatize_tokens)\n", "df['Expected_Result'] = df['Expected_Result'].apply(lemmatize_tokens)\n", "\n", "# Inspect the data after lemmatization\n", "df.head(5)" ] }, { "cell_type": "code", "execution_count": 15, "id": "249dd661", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Test_case_Acceptance_criteriaTest_StepsExpected_ResultAcceptance_criteria_embeddingsTest_Steps_embeddingsExpected_Result_embeddings
0[Weekly, Ad, -, tap, product, offer, -, tap, A...[User, log, UMA, application, valid, user's, c...[User, navigate, Home, page, UMA, application....[2.9078821e-05, 0.0009868374, 0.0006897929, 0....[-0.00090376585, 0.0015351841, 0.00077817513, ...[-0.00075740286, 0.0017703008, 7.018649e-05, 0...
1[PdM,, want, ensure, L2, entry, point, work, f...[Login, UMA, app, valid, email/, mobile, no., ...[User, able, login, successfully, home, page, ...[4.9687253e-05, -0.0002648631, -0.0011476703, ...[-0.0007915226, 0.0008593759, 0.00056966604, -...[0.00035405744, 0.0019673503, -0.00071650144, ...
2[customer,, see, age, restriction, message, ch...[Login, UMA, app, valid, email/, mobile, no., ...[order, contain, age-restricted, items., Someo...[-0.0019043502, -0.0007733393, -0.00047627056,...[-0.0010107799, -0.0004325275, 0.0025766247, 0...[-0.0022062701, -0.0032818727, 0.0012025184, -...
3[Verify, Banner, navigation, banner, place, di...[User, log, UMA, application, valid, user's, c...[User, navigate, Home, page, UMA, application,...[0.00079187436, 0.001024591, -0.00025014183, -...[-0.00082380656, 0.0015335361, 0.0008829938, 0...[-0.0007905865, 0.0017265088, 0.00018967084, 0...
4[Display, Meal, Plans, banner, base, banner., ...[User, log, UMA, application, valid, user's, c...[User, navigate, Home, page, UMA, application....[0.0006987122, 0.0025012388, 0.00094601634, -0...[-0.0006520124, 0.00076459144, 0.0014451812, 0...[-0.00028285536, 0.0013591949, -0.00073397934,...
\n", "
" ], "text/plain": [ " Test_case_Acceptance_criteria \\\n", "0 [Weekly, Ad, -, tap, product, offer, -, tap, A... \n", "1 [PdM,, want, ensure, L2, entry, point, work, f... \n", "2 [customer,, see, age, restriction, message, ch... \n", "3 [Verify, Banner, navigation, banner, place, di... \n", "4 [Display, Meal, Plans, banner, base, banner., ... \n", "\n", " Test_Steps \\\n", "0 [User, log, UMA, application, valid, user's, c... \n", "1 [Login, UMA, app, valid, email/, mobile, no., ... \n", "2 [Login, UMA, app, valid, email/, mobile, no., ... \n", "3 [User, log, UMA, application, valid, user's, c... \n", "4 [User, log, UMA, application, valid, user's, c... \n", "\n", " Expected_Result \\\n", "0 [User, navigate, Home, page, UMA, application.... \n", "1 [User, able, login, successfully, home, page, ... \n", "2 [order, contain, age-restricted, items., Someo... \n", "3 [User, navigate, Home, page, UMA, application,... \n", "4 [User, navigate, Home, page, UMA, application.... \n", "\n", " Acceptance_criteria_embeddings \\\n", "0 [2.9078821e-05, 0.0009868374, 0.0006897929, 0.... \n", "1 [4.9687253e-05, -0.0002648631, -0.0011476703, ... \n", "2 [-0.0019043502, -0.0007733393, -0.00047627056,... \n", "3 [0.00079187436, 0.001024591, -0.00025014183, -... \n", "4 [0.0006987122, 0.0025012388, 0.00094601634, -0... \n", "\n", " Test_Steps_embeddings \\\n", "0 [-0.00090376585, 0.0015351841, 0.00077817513, ... \n", "1 [-0.0007915226, 0.0008593759, 0.00056966604, -... \n", "2 [-0.0010107799, -0.0004325275, 0.0025766247, 0... \n", "3 [-0.00082380656, 0.0015335361, 0.0008829938, 0... \n", "4 [-0.0006520124, 0.00076459144, 0.0014451812, 0... \n", "\n", " Expected_Result_embeddings \n", "0 [-0.00075740286, 0.0017703008, 7.018649e-05, 0... \n", "1 [0.00035405744, 0.0019673503, -0.00071650144, ... \n", "2 [-0.0022062701, -0.0032818727, 0.0012025184, -... \n", "3 [-0.0007905865, 0.0017265088, 0.00018967084, 0... \n", "4 [-0.00028285536, 0.0013591949, -0.00073397934,... " ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "all_tokens = df['Test_case_Acceptance_criteria'].tolist() + df['Test_Steps'].tolist() + df['Expected_Result'].tolist()\n", "\n", "# Train the Word2Vec model\n", "word2vec_model = Word2Vec(sentences=all_tokens, vector_size=100, window=5, min_count=1, sg=0)\n", "\n", "# Function to get embeddings for tokens\n", "def get_embeddings(tokens, model):\n", " embeddings = []\n", " for token in tokens:\n", " if token in model.wv:\n", " embeddings.append(model.wv[token])\n", " else:\n", " embeddings.append(np.zeros(model.vector_size)) # Handle out-of-vocabulary words\n", " return np.mean(embeddings, axis=0) # Mean vector for the document\n", "\n", "# Apply the function to each column\n", "df['Acceptance_criteria_embeddings'] = df['Test_case_Acceptance_criteria'].apply(lambda tokens: get_embeddings(tokens, word2vec_model) if tokens else np.nan)\n", "df['Test_Steps_embeddings'] = df['Test_Steps'].apply(lambda tokens: get_embeddings(tokens, word2vec_model) if tokens else np.nan)\n", "df['Expected_Result_embeddings'] = df['Expected_Result'].apply(lambda tokens: get_embeddings(tokens, word2vec_model) if tokens else np.nan)\n", "\n", "# Verify the final DataFrame\n", "df.head(5)" ] }, { "cell_type": "code", "execution_count": 16, "id": "f36d8564", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Acceptance_criteria_embeddingsTest_Steps_embeddingsExpected_Result_embeddings
0[2.9078821e-05, 0.0009868374, 0.0006897929, 0....[-0.00090376585, 0.0015351841, 0.00077817513, ...[-0.00075740286, 0.0017703008, 7.018649e-05, 0...
1[4.9687253e-05, -0.0002648631, -0.0011476703, ...[-0.0007915226, 0.0008593759, 0.00056966604, -...[0.00035405744, 0.0019673503, -0.00071650144, ...
2[-0.0019043502, -0.0007733393, -0.00047627056,...[-0.0010107799, -0.0004325275, 0.0025766247, 0...[-0.0022062701, -0.0032818727, 0.0012025184, -...
3[0.00079187436, 0.001024591, -0.00025014183, -...[-0.00082380656, 0.0015335361, 0.0008829938, 0...[-0.0007905865, 0.0017265088, 0.00018967084, 0...
4[0.0006987122, 0.0025012388, 0.00094601634, -0...[-0.0006520124, 0.00076459144, 0.0014451812, 0...[-0.00028285536, 0.0013591949, -0.00073397934,...
\n", "
" ], "text/plain": [ " Acceptance_criteria_embeddings \\\n", "0 [2.9078821e-05, 0.0009868374, 0.0006897929, 0.... \n", "1 [4.9687253e-05, -0.0002648631, -0.0011476703, ... \n", "2 [-0.0019043502, -0.0007733393, -0.00047627056,... \n", "3 [0.00079187436, 0.001024591, -0.00025014183, -... \n", "4 [0.0006987122, 0.0025012388, 0.00094601634, -0... \n", "\n", " Test_Steps_embeddings \\\n", "0 [-0.00090376585, 0.0015351841, 0.00077817513, ... \n", "1 [-0.0007915226, 0.0008593759, 0.00056966604, -... \n", "2 [-0.0010107799, -0.0004325275, 0.0025766247, 0... \n", "3 [-0.00082380656, 0.0015335361, 0.0008829938, 0... \n", "4 [-0.0006520124, 0.00076459144, 0.0014451812, 0... \n", "\n", " Expected_Result_embeddings \n", "0 [-0.00075740286, 0.0017703008, 7.018649e-05, 0... \n", "1 [0.00035405744, 0.0019673503, -0.00071650144, ... \n", "2 [-0.0022062701, -0.0032818727, 0.0012025184, -... \n", "3 [-0.0007905865, 0.0017265088, 0.00018967084, 0... \n", "4 [-0.00028285536, 0.0013591949, -0.00073397934,... " ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = df.drop(['Test_case_Acceptance_criteria', 'Test_Steps', 'Expected_Result'], axis = 1)\n", "df.head(5)" ] }, { "cell_type": "code", "execution_count": 17, "id": "53d82554", "metadata": {}, "outputs": [], "source": [ "X = np.array(df['Acceptance_criteria_embeddings'].tolist())\n", "y_test_steps = np.array(df['Test_Steps_embeddings'].tolist())\n", "y_expected_result = np.array(df['Expected_Result_embeddings'].tolist())\n", "\n", "# Reshape data for LSTM: (samples, timesteps, features)\n", "X = X.reshape((X.shape[0], 1, X.shape[1]))\n", "y_test_steps = y_test_steps.reshape((y_test_steps.shape[0], 1, y_test_steps.shape[1]))\n", "y_expected_result = y_expected_result.reshape((y_expected_result.shape[0], 1, y_expected_result.shape[1]))\n", "\n", "# Split the data into training and testing sets\n", "X_train, X_test, y_train_test_steps, y_test_test_steps = train_test_split(X, y_test_steps, test_size=0.2, random_state=42)\n", "_, _, y_train_expected_result, y_test_expected_result = train_test_split(X, y_expected_result, test_size=0.2, random_state=42)" ] }, { "cell_type": "code", "execution_count": 18, "id": "dc4930ed", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/preethamreddygollapalli/anaconda3/lib/python3.11/site-packages/keras/src/layers/rnn/rnn.py:204: UserWarning: Do not pass an `input_shape`/`input_dim` argument to a layer. When using Sequential models, prefer using an `Input(shape)` object as the first layer in the model instead.\n", " super().__init__(**kwargs)\n" ] } ], "source": [ "from tensorflow.keras.layers import LSTM, Dense, TimeDistributed\n", "\n", "# Define the model for Test Steps\n", "model_test_steps = Sequential([\n", " LSTM(50, activation='relu', input_shape=(X_train.shape[1], X_train.shape[2]), return_sequences=True),\n", " TimeDistributed(Dense(X_train.shape[2]))\n", "])\n", "\n", "model_test_steps.compile(optimizer='adam', loss='mse')\n", "\n", "# Define the model for Expected Result\n", "model_expected_result = Sequential([\n", " LSTM(50, activation='relu', input_shape=(X_train.shape[1], X_train.shape[2]), return_sequences=True),\n", " TimeDistributed(Dense(X_train.shape[2]))\n", "])\n", "\n", "model_expected_result.compile(optimizer='adam', loss='mse')" ] }, { "cell_type": "code", "execution_count": 19, "id": "f7e70874", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Epoch 1/10\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m1s\u001b[0m 533ms/step - loss: 2.2174e-06 - val_loss: 9.4766e-07\n", "Epoch 2/10\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 13ms/step - loss: 1.0551e-06 - val_loss: 6.0476e-07\n", "Epoch 3/10\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 15ms/step - loss: 8.6695e-07 - val_loss: 6.1300e-07\n", "Epoch 4/10\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 15ms/step - loss: 9.7589e-07 - val_loss: 6.2904e-07\n", "Epoch 5/10\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 14ms/step - loss: 1.0319e-06 - val_loss: 6.0141e-07\n", "Epoch 6/10\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 14ms/step - loss: 9.9991e-07 - val_loss: 5.6963e-07\n", "Epoch 7/10\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 27ms/step - loss: 9.3908e-07 - val_loss: 5.5550e-07\n", "Epoch 8/10\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 14ms/step - loss: 8.8153e-07 - val_loss: 5.5216e-07\n", "Epoch 9/10\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 14ms/step - loss: 8.3433e-07 - val_loss: 5.5272e-07\n", "Epoch 10/10\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 14ms/step - loss: 8.0194e-07 - val_loss: 5.5084e-07\n", "Epoch 1/10\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m1s\u001b[0m 617ms/step - loss: 2.4237e-06 - val_loss: 1.0210e-06\n", "Epoch 2/10\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 14ms/step - loss: 1.4453e-06 - val_loss: 8.3659e-07\n", "Epoch 3/10\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 15ms/step - loss: 1.2441e-06 - val_loss: 9.3372e-07\n", "Epoch 4/10\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 15ms/step - loss: 1.3035e-06 - val_loss: 1.0286e-06\n", "Epoch 5/10\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 15ms/step - loss: 1.3807e-06 - val_loss: 1.0422e-06\n", "Epoch 6/10\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 14ms/step - loss: 1.3993e-06 - val_loss: 9.8222e-07\n", "Epoch 7/10\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 15ms/step - loss: 1.3536e-06 - val_loss: 8.9309e-07\n", "Epoch 8/10\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 15ms/step - loss: 1.2750e-06 - val_loss: 8.2297e-07\n", "Epoch 9/10\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 15ms/step - loss: 1.2075e-06 - val_loss: 7.9015e-07\n", "Epoch 10/10\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 16ms/step - loss: 1.1735e-06 - val_loss: 7.8403e-07\n" ] }, { "data": { "text/plain": [ "" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Train the model for Test Steps\n", "model_test_steps.fit(X_train, y_train_test_steps, epochs=10, batch_size=32, validation_split=0.2)\n", "\n", "# Train the model for Expected Result\n", "model_expected_result.fit(X_train, y_train_expected_result, epochs=10, batch_size=32, validation_split=0.2)" ] }, { "cell_type": "code", "execution_count": 20, "id": "ba6fa0de", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Mean Squared Error for Test Steps: 2.547742951719556e-06\n", "Mean Squared Error for Expected Result: 1.5647674445062876e-06\n" ] } ], "source": [ "mse_test_steps = model_test_steps.evaluate(X_test, y_test_test_steps, verbose=0)\n", "print(f'Mean Squared Error for Test Steps: {mse_test_steps}')\n", "\n", "# Evaluate the model for Expected Result\n", "mse_expected_result = model_expected_result.evaluate(X_test, y_test_expected_result, verbose=0)\n", "print(f'Mean Squared Error for Expected Result: {mse_expected_result}')" ] }, { "cell_type": "code", "execution_count": 21, "id": "b25dda8b", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 63ms/step\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 46ms/step\n", "Predicted Test Steps Embeddings: [[[-8.4391527e-04 8.3808292e-04 9.2794985e-04 6.3661160e-04\n", " 1.4777145e-04 -4.8993941e-04 6.3069363e-04 2.0756002e-03\n", " -8.7469915e-04 -1.1720757e-03 -6.2859093e-04 -9.6428773e-04\n", " 1.0144784e-03 -6.3690939e-05 -3.8700749e-04 -7.1150030e-04\n", " 5.5333151e-04 9.2034061e-05 -1.0463977e-03 -5.2145477e-03\n", " 8.5559912e-04 -5.3791492e-04 2.6520165e-03 -8.6638553e-04\n", " -7.5741264e-04 5.9628719e-04 -6.6239189e-04 -8.7471894e-04\n", " -9.9208625e-04 8.2071731e-04 4.4646338e-04 8.4726338e-04\n", " 9.5180282e-04 -8.4265345e-04 -5.4202758e-04 1.6481500e-03\n", " -2.2101693e-04 -9.7025535e-04 -6.7334180e-04 -2.8382645e-03\n", " 6.2619505e-04 -1.0893656e-03 -8.7078079e-04 -2.0926578e-04\n", " 8.1423775e-04 8.4379961e-04 -1.6668448e-04 -9.9032815e-04\n", " 9.5974747e-04 8.5376378e-05 6.4395380e-04 -2.3663426e-03\n", " -7.3024776e-04 4.5859173e-04 -1.1602787e-03 5.6848535e-04\n", " 2.6010780e-04 -1.0128880e-03 -2.1443174e-03 -2.6855108e-04\n", " -4.5336629e-04 6.6400541e-04 8.6696784e-04 -8.9265942e-04\n", " -2.0976812e-03 8.8741013e-04 1.0340458e-03 9.4049744e-04\n", " -2.5883170e-03 1.6136141e-03 -9.2293258e-04 8.5503218e-04\n", " 1.2474646e-03 -1.5019166e-05 9.6433581e-04 2.4179585e-04\n", " 7.6161108e-05 6.6559250e-04 -2.3543791e-04 1.0006825e-03\n", " 2.9814860e-04 -7.5365568e-04 -2.1536734e-03 8.8814070e-04\n", " -1.2573856e-03 -1.0502129e-03 5.2467862e-04 -6.8704574e-04\n", " 7.3569722e-04 -4.7312939e-04 2.2936910e-03 8.2683226e-04\n", " 9.9437268e-05 -1.2628101e-04 3.2667362e-03 9.2687435e-04\n", " 8.7968190e-04 -8.3866203e-04 -8.7905704e-05 -1.0417018e-03]]]\n", "Predicted Expected Result Embeddings: [[[-6.00951666e-04 -8.71340380e-05 2.10425234e-04 1.77528680e-04\n", " 8.00210983e-05 -1.85253297e-03 4.65850317e-04 3.56995873e-03\n", " -8.36861320e-04 -6.41276536e-04 9.27919289e-04 -5.45815798e-04\n", " -3.05406691e-04 7.55917281e-04 1.03734914e-04 2.38866487e-05\n", " 7.79760536e-04 -8.88810202e-04 -8.77981714e-04 -2.83502182e-03\n", " 4.05026833e-04 6.70524372e-04 4.63965582e-04 -7.13920599e-05\n", " -1.02403646e-04 -8.36344901e-04 -6.75997231e-04 7.48908031e-04\n", " -1.09156314e-03 7.66666722e-04 1.19300978e-03 -7.83136347e-04\n", " 8.18963978e-04 -1.27818645e-03 -1.85861718e-03 2.35299161e-03\n", " 9.13300086e-04 -3.06413101e-04 -1.55945239e-03 -9.19050653e-04\n", " -5.39628905e-04 -6.51296170e-04 -1.40835065e-04 -4.40066768e-04\n", " 1.64291263e-03 -9.18515027e-04 -3.14408244e-04 2.30843452e-05\n", " 6.91586174e-04 6.74205832e-04 -6.55808544e-05 -4.83483251e-04\n", " -1.72121217e-04 -6.61872444e-04 -8.81674583e-04 -8.80461157e-05\n", " -5.44943148e-04 1.00790197e-03 -1.34598825e-03 1.66665553e-03\n", " 3.33746721e-04 8.65762937e-04 8.99292936e-04 -9.54890158e-04\n", " -5.94305107e-04 9.11348965e-04 2.88407644e-03 7.95712927e-04\n", " -1.11689197e-03 2.58971867e-03 -6.90977846e-04 2.21353053e-04\n", " 7.32570188e-05 -5.61508466e-04 8.17475026e-04 9.93824913e-04\n", " 8.48811760e-04 5.58658561e-04 -8.79892672e-04 -1.04590645e-03\n", " -6.82677957e-04 8.21857655e-04 -8.91812611e-04 1.62078207e-03\n", " -1.80392992e-03 2.16952423e-04 3.11806944e-04 5.39015047e-04\n", " -9.99061740e-08 9.94091504e-04 3.61588714e-03 2.67144089e-04\n", " -1.72064669e-04 -8.35217419e-04 1.40309369e-03 -4.59492789e-04\n", " 9.69752960e-04 -8.42938258e-04 -3.16075137e-04 1.21560282e-04]]]\n" ] } ], "source": [ "new_acceptance_criteria = df['Acceptance_criteria_embeddings'].tolist()[0]\n", "new_acceptance_criteria = np.array(new_acceptance_criteria).reshape((1, 1, len(new_acceptance_criteria)))\n", "\n", "# Make predictions\n", "predicted_test_steps = model_test_steps.predict(new_acceptance_criteria)\n", "predicted_expected_result = model_expected_result.predict(new_acceptance_criteria)\n", "\n", "print(f'Predicted Test Steps Embeddings: {predicted_test_steps}')\n", "print(f'Predicted Expected Result Embeddings: {predicted_expected_result}')" ] }, { "cell_type": "code", "execution_count": 24, "id": "cf073637", "metadata": {}, "outputs": [], "source": [ "mae_test_steps = MeanAbsoluteError()\n", "mae_expected_result = MeanAbsoluteError()" ] }, { "cell_type": "code", "execution_count": 25, "id": "d77deaa0", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 14ms/step\n", "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 9ms/step\n", "Mean Absolute Error for Test Steps: 0.0012983311899006367\n", "Mean Absolute Error for Expected Result: 0.0009957090951502323\n", "R-squared for Test Steps: 0.13273363428637874\n", "R-squared for Expected Result: 0.1580453613077316\n" ] } ], "source": [ "y_pred_test_steps = model_test_steps.predict(X_test)\n", "y_pred_expected_result = model_expected_result.predict(X_test)\n", "\n", "# Calculate MAE for Test Steps\n", "mae_test_steps_value = mae_test_steps(y_test_test_steps, y_pred_test_steps).numpy()\n", "print(f'Mean Absolute Error for Test Steps: {mae_test_steps_value}')\n", "\n", "# Calculate MAE for Expected Result\n", "mae_expected_result_value = mae_expected_result(y_test_expected_result, y_pred_expected_result).numpy()\n", "print(f'Mean Absolute Error for Expected Result: {mae_expected_result_value}')\n", "\n", "# Calculate R-squared for Test Steps\n", "r2_test_steps = r2_score(y_test_test_steps.flatten(), y_pred_test_steps.flatten())\n", "print(f'R-squared for Test Steps: {r2_test_steps}')\n", "\n", "# Calculate R-squared for Expected Result\n", "r2_expected_result = r2_score(y_test_expected_result.flatten(), y_pred_expected_result.flatten())\n", "print(f'R-squared for Expected Result: {r2_expected_result}')" ] }, { "cell_type": "code", "execution_count": null, "id": "ea62b59f", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.5" } }, "nbformat": 4, "nbformat_minor": 5 }