{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "**Importing Libraries**" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19", "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5" }, "outputs": [], "source": [ "import numpy as np # linear algebra\n", "import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n", "import ast\n", "import operator\n", "from textblob import TextBlob\n", "import pandas as pd\n", "import re" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Loading Dataset**" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "dataset = pd.read_csv(\"../input/daraz-sef/Daraz_Labeled_Standardized_Sentiments_Featured_Dataset(Updated).csv\")\n", "dataset = dataset.rename(columns={\"Unnamed: 0\": \"Review_Id\"}, errors=\"raise\")\n", "# dataset.drop(['Unnamed: 0'],axis=1,inplace=True)\n", "dataset.drop_duplicates(subset =\"Reviews\",keep = False, inplace = True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Excluding Spam Reviews**\n", "i.e. Review with Label 0" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "dataset.drop(dataset[dataset.Label == 1].index, inplace=True)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Review_Id | \n", "Product_ID | \n", "Customer_Name | \n", "Customer_ID | \n", "Date | \n", "Rating | \n", "Label | \n", "Reviews | \n", "Sentiment | \n", "Features | \n", "
---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "0 | \n", "TE111EL1KXNGWNAFAMZ | \n", "itzmr7 | \n", "6702 | \n", "5/5/2017 | \n", "1 | \n", "0.0 | \n", "mil gya hai acha hai aur toota howa b nai hai | \n", "Positive | \n", "['toota'] | \n", "
1 | \n", "1 | \n", "MI543EL02ACXSNAFAMZ | \n", "Afridi | \n", "396 | \n", "3/28/2017 | \n", "5 | \n", "0.0 | \n", "aram sy pocket may aa jta hai aur quality b a... | \n", "Positive | \n", "['aram', 'pocket', 'quality'] | \n", "
2 | \n", "2 | \n", "MI543EL02ACXSNAFAMZ | \n", "Muhammed | \n", "3710 | \n", "3/24/2017 | \n", "2 | \n", "0.0 | \n", "sb sy achi chez apki customer service bhot ac... | \n", "Positive | \n", "['customer', 'products', 'orignal'] | \n", "
3 | \n", "3 | \n", "TE111EL1KXNGWNAFAMZ | \n", "Ghazanfar | \n", "1860 | \n", "4/5/2017 | \n", "3 | \n", "0.0 | \n", "back cover acha hai sai cuts hai aur soft b h... | \n", "Positive | \n", "['back', 'cover', 'cuts', 'soft', 'protector',... | \n", "
4 | \n", "4 | \n", "SO638EL103OUWNAFAMZ | \n", "Murtaza iqbal | \n", "3778 | \n", "11/4/2017 | \n", "4 | \n", "0.0 | \n", "shru may may thumb grip k khalif thi kyu k ex... | \n", "Negative | \n", "['thumb', 'grip', 'chezy', 'stock', 'controlle... | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
3915 | \n", "3915 | \n", "HA779HL1JDA5CNAFAMZ | \n", "Adny2k | \n", "368 | \n", "5/29/2018 | \n", "2 | \n", "0.0 | \n", "iss article mein koi auto car tareeqay se saf... | \n", "Positive | \n", "['auto', 'car', 'tareeqay', 'safai'] | \n", "
3918 | \n", "3918 | \n", "HA779HL1JDA5CNAFAMZ | \n", "Az | \n", "1157 | \n", "5/27/2018 | \n", "3 | \n", "0.0 | \n", "tasweer isi terhan tha jaisay tasweer aur tar... | \n", "Positive | \n", "['tasweer', 'tasweer', 'haftay', 'takheer', 'm... | \n", "
3919 | \n", "3919 | \n", "HA779HL1JDA5CNAFAMZ | \n", "Zeeshan | \n", "6135 | \n", "5/22/2018 | \n", "5 | \n", "0.0 | \n", "waqt par masool hwa aaccha lagta hai mein iss... | \n", "Neutral | \n", "['waqt', 'masool', 'miyaar'] | \n", "
3920 | \n", "3920 | \n", "HA779HL1JDA5CNAFAMZ | \n", "shan | \n", "7218 | \n", "5/21/2018 | \n", "3 | \n", "0.0 | \n", "masnoaat isi terhan ki thi jaisay website par... | \n", "Positive | \n", "['masnoaat', 'website', 'asal', 'tasweer', 'da... | \n", "
3922 | \n", "3922 | \n", "HA779HL1JDA5CNAFAMZ | \n", "Feroz | \n", "1800 | \n", "5/20/2018 | \n", "1 | \n", "0.0 | \n", "aik puranay model bheja gaya tha jo ab bazaar... | \n", "Positive | \n", "['puranay', 'model', 'bazaar', 'dastyab', 'plu... | \n", "
3308 rows × 10 columns
\n", "\n", " | Review_Id | \n", "Product_ID | \n", "Customer_Name | \n", "Customer_ID | \n", "Date | \n", "Rating | \n", "Label | \n", "Reviews | \n", "Sentiment | \n", "Features | \n", "
---|---|---|---|---|---|---|---|---|---|---|
224 | \n", "224 | \n", "MA305FA1KY528NAFAMZ | \n", "Abdullah Shahid | \n", "251 | \n", "8/31/2017 | \n", "2 | \n", "0.0 | \n", "achi terhan se iss ke sath mera tajurbah muk... | \n", "Negative | \n", "['tajurbah', 'mukammal', 'tor', 'zabardast', '... | \n", "
225 | \n", "225 | \n", "MA305FA1KY528NAFAMZ | \n", "Suhayb | \n", "5333 | \n", "8/24/2017 | \n", "3 | \n", "0.0 | \n", "mujhe yeh apne dost ke liye mile hain qmizin... | \n", "Negative | \n", "['qmizin', 'qeemat', 'roz', 'pahannay', 'cotto... | \n", "
226 | \n", "226 | \n", "MA305FA1KY528NAFAMZ | \n", "Malik Arslan | \n", "2989 | \n", "8/22/2017 | \n", "3 | \n", "0.0 | \n", "mein nai un shirts ka order diya tha aur sirf... | \n", "Negative | \n", "['shirts', 'order', 'order', 'haasil', 'safaid... | \n", "
229 | \n", "229 | \n", "MA305FA1KY528NAFAMZ | \n", "Qasim | \n", "4232 | \n", "8/21/2017 | \n", "5 | \n", "0.0 | \n", "bohat umdah miyaar theek hai waqai iss ko p... | \n", "Positive | \n", "['umdah', 'miyaar', 'pasand', 'garmiyon', 'roz... | \n", "
230 | \n", "230 | \n", "MA305FA1KY528NAFAMZ | \n", "Asad | \n", "966 | \n", "8/19/2017 | \n", "1 | \n", "0.0 | \n", "mein nay x ail shirts order ki lekin un ke s... | \n", "Negative | \n", "['shirts', 'order', 'size', 'wazeh', 'shirts',... | \n", "
\n", " | Review_Id | \n", "Product_ID | \n", "Customer_Name | \n", "Customer_ID | \n", "Date | \n", "Rating | \n", "Label | \n", "Reviews | \n", "Sentiment | \n", "Features | \n", "
---|---|---|---|---|---|---|---|---|---|---|
224 | \n", "224 | \n", "MA305FA1KY528NAFAMZ | \n", "Abdullah Shahid | \n", "251 | \n", "8/31/2017 | \n", "2 | \n", "0.0 | \n", "achi terhan se iss ke sath mera tajurbah muk... | \n", "Negative | \n", "['tajurbah', 'mukammal', 'tor', 'zabardast', '... | \n", "
225 | \n", "225 | \n", "MA305FA1KY528NAFAMZ | \n", "Suhayb | \n", "5333 | \n", "8/24/2017 | \n", "3 | \n", "0.0 | \n", "mujhe yeh apne dost ke liye mile hain qmizin... | \n", "Negative | \n", "['qmizin', 'qeemat', 'roz', 'pahannay', 'cotto... | \n", "
226 | \n", "226 | \n", "MA305FA1KY528NAFAMZ | \n", "Malik Arslan | \n", "2989 | \n", "8/22/2017 | \n", "3 | \n", "0.0 | \n", "mein nai un shirts ka order diya tha aur sirf... | \n", "Negative | \n", "['shirts', 'order', 'order', 'haasil', 'safaid... | \n", "
230 | \n", "230 | \n", "MA305FA1KY528NAFAMZ | \n", "Asad | \n", "966 | \n", "8/19/2017 | \n", "1 | \n", "0.0 | \n", "mein nay x ail shirts order ki lekin un ke s... | \n", "Negative | \n", "['shirts', 'order', 'size', 'wazeh', 'shirts',... | \n", "
261 | \n", "261 | \n", "MA305FA1KY528NAFAMZ | \n", "Shayam Malik | \n", "5145 | \n", "11/8/2017 | \n", "4 | \n", "0.0 | \n", "un shirts mein sirf ghalti fitting thi woh ha... | \n", "Negative | \n", "['shirts', 'ghalti', 'fitting', 'halki', 'dhee... | \n", "
\n", " | Review_Id | \n", "Product_ID | \n", "Customer_Name | \n", "Customer_ID | \n", "Date | \n", "Rating | \n", "Label | \n", "Reviews | \n", "Sentiment | \n", "Features | \n", "
---|---|---|---|---|---|---|---|---|---|---|
229 | \n", "229 | \n", "MA305FA1KY528NAFAMZ | \n", "Qasim | \n", "4232 | \n", "8/21/2017 | \n", "5 | \n", "0.0 | \n", "bohat umdah miyaar theek hai waqai iss ko p... | \n", "Positive | \n", "['umdah', 'miyaar', 'pasand', 'garmiyon', 'roz... | \n", "
231 | \n", "231 | \n", "MA305FA1KY528NAFAMZ | \n", "Mahnoor Mubashir | \n", "2962 | \n", "8/17/2017 | \n", "4 | \n", "0.0 | \n", "tea shirts ka packet bohat acha tha mein ye... | \n", "Positive | \n", "['tea', 'shirts', 'packet', 'chahta', 'rang', ... | \n", "
232 | \n", "232 | \n", "MA305FA1KY528NAFAMZ | \n", "umar khattak | \n", "7355 | \n", "8/16/2017 | \n", "4 | \n", "0.0 | \n", "theek hai iss qeemat ke baarey mein mein yeh... | \n", "Positive | \n", "['qeemat', 'qmizin', 'umdah', 'tane', 'miyaar'... | \n", "
305 | \n", "305 | \n", "MA305FA1KY528NAFAMZ | \n", "Mustufa Dilpazir | \n", "3814 | \n", "2/8/2017 | \n", "4 | \n", "0.0 | \n", "mein daraz ka aksar gahak hon mujhe waqai mei... | \n", "Positive | \n", "['aksar', 'tea', 'shirts', 'pasand', 'miyaar',... | \n", "
387 | \n", "387 | \n", "MA305FA1KY528NAFAMZ | \n", "No name | \n", "4060 | \n", "10/7/2017 | \n", "5 | \n", "0.0 | \n", "shirts ki bohat achi quality sirf yeh dekh ka... | \n", "Positive | \n", "['shirts', 'quality', 'heran', 'shirts', 'pack... | \n", "
\n", " | Review_Id | \n", "Product_ID | \n", "Customer_Name | \n", "Customer_ID | \n", "Date | \n", "Rating | \n", "Label | \n", "Reviews | \n", "Sentiment | \n", "Features | \n", "
---|---|---|---|---|---|---|---|---|---|---|
306 | \n", "306 | \n", "MA305FA1KY528NAFAMZ | \n", "Mrs | \n", "3330 | \n", "1/8/2017 | \n", "5 | \n", "0.0 | \n", "ya asan h istemaal may keemat b kaam hai aur ... | \n", "Neutral | \n", "['asan', 'keemat', 'saaf'] | \n", "
336 | \n", "336 | \n", "MA305FA1KY528NAFAMZ | \n", "Khan | \n", "2636 | \n", "7/30/2017 | \n", "1 | \n", "0.0 | \n", "aik shirt khrb hai aur blue wali may whole hai | \n", "Neutral | \n", "['khrb', 'blue'] | \n", "
533 | \n", "533 | \n", "MA305FA1KY528NAFAMZ | \n", "Azam | \n", "1160 | \n", "6/17/2017 | \n", "2 | \n", "0.0 | \n", "mein ne poooray shirts mein poori terhan se ... | \n", "Neutral | \n", "['poooray', 'shirts', 'paaya', 'safaid', 'peel... | \n", "
729 | \n", "729 | \n", "MA305FA1KY528NAFAMZ | \n", "Irfan Bin Hakim | \n", "2345 | \n", "5/26/2017 | \n", "2 | \n", "0.0 | \n", "mein ne safaid aur gehra surkh rang ke liye ... | \n", "Neutral | \n", "['safaid', 'rang', 'order', 'rang', 'safaid', ... | \n", "
807 | \n", "807 | \n", "MA305FA1KY528NAFAMZ | \n", "hina timothy | \n", "6632 | \n", "11/5/2017 | \n", "4 | \n", "0.0 | \n", "yeh qmizin iss mausam garma mein meri jane wa... | \n", "Neutral | \n", "['qmizin', 'mausam', 'garma', 'rangeen', 'muta... | \n", "
\n", " | Review_Id | \n", "Customer_Name | \n", "Reviews | \n", "Features | \n", "
---|---|---|---|---|
0 | \n", "231 | \n", "Mahnoor Mubashir | \n", "tea shirts ka packet bohat acha tha mein ye... | \n", "['tea', 'shirts', 'packet', 'chahta', 'rang', ... | \n", "
1 | \n", "391 | \n", "NADEEM ABBAS | \n", "jab mein un ki qeemat par ghhor karta hon tu... | \n", "['qeemat', 'tea', 'shirts', 'qabil', 'neh', 'q... | \n", "
2 | \n", "919 | \n", "Ahsan Malik | \n", "yeh tea herat angaiz hain aur mein nay websi... | \n", "['tea', 'herat', 'angaiz', 'website', 'dekhty'... | \n", "
3 | \n", "841 | \n", "behroz ali | \n", "mujhe iss package mein mojood tamam shirts bo... | \n", "['package', 'mojood', 'tamam', 'shirts', 'pasa... | \n", "
4 | \n", "877 | \n", "Bilal Ali brohi | \n", "tamam shirts mein se yeh pack behtareen hai ... | \n", "['tamam', 'shirts', 'pack', 'behtareen', 'aram... | \n", "
5 | \n", "1085 | \n", "Abid Zafar | \n", "perfect size perfect fitting aur perfect colo... | \n", "['perfect', 'size', 'perfect', 'fitting', 'per... | \n", "
6 | \n", "1040 | \n", "Azlan Khan | \n", "yeh pack of iss price ke hisaab se acha hai ... | \n", "['pack', 'hisaab', 'bus', 'masla', 'tshirts', ... | \n", "
7 | \n", "1083 | \n", "Ameen Yousuf | \n", "munasib keemat mein achi quality ki shirts ey... | \n", "['munasib', 'keemat', 'quality', 'shirts', 'ba... | \n", "
8 | \n", "342 | \n", "Adil Aslam | \n", "mein ne un tea shirts ka order diya tha aur ... | \n", "['tea', 'shirts', 'order', 'vaqata', 'satisfie... | \n", "
9 | \n", "3611 | \n", "Murad | \n", "tarseel prompt aur presentation achay miyaar... | \n", "['prompt', 'presentation', 'miyaar', 'darmiyan... | \n", "
10 | \n", "225 | \n", "Suhayb | \n", "mujhe yeh apne dost ke liye mile hain qmizin... | \n", "['qmizin', 'qeemat', 'roz', 'pahannay', 'cotto... | \n", "
11 | \n", "879 | \n", "Abdullah | \n", "mein tawaqqa nahi kar raha tha ke un shirts ... | \n", "['tawaqqa', 'shirts', 'shirts', 'miyaar', 'ara... | \n", "
12 | \n", "1057 | \n", "Abdullah | \n", "nu doubt quality bht achi ha magar mene yeh w... | \n", "['doubt', 'quality', 'white', 'order', 'packag... | \n", "
13 | \n", "261 | \n", "Shayam Malik | \n", "un shirts mein sirf ghalti fitting thi woh ha... | \n", "['shirts', 'ghalti', 'fitting', 'halki', 'dhee... | \n", "
14 | \n", "842 | \n", "Usman Rasheed | \n", "pakistan mein meri pehli online shopping mei... | \n", "['online', 'shopping', 'herat', 'umdah', 'sama... | \n", "
15 | \n", "224 | \n", "Abdullah Shahid | \n", "achi terhan se iss ke sath mera tajurbah muk... | \n", "['tajurbah', 'mukammal', 'tor', 'zabardast', '... | \n", "
16 | \n", "925 | \n", "Ammad Ali | \n", "meri pehli online shopping mujhe herat zada h... | \n", "['online', 'shopping', 'herat', 'herat', 'anga... | \n", "
17 | \n", "729 | \n", "Irfan Bin Hakim | \n", "mein ne safaid aur gehra surkh rang ke liye ... | \n", "['safaid', 'rang', 'order', 'rang', 'safaid', ... | \n", "
18 | \n", "807 | \n", "hina timothy | \n", "yeh qmizin iss mausam garma mein meri jane wa... | \n", "['qmizin', 'mausam', 'garma', 'rangeen', 'muta... | \n", "
19 | \n", "845 | \n", "Aun | \n", "mein ne jaali saazi ki numayesh karte hue waz... | \n", "['jaali', 'numayesh', 'wazeh', 'tor', 'tasavee... | \n", "