File size: 12,308 Bytes
5ecde30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "#!pip install pandas\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Load the CSV file into a pandas DataFrame\n",
    "df = pd.read_csv(filepath_or_buffer=r'C:\\Users\\serban.tica\\Documents\\tobi_llm_intent_recognition\\data\\Pager_Intents.csv', \n",
    "                 usecols=[0, 1], names=['utterance', 'intent'])\n",
    "\n",
    "# Remove the special character \" from the 'utterance' column\n",
    "df['utterance'] = df['utterance'].str.replace('\"', '')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<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>utterance</th>\n",
       "      <th>intent</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>utterance</td>\n",
       "      <td>intent</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Pot sa i scriu specialistului de cont</td>\n",
       "      <td>account.Specialist</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Contact specialist de cont</td>\n",
       "      <td>account.Specialist</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ce numar de telefon are specialistul de cont</td>\n",
       "      <td>account.Specialist</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Ce numar de telefon are specialistul de cont</td>\n",
       "      <td>account.Specialist</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                      utterance              intent\n",
       "0                                     utterance              intent\n",
       "1         Pot sa i scriu specialistului de cont  account.Specialist\n",
       "2                    Contact specialist de cont  account.Specialist\n",
       "3  Ce numar de telefon are specialistul de cont  account.Specialist\n",
       "4  Ce numar de telefon are specialistul de cont  account.Specialist"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "intent\n",
      "offer.Request                        1084\n",
      "tshooting                            1065\n",
      "reziliere                             829\n",
      "activate.Service                      664\n",
      "info.req.MyPlan                       560\n",
      "switch.To.Agent                       413\n",
      "invoice.Explanation                   318\n",
      "invoice.PC                            298\n",
      "offer.Request.Existing                278\n",
      "deactivate.Service                    264\n",
      "info.Dez.Roaming                      244\n",
      "invoice.Details                       241\n",
      "info.req.Service                      239\n",
      "info.req.Cost.Control                 230\n",
      "info.faq.Contact                      228\n",
      "info.faq.Download.DOC                 186\n",
      "invoice.Payment                       182\n",
      "info.reziliere                        180\n",
      "info.faq.IMEI.PUK                     178\n",
      "offer.Request.Tarife                  167\n",
      "info.faq.Roaming.Status               146\n",
      "offer.Request.Port.In                 145\n",
      "info.faq.Order                        136\n",
      "info.faq.Price.Up                     129\n",
      "byebye                                117\n",
      "info.faq.Recharge                     114\n",
      "invoice.PA                            113\n",
      "info.faq.Revolut                      107\n",
      "info.faq.VFClub                       105\n",
      "info.faq.Deblocare                    102\n",
      "info.faq.MVA.Asociere.Servicii         88\n",
      "info.faq.Schimbare.SIM                 75\n",
      "welcome                                74\n",
      "info.faq.CashBack                      74\n",
      "activate.Service.Electronic.Bill       73\n",
      "engleza                                72\n",
      "info.faq.VTV.login                     67\n",
      "info.faq.Settings                      64\n",
      "info.faq.Speedtest                     64\n",
      "info.req.Gratie                        55\n",
      "info.faq.MVA.istoric.apeluri           54\n",
      "UPC_pay_in_advance                     53\n",
      "info.faq.Own.MSISDN                    53\n",
      "info.faq.Telefon.furat                 50\n",
      "info.faq.DueDate                       50\n",
      "info.faq.Gamification                  49\n",
      "UPC_account_no                         48\n",
      "info.faq.Account.Creation              48\n",
      "info.faq.Credit.Transfer               48\n",
      "offer.Request.Port.Out                 47\n",
      "offer.Request.Portare                  47\n",
      "info.faq.MVA.Credentiale               45\n",
      "info.faq.HBOMax                        44\n",
      "info.faq.Cont.Bancar                   41\n",
      "info.faq.Reclamatie                    41\n",
      "info.faq.Job.Vodafone                  40\n",
      "info.faq.ID.TV                         40\n",
      "info.faq.TeslaLucky                    38\n",
      "UPC_personal_data                      38\n",
      "info.faq.Lista.Canale                  37\n",
      "info.faq.Service.Warranty              37\n",
      "info.faq.WIFI.Connect                  36\n",
      "info.faq.Tombola                       36\n",
      "info.faq.Swap                          36\n",
      "account.Specialist                     35\n",
      "info.faq.Spam                          35\n",
      "info.faq.PIN.TV                        34\n",
      "info.faq.TikTok                        33\n",
      "UPC_no_bill                            33\n",
      "info.faq.PreOrder                      33\n",
      "info.faq.Port.Forwarding               33\n",
      "UPC_suspend                            33\n",
      "info.faq.WIFI.Booster                  32\n",
      "info.faq.5G                            32\n",
      "info.faq.Reincarcare.Gresita           32\n",
      "invoice.DueDate.Update                 32\n",
      "info.faq.Sincronizare.Telecomanda      32\n",
      "info.faq.Acte.Necesare                 32\n",
      "info.faq.Service.Insurance             32\n",
      "info.faq.Campanii                      32\n",
      "info.faq.Configurare.Modem             32\n",
      "info.faq.Acoperire.roaming             31\n",
      "info.faq.Adresa.Magazine               31\n",
      "info.faq.Port.Cancel                   31\n",
      "info.faq.FUP                           31\n",
      "info.faq.EECCT                         31\n",
      "info.faq.Curs.Valutar                  31\n",
      "UPC_modify_services                    30\n",
      "Welcome2Tobi                           30\n",
      "info.faq.WIFI.Password                 30\n",
      "info.faq.Netflix                       30\n",
      "info.faq.WIFI.Disable                  30\n",
      "info.faq.Software.Update               30\n",
      "info.faq.Service.Not.Warranty          30\n",
      "info.faq.Port.Usage                    30\n",
      "info.faq.Port.Duration                 30\n",
      "info.faq.Cable.Connection              30\n",
      "info.faq.CAW                           30\n",
      "info.faq.Evalueaza.Experienta          29\n",
      "info.faq.MVA.Dwld                      29\n",
      "info.faq.Ordine.Consum.Beneficii       29\n",
      "info.faq.Nr.WhatsApp                   28\n",
      "info.faq.Aviz.Tehnic                   28\n",
      "info.faq.Auto.Reincarcare              26\n",
      "rejection                              25\n",
      "info.faq.WIFI.Discover                 24\n",
      "confirmation                           23\n",
      "chitchat.CeFaci                        22\n",
      "chitchat.Weather                       21\n",
      "TestJourney                             2\n",
      "intent                                  1\n",
      "Name: count, dtype: int64\n"
     ]
    }
   ],
   "source": [
    "# Set max rows to None to display all rows\n",
    "pd.set_option('display.max_rows', None)\n",
    "\n",
    "# Print the count of unique 'intent', and the count of each 'intent'\n",
    "print(df['intent'].value_counts()) # show all the unique values and their counts\n",
    "\n",
    "# Set the default max rows to 10\n",
    "pd.set_option('display.max_rows', 20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'matplotlib'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[5], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mmatplotlib\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mpyplot\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mplt\u001b[39;00m\n\u001b[0;32m      3\u001b[0m \u001b[38;5;66;03m# Get the count of each unique 'intent'\u001b[39;00m\n\u001b[0;32m      4\u001b[0m intent_counts \u001b[38;5;241m=\u001b[39m df[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mintent\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m.\u001b[39mvalue_counts()\n",
      "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'matplotlib'"
     ]
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "\n",
    "# Get the count of each unique 'intent'\n",
    "intent_counts = df['intent'].value_counts()\n",
    "\n",
    "def plot_intent_counts(intent_counts):\n",
    "    # Calculate the average and median count\n",
    "    average_count = intent_counts.mean()\n",
    "    median_count = intent_counts.median()\n",
    "\n",
    "    # Create a bar plot\n",
    "    plt.figure(figsize=(10, 6))\n",
    "    intent_counts.plot(kind='bar')\n",
    "    plt.title('Count of each Intent')\n",
    "    plt.xlabel('Intent')\n",
    "    plt.ylabel('Count')\n",
    "\n",
    "    # Add a horizontal line for the average count\n",
    "    plt.axhline(y=average_count, color='r', linestyle='--', label=f'Average count: {average_count:.2f}')\n",
    "    # Add a horizontal line for the median count\n",
    "    plt.axhline(y=median_count, color='g', linestyle='--', label=f'Median count: {median_count:.2f}')\n",
    "    plt.legend()\n",
    "\n",
    "    plt.show()\n",
    "\n",
    "plot_intent_counts(intent_counts)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "env",
   "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.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}