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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {
7
+ "colab": {
8
+ "base_uri": "https://localhost:8080/"
9
+ },
10
+ "id": "N3shQZoZPScM",
11
+ "outputId": "63642e05-bd32-4fd9-f029-8f50148a1e8a"
12
+ },
13
+ "outputs": [],
14
+ "source": [
15
+ "!pip install -U sentence_transformers --q"
16
+ ]
17
+ },
18
+ {
19
+ "cell_type": "code",
20
+ "execution_count": 2,
21
+ "metadata": {
22
+ "colab": {
23
+ "base_uri": "https://localhost:8080/"
24
+ },
25
+ "id": "rcBH0FzwVOk6",
26
+ "outputId": "f5b4b762-9b30-4474-d1d0-7ba3ab68a2ef"
27
+ },
28
+ "outputs": [
29
+ {
30
+ "name": "stdout",
31
+ "output_type": "stream",
32
+ "text": [
33
+ "\n",
34
+ "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m24.0\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.0.1\u001b[0m\n",
35
+ "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip3 install --upgrade pip\u001b[0m\n",
36
+ "Note: you may need to restart the kernel to use updated packages.\n"
37
+ ]
38
+ }
39
+ ],
40
+ "source": [
41
+ "pip install datasets --q"
42
+ ]
43
+ },
44
+ {
45
+ "cell_type": "code",
46
+ "execution_count": 3,
47
+ "metadata": {
48
+ "colab": {
49
+ "base_uri": "https://localhost:8080/"
50
+ },
51
+ "id": "y-pDMu97XyVd",
52
+ "outputId": "737160a3-2c34-4293-a129-bb053cd91117"
53
+ },
54
+ "outputs": [
55
+ {
56
+ "name": "stdout",
57
+ "output_type": "stream",
58
+ "text": [
59
+ "Collecting sentence-transformers\n",
60
+ " Using cached sentence_transformers-3.4.1-py3-none-any.whl.metadata (10 kB)\n",
61
+ "Requirement already satisfied: scikit-learn in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (1.4.1.post1)\n",
62
+ "Requirement already satisfied: pandas in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (2.2.1)\n",
63
+ "Collecting torch\n",
64
+ " Downloading torch-2.6.0-cp312-none-macosx_11_0_arm64.whl.metadata (28 kB)\n",
65
+ "Collecting transformers<5.0.0,>=4.41.0 (from sentence-transformers)\n",
66
+ " Downloading transformers-4.48.3-py3-none-any.whl.metadata (44 kB)\n",
67
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m44.4/44.4 kB\u001b[0m \u001b[31m2.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
68
+ "\u001b[?25hRequirement already satisfied: tqdm in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from sentence-transformers) (4.67.1)\n",
69
+ "Requirement already satisfied: scipy in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from sentence-transformers) (1.12.0)\n",
70
+ "Requirement already satisfied: huggingface-hub>=0.20.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from sentence-transformers) (0.28.1)\n",
71
+ "Requirement already satisfied: Pillow in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from sentence-transformers) (10.2.0)\n",
72
+ "Requirement already satisfied: numpy<2.0,>=1.19.5 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from scikit-learn) (1.26.4)\n",
73
+ "Requirement already satisfied: joblib>=1.2.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from scikit-learn) (1.3.2)\n",
74
+ "Requirement already satisfied: threadpoolctl>=2.0.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from scikit-learn) (3.3.0)\n",
75
+ "Requirement already satisfied: python-dateutil>=2.8.2 in /Users/markushenriksson/Library/Python/3.12/lib/python/site-packages (from pandas) (2.9.0.post0)\n",
76
+ "Requirement already satisfied: pytz>=2020.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pandas) (2024.1)\n",
77
+ "Requirement already satisfied: tzdata>=2022.7 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from pandas) (2024.1)\n",
78
+ "Requirement already satisfied: filelock in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from torch) (3.16.0)\n",
79
+ "Requirement already satisfied: typing-extensions>=4.10.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from torch) (4.10.0)\n",
80
+ "Collecting networkx (from torch)\n",
81
+ " Using cached networkx-3.4.2-py3-none-any.whl.metadata (6.3 kB)\n",
82
+ "Requirement already satisfied: jinja2 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from torch) (3.1.3)\n",
83
+ "Requirement already satisfied: fsspec in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from torch) (2024.2.0)\n",
84
+ "Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from torch) (69.1.1)\n",
85
+ "Collecting sympy==1.13.1 (from torch)\n",
86
+ " Using cached sympy-1.13.1-py3-none-any.whl.metadata (12 kB)\n",
87
+ "Collecting mpmath<1.4,>=1.1.0 (from sympy==1.13.1->torch)\n",
88
+ " Using cached mpmath-1.3.0-py3-none-any.whl.metadata (8.6 kB)\n",
89
+ "Requirement already satisfied: packaging>=20.9 in /Users/markushenriksson/Library/Python/3.12/lib/python/site-packages (from huggingface-hub>=0.20.0->sentence-transformers) (24.0)\n",
90
+ "Requirement already satisfied: pyyaml>=5.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from huggingface-hub>=0.20.0->sentence-transformers) (6.0.1)\n",
91
+ "Requirement already satisfied: requests in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from huggingface-hub>=0.20.0->sentence-transformers) (2.32.3)\n",
92
+ "Requirement already satisfied: six>=1.5 in /Users/markushenriksson/Library/Python/3.12/lib/python/site-packages (from python-dateutil>=2.8.2->pandas) (1.16.0)\n",
93
+ "Collecting regex!=2019.12.17 (from transformers<5.0.0,>=4.41.0->sentence-transformers)\n",
94
+ " Using cached regex-2024.11.6-cp312-cp312-macosx_11_0_arm64.whl.metadata (40 kB)\n",
95
+ "Collecting tokenizers<0.22,>=0.21 (from transformers<5.0.0,>=4.41.0->sentence-transformers)\n",
96
+ " Downloading tokenizers-0.21.0-cp39-abi3-macosx_11_0_arm64.whl.metadata (6.7 kB)\n",
97
+ "Collecting safetensors>=0.4.1 (from transformers<5.0.0,>=4.41.0->sentence-transformers)\n",
98
+ " Downloading safetensors-0.5.2-cp38-abi3-macosx_11_0_arm64.whl.metadata (3.8 kB)\n",
99
+ "Requirement already satisfied: MarkupSafe>=2.0 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from jinja2->torch) (2.1.5)\n",
100
+ "Requirement already satisfied: charset-normalizer<4,>=2 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from requests->huggingface-hub>=0.20.0->sentence-transformers) (3.3.2)\n",
101
+ "Requirement already satisfied: idna<4,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from requests->huggingface-hub>=0.20.0->sentence-transformers) (3.6)\n",
102
+ "Requirement already satisfied: urllib3<3,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from requests->huggingface-hub>=0.20.0->sentence-transformers) (2.0.7)\n",
103
+ "Requirement already satisfied: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages (from requests->huggingface-hub>=0.20.0->sentence-transformers) (2024.2.2)\n",
104
+ "Using cached sentence_transformers-3.4.1-py3-none-any.whl (275 kB)\n",
105
+ "Downloading torch-2.6.0-cp312-none-macosx_11_0_arm64.whl (66.5 MB)\n",
106
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m66.5/66.5 MB\u001b[0m \u001b[31m24.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
107
+ "\u001b[?25hUsing cached sympy-1.13.1-py3-none-any.whl (6.2 MB)\n",
108
+ "Downloading transformers-4.48.3-py3-none-any.whl (9.7 MB)\n",
109
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m9.7/9.7 MB\u001b[0m \u001b[31m35.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
110
+ "\u001b[?25hUsing cached networkx-3.4.2-py3-none-any.whl (1.7 MB)\n",
111
+ "Using cached mpmath-1.3.0-py3-none-any.whl (536 kB)\n",
112
+ "Using cached regex-2024.11.6-cp312-cp312-macosx_11_0_arm64.whl (284 kB)\n",
113
+ "Downloading safetensors-0.5.2-cp38-abi3-macosx_11_0_arm64.whl (408 kB)\n",
114
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m408.9/408.9 kB\u001b[0m \u001b[31m27.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
115
+ "\u001b[?25hDownloading tokenizers-0.21.0-cp39-abi3-macosx_11_0_arm64.whl (2.6 MB)\n",
116
+ "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.6/2.6 MB\u001b[0m \u001b[31m36.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n",
117
+ "\u001b[?25hInstalling collected packages: mpmath, sympy, safetensors, regex, networkx, torch, tokenizers, transformers, sentence-transformers\n",
118
+ "Successfully installed mpmath-1.3.0 networkx-3.4.2 regex-2024.11.6 safetensors-0.5.2 sentence-transformers-3.4.1 sympy-1.13.1 tokenizers-0.21.0 torch-2.6.0 transformers-4.48.3\n",
119
+ "\n",
120
+ "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m24.0\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.0.1\u001b[0m\n",
121
+ "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip3 install --upgrade pip\u001b[0m\n",
122
+ "Note: you may need to restart the kernel to use updated packages.\n"
123
+ ]
124
+ }
125
+ ],
126
+ "source": [
127
+ "pip install sentence-transformers scikit-learn pandas torch\n"
128
+ ]
129
+ },
130
+ {
131
+ "cell_type": "code",
132
+ "execution_count": 4,
133
+ "metadata": {
134
+ "id": "m-tmgXuldd3C"
135
+ },
136
+ "outputs": [],
137
+ "source": [
138
+ "import seaborn as sns"
139
+ ]
140
+ },
141
+ {
142
+ "cell_type": "code",
143
+ "execution_count": 5,
144
+ "metadata": {
145
+ "id": "1Z0mgYZEgjC4"
146
+ },
147
+ "outputs": [],
148
+ "source": [
149
+ "from sklearn.ensemble import RandomForestClassifier"
150
+ ]
151
+ },
152
+ {
153
+ "cell_type": "code",
154
+ "execution_count": 6,
155
+ "metadata": {
156
+ "id": "aBmXLbZ4cc1U"
157
+ },
158
+ "outputs": [],
159
+ "source": [
160
+ "from sklearn.model_selection import train_test_split\n"
161
+ ]
162
+ },
163
+ {
164
+ "cell_type": "code",
165
+ "execution_count": 7,
166
+ "metadata": {
167
+ "id": "LXkXdIWgUcWI"
168
+ },
169
+ "outputs": [],
170
+ "source": [
171
+ "from datasets import load_dataset, Dataset\n",
172
+ "import pandas as pd"
173
+ ]
174
+ },
175
+ {
176
+ "cell_type": "code",
177
+ "execution_count": 8,
178
+ "metadata": {
179
+ "id": "AFkI23ySgtkV"
180
+ },
181
+ "outputs": [],
182
+ "source": [
183
+ "from sklearn.metrics import accuracy_score"
184
+ ]
185
+ },
186
+ {
187
+ "cell_type": "code",
188
+ "execution_count": 9,
189
+ "metadata": {
190
+ "colab": {
191
+ "base_uri": "https://localhost:8080/"
192
+ },
193
+ "id": "ehvh1BJZWa_1",
194
+ "outputId": "212a5f82-885d-4e61-a73f-94dcf12a3a39"
195
+ },
196
+ "outputs": [
197
+ {
198
+ "data": {
199
+ "application/vnd.jupyter.widget-view+json": {
200
+ "model_id": "ab0344420d964f64a16c911f17aae057",
201
+ "version_major": 2,
202
+ "version_minor": 0
203
+ },
204
+ "text/plain": [
205
+ "README.md: 0%| | 0.00/515 [00:00<?, ?B/s]"
206
+ ]
207
+ },
208
+ "metadata": {},
209
+ "output_type": "display_data"
210
+ },
211
+ {
212
+ "data": {
213
+ "application/vnd.jupyter.widget-view+json": {
214
+ "model_id": "9f86cbde053f4b9e91cff137a924082f",
215
+ "version_major": 2,
216
+ "version_minor": 0
217
+ },
218
+ "text/plain": [
219
+ "train-00000-of-00001.parquet: 0%| | 0.00/5.89M [00:00<?, ?B/s]"
220
+ ]
221
+ },
222
+ "metadata": {},
223
+ "output_type": "display_data"
224
+ },
225
+ {
226
+ "data": {
227
+ "application/vnd.jupyter.widget-view+json": {
228
+ "model_id": "2f6d00487331444299405cc97d4b18ea",
229
+ "version_major": 2,
230
+ "version_minor": 0
231
+ },
232
+ "text/plain": [
233
+ "Generating train split: 0%| | 0/61199 [00:00<?, ? examples/s]"
234
+ ]
235
+ },
236
+ "metadata": {},
237
+ "output_type": "display_data"
238
+ },
239
+ {
240
+ "name": "stdout",
241
+ "output_type": "stream",
242
+ "text": [
243
+ " answer system_prompt \\\n",
244
+ "0 neutral You are a financial sentiment analysis expert.... \n",
245
+ "1 neutral You are a financial sentiment analysis expert.... \n",
246
+ "2 negative You are a financial sentiment analysis expert.... \n",
247
+ "3 positive You are a financial sentiment analysis expert.... \n",
248
+ "4 positive You are a financial sentiment analysis expert.... \n",
249
+ "\n",
250
+ " user_prompt task_type \n",
251
+ "0 According to Gran , the company has no plans t... sentiment_analysis \n",
252
+ "1 Technopolis plans to develop in stages an area... sentiment_analysis \n",
253
+ "2 The international electronic industry company ... sentiment_analysis \n",
254
+ "3 With the new production plant the company woul... sentiment_analysis \n",
255
+ "4 According to the company 's updated strategy f... sentiment_analysis \n"
256
+ ]
257
+ }
258
+ ],
259
+ "source": [
260
+ "df = load_dataset(\"NickyNicky/Finance_sentiment_and_topic_classification_En\")\n",
261
+ "\n",
262
+ "# Converting 'train' split to a Pandas DataFrame\n",
263
+ "df = pd.DataFrame(df['train'])\n",
264
+ "\n",
265
+ "\n",
266
+ "print(df.head())\n",
267
+ "\n",
268
+ "\n",
269
+ "df.to_csv(\"train_data.csv\", index=False)\n"
270
+ ]
271
+ },
272
+ {
273
+ "cell_type": "code",
274
+ "execution_count": 10,
275
+ "metadata": {
276
+ "colab": {
277
+ "base_uri": "https://localhost:8080/",
278
+ "height": 206
279
+ },
280
+ "id": "wS-PmD5WWnYC",
281
+ "outputId": "36732946-2bb0-4f58-f784-5619d77698b9"
282
+ },
283
+ "outputs": [
284
+ {
285
+ "data": {
286
+ "text/html": [
287
+ "<div>\n",
288
+ "<style scoped>\n",
289
+ " .dataframe tbody tr th:only-of-type {\n",
290
+ " vertical-align: middle;\n",
291
+ " }\n",
292
+ "\n",
293
+ " .dataframe tbody tr th {\n",
294
+ " vertical-align: top;\n",
295
+ " }\n",
296
+ "\n",
297
+ " .dataframe thead th {\n",
298
+ " text-align: right;\n",
299
+ " }\n",
300
+ "</style>\n",
301
+ "<table border=\"1\" class=\"dataframe\">\n",
302
+ " <thead>\n",
303
+ " <tr style=\"text-align: right;\">\n",
304
+ " <th></th>\n",
305
+ " <th>answer</th>\n",
306
+ " <th>system_prompt</th>\n",
307
+ " <th>user_prompt</th>\n",
308
+ " <th>task_type</th>\n",
309
+ " </tr>\n",
310
+ " </thead>\n",
311
+ " <tbody>\n",
312
+ " <tr>\n",
313
+ " <th>0</th>\n",
314
+ " <td>neutral</td>\n",
315
+ " <td>You are a financial sentiment analysis expert....</td>\n",
316
+ " <td>According to Gran , the company has no plans t...</td>\n",
317
+ " <td>sentiment_analysis</td>\n",
318
+ " </tr>\n",
319
+ " <tr>\n",
320
+ " <th>1</th>\n",
321
+ " <td>neutral</td>\n",
322
+ " <td>You are a financial sentiment analysis expert....</td>\n",
323
+ " <td>Technopolis plans to develop in stages an area...</td>\n",
324
+ " <td>sentiment_analysis</td>\n",
325
+ " </tr>\n",
326
+ " <tr>\n",
327
+ " <th>2</th>\n",
328
+ " <td>negative</td>\n",
329
+ " <td>You are a financial sentiment analysis expert....</td>\n",
330
+ " <td>The international electronic industry company ...</td>\n",
331
+ " <td>sentiment_analysis</td>\n",
332
+ " </tr>\n",
333
+ " <tr>\n",
334
+ " <th>3</th>\n",
335
+ " <td>positive</td>\n",
336
+ " <td>You are a financial sentiment analysis expert....</td>\n",
337
+ " <td>With the new production plant the company woul...</td>\n",
338
+ " <td>sentiment_analysis</td>\n",
339
+ " </tr>\n",
340
+ " <tr>\n",
341
+ " <th>4</th>\n",
342
+ " <td>positive</td>\n",
343
+ " <td>You are a financial sentiment analysis expert....</td>\n",
344
+ " <td>According to the company 's updated strategy f...</td>\n",
345
+ " <td>sentiment_analysis</td>\n",
346
+ " </tr>\n",
347
+ " </tbody>\n",
348
+ "</table>\n",
349
+ "</div>"
350
+ ],
351
+ "text/plain": [
352
+ " answer system_prompt \\\n",
353
+ "0 neutral You are a financial sentiment analysis expert.... \n",
354
+ "1 neutral You are a financial sentiment analysis expert.... \n",
355
+ "2 negative You are a financial sentiment analysis expert.... \n",
356
+ "3 positive You are a financial sentiment analysis expert.... \n",
357
+ "4 positive You are a financial sentiment analysis expert.... \n",
358
+ "\n",
359
+ " user_prompt task_type \n",
360
+ "0 According to Gran , the company has no plans t... sentiment_analysis \n",
361
+ "1 Technopolis plans to develop in stages an area... sentiment_analysis \n",
362
+ "2 The international electronic industry company ... sentiment_analysis \n",
363
+ "3 With the new production plant the company woul... sentiment_analysis \n",
364
+ "4 According to the company 's updated strategy f... sentiment_analysis "
365
+ ]
366
+ },
367
+ "execution_count": 10,
368
+ "metadata": {},
369
+ "output_type": "execute_result"
370
+ }
371
+ ],
372
+ "source": [
373
+ "df.head()"
374
+ ]
375
+ },
376
+ {
377
+ "cell_type": "code",
378
+ "execution_count": 11,
379
+ "metadata": {
380
+ "id": "cQ3tjGFTW5kE"
381
+ },
382
+ "outputs": [],
383
+ "source": [
384
+ "df.drop(['system_prompt', 'task_type'], axis=1, inplace=True)"
385
+ ]
386
+ },
387
+ {
388
+ "cell_type": "code",
389
+ "execution_count": 12,
390
+ "metadata": {
391
+ "colab": {
392
+ "base_uri": "https://localhost:8080/",
393
+ "height": 423
394
+ },
395
+ "id": "Va5867ATXAxD",
396
+ "outputId": "c258f546-d8af-4ba5-8228-3a07f2283baf"
397
+ },
398
+ "outputs": [
399
+ {
400
+ "data": {
401
+ "text/html": [
402
+ "<div>\n",
403
+ "<style scoped>\n",
404
+ " .dataframe tbody tr th:only-of-type {\n",
405
+ " vertical-align: middle;\n",
406
+ " }\n",
407
+ "\n",
408
+ " .dataframe tbody tr th {\n",
409
+ " vertical-align: top;\n",
410
+ " }\n",
411
+ "\n",
412
+ " .dataframe thead th {\n",
413
+ " text-align: right;\n",
414
+ " }\n",
415
+ "</style>\n",
416
+ "<table border=\"1\" class=\"dataframe\">\n",
417
+ " <thead>\n",
418
+ " <tr style=\"text-align: right;\">\n",
419
+ " <th></th>\n",
420
+ " <th>answer</th>\n",
421
+ " <th>user_prompt</th>\n",
422
+ " </tr>\n",
423
+ " </thead>\n",
424
+ " <tbody>\n",
425
+ " <tr>\n",
426
+ " <th>0</th>\n",
427
+ " <td>neutral</td>\n",
428
+ " <td>According to Gran , the company has no plans t...</td>\n",
429
+ " </tr>\n",
430
+ " <tr>\n",
431
+ " <th>1</th>\n",
432
+ " <td>neutral</td>\n",
433
+ " <td>Technopolis plans to develop in stages an area...</td>\n",
434
+ " </tr>\n",
435
+ " <tr>\n",
436
+ " <th>2</th>\n",
437
+ " <td>negative</td>\n",
438
+ " <td>The international electronic industry company ...</td>\n",
439
+ " </tr>\n",
440
+ " <tr>\n",
441
+ " <th>3</th>\n",
442
+ " <td>positive</td>\n",
443
+ " <td>With the new production plant the company woul...</td>\n",
444
+ " </tr>\n",
445
+ " <tr>\n",
446
+ " <th>4</th>\n",
447
+ " <td>positive</td>\n",
448
+ " <td>According to the company 's updated strategy f...</td>\n",
449
+ " </tr>\n",
450
+ " <tr>\n",
451
+ " <th>...</th>\n",
452
+ " <td>...</td>\n",
453
+ " <td>...</td>\n",
454
+ " </tr>\n",
455
+ " <tr>\n",
456
+ " <th>61194</th>\n",
457
+ " <td>Treasuries | Corporate Debt</td>\n",
458
+ " <td>KfW credit line for Uniper could be raised to ...</td>\n",
459
+ " </tr>\n",
460
+ " <tr>\n",
461
+ " <th>61195</th>\n",
462
+ " <td>Treasuries | Corporate Debt</td>\n",
463
+ " <td>KfW credit line for Uniper could be raised to ...</td>\n",
464
+ " </tr>\n",
465
+ " <tr>\n",
466
+ " <th>61196</th>\n",
467
+ " <td>Treasuries | Corporate Debt</td>\n",
468
+ " <td>Russian https://t.co/R0iPhyo5p7 sells 1 bln r...</td>\n",
469
+ " </tr>\n",
470
+ " <tr>\n",
471
+ " <th>61197</th>\n",
472
+ " <td>Treasuries | Corporate Debt</td>\n",
473
+ " <td>Global ESG bond issuance posts H1 dip as supra...</td>\n",
474
+ " </tr>\n",
475
+ " <tr>\n",
476
+ " <th>61198</th>\n",
477
+ " <td>Treasuries | Corporate Debt</td>\n",
478
+ " <td>Brazil's Petrobras says it signed a $1.25 bill...</td>\n",
479
+ " </tr>\n",
480
+ " </tbody>\n",
481
+ "</table>\n",
482
+ "<p>61199 rows × 2 columns</p>\n",
483
+ "</div>"
484
+ ],
485
+ "text/plain": [
486
+ " answer \\\n",
487
+ "0 neutral \n",
488
+ "1 neutral \n",
489
+ "2 negative \n",
490
+ "3 positive \n",
491
+ "4 positive \n",
492
+ "... ... \n",
493
+ "61194 Treasuries | Corporate Debt \n",
494
+ "61195 Treasuries | Corporate Debt \n",
495
+ "61196 Treasuries | Corporate Debt \n",
496
+ "61197 Treasuries | Corporate Debt \n",
497
+ "61198 Treasuries | Corporate Debt \n",
498
+ "\n",
499
+ " user_prompt \n",
500
+ "0 According to Gran , the company has no plans t... \n",
501
+ "1 Technopolis plans to develop in stages an area... \n",
502
+ "2 The international electronic industry company ... \n",
503
+ "3 With the new production plant the company woul... \n",
504
+ "4 According to the company 's updated strategy f... \n",
505
+ "... ... \n",
506
+ "61194 KfW credit line for Uniper could be raised to ... \n",
507
+ "61195 KfW credit line for Uniper could be raised to ... \n",
508
+ "61196 Russian https://t.co/R0iPhyo5p7 sells 1 bln r... \n",
509
+ "61197 Global ESG bond issuance posts H1 dip as supra... \n",
510
+ "61198 Brazil's Petrobras says it signed a $1.25 bill... \n",
511
+ "\n",
512
+ "[61199 rows x 2 columns]"
513
+ ]
514
+ },
515
+ "execution_count": 12,
516
+ "metadata": {},
517
+ "output_type": "execute_result"
518
+ }
519
+ ],
520
+ "source": [
521
+ "df"
522
+ ]
523
+ },
524
+ {
525
+ "cell_type": "code",
526
+ "execution_count": 13,
527
+ "metadata": {
528
+ "colab": {
529
+ "base_uri": "https://localhost:8080/"
530
+ },
531
+ "id": "a2PtcHIfeM5t",
532
+ "outputId": "2214b201-c68d-4112-d224-855bd7103213"
533
+ },
534
+ "outputs": [
535
+ {
536
+ "name": "stdout",
537
+ "output_type": "stream",
538
+ "text": [
539
+ "(39641, 2)\n"
540
+ ]
541
+ }
542
+ ],
543
+ "source": [
544
+ "# only want to keep rows where 'answer' is 'neutral', 'positive', or 'negative'\n",
545
+ "df_filtered = df[df[\"answer\"].isin([\"neutral\", \"positive\", \"negative\"])]\n",
546
+ "\n",
547
+ "# Showing the shape of the new DataFrame\n",
548
+ "print(df_filtered.shape)\n"
549
+ ]
550
+ },
551
+ {
552
+ "cell_type": "code",
553
+ "execution_count": 14,
554
+ "metadata": {
555
+ "colab": {
556
+ "base_uri": "https://localhost:8080/"
557
+ },
558
+ "id": "OzmsDZ-tZuGA",
559
+ "outputId": "cb743649-521b-45da-8c9a-182fff7584bd"
560
+ },
561
+ "outputs": [
562
+ {
563
+ "name": "stdout",
564
+ "output_type": "stream",
565
+ "text": [
566
+ "(5946, 2)\n"
567
+ ]
568
+ }
569
+ ],
570
+ "source": [
571
+ "df_sampled = df_filtered.sample(frac=0.15, random_state=42) # 15% sample\n",
572
+ "print(df_sampled.shape) # Checking new size\n"
573
+ ]
574
+ },
575
+ {
576
+ "cell_type": "code",
577
+ "execution_count": 15,
578
+ "metadata": {
579
+ "colab": {
580
+ "base_uri": "https://localhost:8080/",
581
+ "height": 466
582
+ },
583
+ "id": "kkaxAfyQdcgZ",
584
+ "outputId": "1fa73eb8-c4ea-4b0b-8288-7dcb3c517798"
585
+ },
586
+ "outputs": [
587
+ {
588
+ "data": {
589
+ "text/plain": [
590
+ "<Axes: xlabel='answer', ylabel='count'>"
591
+ ]
592
+ },
593
+ "execution_count": 15,
594
+ "metadata": {},
595
+ "output_type": "execute_result"
596
+ },
597
+ {
598
+ "data": {
599
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAAkQAAAGwCAYAAABIC3rIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMywgaHR0cHM6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3684779Sdd94pSUpKStKdd96pmTNnytvbWzt37tR//dd/qUOHDkpISFCPHj20fv16l+d7lixZok6dOmnAgAEaMmSI7rvvPpfPGAoICNDq1auVn5+vHj166Nlnn9XMmTN/8i33AADAPNf0UPW1ioqKktPp/MnxVatW/ew+mjZtqqVLl162pmvXrlq/fv1V9wcAAMxwQz1DBAAAcD0QiAAAgPEIRAAAwHgEIgAAYDwCEQAAMB6BCAAAGI9ABAAAjEcgAgAAxiMQAQAA4xGIAACA8QhEAADAeAQiAABgPAIRAAAwHoEIAAAYj0AEAACMRyACAADGIxABAADjEYgAAIDxCEQAAMB4BCIAAGA8AhEAADAegQgAABivnrsbAOA+PaYtdncL8DA5r8S7uwXALbhCBAAAjEcgAgAAxiMQAQAA4xGIAACA8QhEAADAeAQiAABgPAIRAAAwHoEIAAAYj0AEAACMRyACAADGIxABAADjEYgAAIDxCEQAAMB4BCIAAGA8AhEAADAegQgAABiPQAQAAIxHIAIAAMYjEAEAAOMRiAAAgPEIRAAAwHhuDUTr1q3T0KFDFRYWJpvNpk8//dRl3Ol0aubMmWrRooX8/Pw0cOBA7d+/36Xm+PHjiouLk91uV2BgoBISElReXu5Ss3PnTvXp00cNGjRQeHi45s6de72nBgAAbiBuDUSnTp1St27d9Oabb15yfO7cufrDH/6ghQsXasuWLWrUqJGio6N19uxZqyYuLk579uxRenq6VqxYoXXr1umpp56yxsvKyjRo0CC1bt1aOTk5euWVVzR79my98847131+AADgxlDPnQcfPHiwBg8efMkxp9OpN954Q88995yGDRsmSVq8eLFCQkL06aefatSoUdq3b59Wrlypbdu26a677pIkLViwQEOGDNGrr76qsLAwLVmyROfOndP7778vHx8fde7cWbm5uXrttddcghMAADCXxz5DlJ+fr8LCQg0cONDaFhAQoF69eik7O1uSlJ2drcDAQCsMSdLAgQPl5eWlLVu2WDV9+/aVj4+PVRMdHa28vDydOHHikseuqKhQWVmZywIAAG5eHhuICgsLJUkhISEu20NCQqyxwsJCBQcHu4zXq1dPTZs2dam51D5+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LFhgrbdu3dr5+uuv//zk4PGu9fzr1auXMzEx0WX83nvvdXbr1u0nj1lZWels3Lixc/ny5dY2Sc5PPvnEpW7WrFku+3nmmWec/fv3t9ZXrVrl9PX1dZ44ccLpdDqdCQkJzqeeesplH+vXr3d6eXk5z5w585P9wLP169fPGRER4ayqqrK2zZgxwxkREeH817/+5ZTk3LhxozX23XffOf38/JwfffSR0+l0Ort06eKcPXv2Jfdd/XOw+hz64IMPnAEBARfV/fBn3vnz553Nmzd3Ll682BofPXq0c+TIkU6n0+k8e/ass2HDhs5Nmza57CMhIcE5evToq57/zYorRLikrl27uqy3aNFCxcXF2rFjh8rLy9WsWTPreQp/f3/l5+frwIEDtXLsu+66y2W9vLxcU6dOVUREhAIDA+Xv7699+/Zxhegmdi3nX15enu6++26X1/94vaioSOPGjdNtt92mgIAA2e12lZeXX/U5FRcXp8zMTB0+fFjS91enYmNjrYdgd+zYodTUVJdeo6OjVVVVpfz8/Ks6FjxL7969ZbPZrHWHw6H9+/dr7969qlevnnr16mWNNWvWTB07dtS+ffskSZMmTdKLL76oe++9V7NmzdLOnTuvqZd69erpV7/6lZYsWSJJOnXqlD777DPrSuW3336r06dP64EHHnA5FxcvXlxrP7dvBjytikuqX7++y7rNZlNVVZXKy8vVokULZWZmXvSa6l8CXl5e1r30atWXiq9Eo0aNXNanTp2q9PR0vfrqq2rfvr38/Pz00EMP6dy5c1e8T9xYruX8uxJjxozRsWPHNH/+fLVu3Vq+vr5yOBxXfU717NlTt956qz788EM9/fTT+uSTT5SammqNl5eX67//+781adKki17bqlWrqzoWbh5jx45VdHS00tLStHr1aqWkpGjevHmaOHFijfcZFxenfv36qbi4WOnp6fLz81NMTIwkWbfS0tLSdMstt7i8jr+V9v8QiHBVunfvrsLCQtWrV8960PTHgoKCtHv3bpdtubm5Lr/kfHx8VFlZeUXH3Lhxox5//HHrXnh5ebkOHjxYo/5xY7uS869jx47atm2b4uPjrW0/fgZo48aNeuuttzRkyBBJ0qFDh/Tdd9+51NSvX/+KztG4uDgtWbJELVu2lJeXl2JjY1363bt3r9q3b3+lU8QNYsuWLS7r1c+iRUZG6sKFC9qyZYvuueceSdKxY8eUl5enyMhIqz48PFzjx4/X+PHjlZycrHffffeSgehKf1bec889Cg8P17Jly/Tll1/q4Ycftn7mRkZGytfXVwUFBerXr9+1TPumxi0zXJWBAwfK4XBo+PDhWr16tQ4ePKhNmzbpN7/5jbZv3y5J6t+/v7Zv367Fixdr//79mjVr1kUBqU2bNtqyZYsOHjyo7777TlVVVT95zNtuu00ff/yxcnNztWPHDj3yyCOXrcfN60rOv4kTJ+rPf/6zFi1apP379+vFF1/Uzp07XW5v3HbbbfrLX/6iffv2acuWLYqLi5Ofn5/Lsdq0aaOMjAwVFhbqxIkTP9lTXFycvv76a7300kt66KGHXP7HPWPGDG3atEkTJkxQbm6u9u/fr88++4yHqm8CBQUFSkpKUl5env76179qwYIFeuaZZ3Tbbbdp2LBhGjdunDZs2KAdO3bo0Ucf1S233KJhw4ZJ+v5dt6tWrVJ+fr6+/vprrV27VhEREZc8Tps2bVReXq6MjAx99913On369E/29Mgjj2jhwoVKT0+3bpdJUuPGjTV16lRNmTJFixYt0oEDB/T1119rwYIFWrRoUe1+Y25gBCJcFZvNpi+++EJ9+/bVE088oQ4dOmjUqFH697//rZCQEElSdHS0nn/+eU2fPl09e/bUyZMnXf63Ln1/G8zb21uRkZEKCgq67LMbr732mpo0aaJ77rlHQ4cOVXR0tLp3735d5wnPdCXnX1xcnJKTkzV16lR1795d+fn5evzxx9WgQQNrP3/+85914sQJde/eXY899pgmTZqk4OBgl2PNmzdP6enpCg8P15133vmTPbVv31533323du7c6fJLSPr+WaisrCz961//Up8+fXTnnXdq5syZCgsLq8XvCtwhPj5eZ86c0d13363ExEQ988wz1gclfvDBB+rRo4cefPBBORwOOZ1OffHFF9YVm8rKSiUmJioiIkIxMTHq0KGD3nrrrUse55577tH48eM1cuRIBQUFae7cuT/ZU1xcnPbu3atbbrlF9957r8vYCy+8oOeff14pKSnWcdPS0tS2bdta+o7c+GzOHz/sAQA3mQceeEChoaH6y1/+4u5WcBOIiorSHXfcwZ/OuMnwDBGAm8rp06e1cOFCRUdHy9vbW3/961/11VdfWZ9jBACXQiACcFOpvq320ksv6ezZs+rYsaP+8Y9/aODAge5uDYAH45YZAAAwHg9VAwAA4xGIAACA8QhEAADAeAQiAABgPAIRAAAwHoEIAAAYj0AEAACMRyACgOussrKSP0gMeDgCEYAbwsqVK3XfffcpMDBQzZo104MPPqgDBw5Ikg4ePCibzaaPP/5Y999/vxo2bKhu3bopOzvbev2///1vDR06VE2aNFGjRo3UuXNnffHFF5Kku+66S6+++qpVO3z4cNWvX1/l5eWSpP/85z+y2Wz69ttvJUkVFRWaOnWqbrnlFjVq1Ei9evVSZmam9frU1FQFBgbq888/V2RkpHx9fS/7B4wBuB+BCMAN4dSpU0pKStL27duVkZEhLy8v/eIXv3C58vKb3/xGU6dOVW5urjp06KDRo0frwoULkqTExERVVFRo3bp12rVrl15++WX5+/tLkvr162cFGqfTqfXr1yswMFAbNmyQJGVlZemWW25R+/btJUkTJkxQdna2PvzwQ+3cuVMPP/ywYmJitH//fquX06dP6+WXX9Z7772nPXv2KDg4uC6+TQBqiD/dAeCG9N133ykoKEi7du2Sv7+/2rZtq/fee08JCQmSpL1796pz587at2+fOnXqpK5du2rEiBGaNWvWRftavny5HnvsMR07dky7d+9WTEyMRo4cqQYNGuj3v/+9xo0bp9OnT2vJkiUqKChQu3btVFBQoLCwMGsfAwcO1N13363f/e53Sk1N1RNPPKHc3Fx169atzr4nAGqOK0QAbgj79+/X6NGj1a5dO9ntdrVp00aSXG5Fde3a1fq6RYsWkqTi4mJJ0qRJk/Tiiy/q3nvv1axZs7Rz506rtk+fPjp58qT++c9/KisrS/369VNUVJR11SgrK0tRUVGSpF27dqmyslIdOnSQv7+/tWRlZVm38CTJx8fHpR8Ano2/dg/ghjB06FC1bt1a7777rsLCwlRVVaXbb79d586ds2rq169vfW2z2STJuqU2duxYRUdHKy0tTatXr1ZKSormzZuniRMnKjAwUN26dVNmZqays7P1wAMPqG/fvho5cqT+9a9/af/+/erXr58kqby8XN7e3srJyZG3t7dLj9W34CTJz8/P6gGA5+MKEQCPd+zYMeXl5em5557TgAEDFBERoRMnTlz1fsLDwzV+/Hh9/PHHevbZZ/Xuu+9aY/369dPatWu1bt06RUVFqWnTpoqIiNBLL72kFi1aqEOHDpKkO++8U5WVlSouLlb79u1dltDQ0FqbM4C6RSAC4PGaNGmiZs2a6Z133tG3336rNWvWKCkp6ar2MXnyZK1atUr5+fn6+uuvtXbtWkVERFjjUVFRWrVqlerVq6dOnTpZ25YsWWJdHZKkDh06KC4uTvHx8fr444+Vn5+vrVu3KiUlRWlpabUzYQB1jkAEwON5eXnpww8/VE5Ojm6//XZNmTJFr7zyylXto7KyUomJiYqIiFBMTIw6dOigt956yxrv06ePqqqqXMJPVFSUKisrreeHqn3wwQeKj4/Xs88+q44dO2r48OHatm2bWrVqdU3zBOA+vMsMAAAYjytEAADAeAQiAABgPAIRAAAwHoEIAAAYj0AEAACMRyACAADGIxABAADjEYgAAIDxCEQAAMB4BCIAAGA8AhEAADDe/weCiimbenEpXAAAAABJRU5ErkJggg==",
600
+ "text/plain": [
601
+ "<Figure size 640x480 with 1 Axes>"
602
+ ]
603
+ },
604
+ "metadata": {},
605
+ "output_type": "display_data"
606
+ }
607
+ ],
608
+ "source": [
609
+ "sns.countplot(x=df_sampled[\"answer\"])"
610
+ ]
611
+ },
612
+ {
613
+ "cell_type": "code",
614
+ "execution_count": 16,
615
+ "metadata": {
616
+ "colab": {
617
+ "base_uri": "https://localhost:8080/"
618
+ },
619
+ "id": "e2DP6ekqfNbe",
620
+ "outputId": "3aacbc50-8554-40eb-9cdb-c949c30d634e"
621
+ },
622
+ "outputs": [
623
+ {
624
+ "name": "stdout",
625
+ "output_type": "stream",
626
+ "text": [
627
+ "answer\n",
628
+ "negative 1236\n",
629
+ "neutral 1236\n",
630
+ "positive 1236\n",
631
+ "Name: count, dtype: int64\n",
632
+ "(3708, 2)\n"
633
+ ]
634
+ },
635
+ {
636
+ "name": "stderr",
637
+ "output_type": "stream",
638
+ "text": [
639
+ "/var/folders/xc/v1l81vkx6fjc9wpqc0tsnl400000gn/T/ipykernel_11468/1830774783.py:5: DeprecationWarning: DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated, and in a future version of pandas the grouping columns will be excluded from the operation. Either pass `include_groups=False` to exclude the groupings or explicitly select the grouping columns after groupby to silence this warning.\n",
640
+ " df_balanced = df_sampled.groupby(\"answer\").apply(lambda x: x.sample(min_class_count, random_state=42)).reset_index(drop=True)\n"
641
+ ]
642
+ }
643
+ ],
644
+ "source": [
645
+ "# Undersampling each class to match the class with the smallest number of samples\n",
646
+ "min_class_count = df_sampled[\"answer\"].value_counts().min()\n",
647
+ "\n",
648
+ "# Sampling an equal number of rows from each class\n",
649
+ "df_balanced = df_sampled.groupby(\"answer\").apply(lambda x: x.sample(min_class_count, random_state=42)).reset_index(drop=True)\n",
650
+ "\n",
651
+ "# Showing the new class distribution\n",
652
+ "print(df_balanced[\"answer\"].value_counts())\n",
653
+ "print(df_balanced.shape)\n"
654
+ ]
655
+ },
656
+ {
657
+ "cell_type": "code",
658
+ "execution_count": 17,
659
+ "metadata": {
660
+ "id": "dJosNJACYDCc"
661
+ },
662
+ "outputs": [
663
+ {
664
+ "data": {
665
+ "application/vnd.jupyter.widget-view+json": {
666
+ "model_id": "593c0e8a5f6b4b9495ff422cc2382975",
667
+ "version_major": 2,
668
+ "version_minor": 0
669
+ },
670
+ "text/plain": [
671
+ "modules.json: 0%| | 0.00/349 [00:00<?, ?B/s]"
672
+ ]
673
+ },
674
+ "metadata": {},
675
+ "output_type": "display_data"
676
+ },
677
+ {
678
+ "data": {
679
+ "application/vnd.jupyter.widget-view+json": {
680
+ "model_id": "850ce1db88c64b81802f2a60f45801d4",
681
+ "version_major": 2,
682
+ "version_minor": 0
683
+ },
684
+ "text/plain": [
685
+ "config_sentence_transformers.json: 0%| | 0.00/116 [00:00<?, ?B/s]"
686
+ ]
687
+ },
688
+ "metadata": {},
689
+ "output_type": "display_data"
690
+ },
691
+ {
692
+ "data": {
693
+ "application/vnd.jupyter.widget-view+json": {
694
+ "model_id": "8cfd7d7217a24485818919eebbca3cb2",
695
+ "version_major": 2,
696
+ "version_minor": 0
697
+ },
698
+ "text/plain": [
699
+ "README.md: 0%| | 0.00/10.7k [00:00<?, ?B/s]"
700
+ ]
701
+ },
702
+ "metadata": {},
703
+ "output_type": "display_data"
704
+ },
705
+ {
706
+ "data": {
707
+ "application/vnd.jupyter.widget-view+json": {
708
+ "model_id": "6aa8a1f649ec471ebe07ee374e80de62",
709
+ "version_major": 2,
710
+ "version_minor": 0
711
+ },
712
+ "text/plain": [
713
+ "sentence_bert_config.json: 0%| | 0.00/53.0 [00:00<?, ?B/s]"
714
+ ]
715
+ },
716
+ "metadata": {},
717
+ "output_type": "display_data"
718
+ },
719
+ {
720
+ "data": {
721
+ "application/vnd.jupyter.widget-view+json": {
722
+ "model_id": "cb49e7e953654af8af5fd5d22f78ce59",
723
+ "version_major": 2,
724
+ "version_minor": 0
725
+ },
726
+ "text/plain": [
727
+ "config.json: 0%| | 0.00/612 [00:00<?, ?B/s]"
728
+ ]
729
+ },
730
+ "metadata": {},
731
+ "output_type": "display_data"
732
+ },
733
+ {
734
+ "data": {
735
+ "application/vnd.jupyter.widget-view+json": {
736
+ "model_id": "12bb5d1510b1422582f091a49fa617a0",
737
+ "version_major": 2,
738
+ "version_minor": 0
739
+ },
740
+ "text/plain": [
741
+ "model.safetensors: 0%| | 0.00/90.9M [00:00<?, ?B/s]"
742
+ ]
743
+ },
744
+ "metadata": {},
745
+ "output_type": "display_data"
746
+ },
747
+ {
748
+ "data": {
749
+ "application/vnd.jupyter.widget-view+json": {
750
+ "model_id": "b9632a0063044733bd70e443fce6caed",
751
+ "version_major": 2,
752
+ "version_minor": 0
753
+ },
754
+ "text/plain": [
755
+ "tokenizer_config.json: 0%| | 0.00/350 [00:00<?, ?B/s]"
756
+ ]
757
+ },
758
+ "metadata": {},
759
+ "output_type": "display_data"
760
+ },
761
+ {
762
+ "data": {
763
+ "application/vnd.jupyter.widget-view+json": {
764
+ "model_id": "5d345282cdd6400d8bc229280df8766e",
765
+ "version_major": 2,
766
+ "version_minor": 0
767
+ },
768
+ "text/plain": [
769
+ "vocab.txt: 0%| | 0.00/232k [00:00<?, ?B/s]"
770
+ ]
771
+ },
772
+ "metadata": {},
773
+ "output_type": "display_data"
774
+ },
775
+ {
776
+ "data": {
777
+ "application/vnd.jupyter.widget-view+json": {
778
+ "model_id": "0473d385d77c406a94075d701d4565e1",
779
+ "version_major": 2,
780
+ "version_minor": 0
781
+ },
782
+ "text/plain": [
783
+ "tokenizer.json: 0%| | 0.00/466k [00:00<?, ?B/s]"
784
+ ]
785
+ },
786
+ "metadata": {},
787
+ "output_type": "display_data"
788
+ },
789
+ {
790
+ "data": {
791
+ "application/vnd.jupyter.widget-view+json": {
792
+ "model_id": "643a5bf87437468e8a168e55687814d5",
793
+ "version_major": 2,
794
+ "version_minor": 0
795
+ },
796
+ "text/plain": [
797
+ "special_tokens_map.json: 0%| | 0.00/112 [00:00<?, ?B/s]"
798
+ ]
799
+ },
800
+ "metadata": {},
801
+ "output_type": "display_data"
802
+ },
803
+ {
804
+ "data": {
805
+ "application/vnd.jupyter.widget-view+json": {
806
+ "model_id": "4560c43f64884ba9b236962626a1f784",
807
+ "version_major": 2,
808
+ "version_minor": 0
809
+ },
810
+ "text/plain": [
811
+ "1_Pooling%2Fconfig.json: 0%| | 0.00/190 [00:00<?, ?B/s]"
812
+ ]
813
+ },
814
+ "metadata": {},
815
+ "output_type": "display_data"
816
+ }
817
+ ],
818
+ "source": [
819
+ "# Load model\n",
820
+ "from sentence_transformers import SentenceTransformer # import the SentenceTransformer class\n",
821
+ "model = SentenceTransformer(\"all-MiniLM-L6-v2\")\n",
822
+ "\n",
823
+ "# Converting text to embeddings\n",
824
+ "X = model.encode(df_balanced[\"user_prompt\"].tolist(), convert_to_numpy=True)"
825
+ ]
826
+ },
827
+ {
828
+ "cell_type": "code",
829
+ "execution_count": 18,
830
+ "metadata": {
831
+ "colab": {
832
+ "base_uri": "https://localhost:8080/"
833
+ },
834
+ "id": "mH4_pI6YZa3E",
835
+ "outputId": "667d2b0f-a60a-4afd-e2aa-270ef9d5b8de"
836
+ },
837
+ "outputs": [
838
+ {
839
+ "name": "stdout",
840
+ "output_type": "stream",
841
+ "text": [
842
+ "Label Mapping: {'negative': 0, 'neutral': 1, 'positive': 2}\n"
843
+ ]
844
+ }
845
+ ],
846
+ "source": [
847
+ "from sklearn.preprocessing import LabelEncoder\n",
848
+ "\n",
849
+ "# Encode labels\n",
850
+ "label_encoder = LabelEncoder()\n",
851
+ "y = label_encoder.fit_transform(df_balanced[\"answer\"])\n",
852
+ "\n",
853
+ "# Saving the mapping\n",
854
+ "label_mapping = dict(zip(label_encoder.classes_, label_encoder.transform(label_encoder.classes_)))\n",
855
+ "print(\"Label Mapping:\", label_mapping)\n"
856
+ ]
857
+ },
858
+ {
859
+ "cell_type": "code",
860
+ "execution_count": 19,
861
+ "metadata": {
862
+ "id": "I5gpynBmZe1h"
863
+ },
864
+ "outputs": [],
865
+ "source": [
866
+ "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n"
867
+ ]
868
+ },
869
+ {
870
+ "cell_type": "code",
871
+ "execution_count": 20,
872
+ "metadata": {
873
+ "colab": {
874
+ "base_uri": "https://localhost:8080/",
875
+ "height": 80
876
+ },
877
+ "id": "jCUXUqgRgdeJ",
878
+ "outputId": "8e27311c-e799-4a89-f319-f7b6f4e07e75"
879
+ },
880
+ "outputs": [
881
+ {
882
+ "data": {
883
+ "text/html": [
884
+ "<style>#sk-container-id-1 {\n",
885
+ " /* Definition of color scheme common for light and dark mode */\n",
886
+ " --sklearn-color-text: black;\n",
887
+ " --sklearn-color-line: gray;\n",
888
+ " /* Definition of color scheme for unfitted estimators */\n",
889
+ " --sklearn-color-unfitted-level-0: #fff5e6;\n",
890
+ " --sklearn-color-unfitted-level-1: #f6e4d2;\n",
891
+ " --sklearn-color-unfitted-level-2: #ffe0b3;\n",
892
+ " --sklearn-color-unfitted-level-3: chocolate;\n",
893
+ " /* Definition of color scheme for fitted estimators */\n",
894
+ " --sklearn-color-fitted-level-0: #f0f8ff;\n",
895
+ " --sklearn-color-fitted-level-1: #d4ebff;\n",
896
+ " --sklearn-color-fitted-level-2: #b3dbfd;\n",
897
+ " --sklearn-color-fitted-level-3: cornflowerblue;\n",
898
+ "\n",
899
+ " /* Specific color for light theme */\n",
900
+ " --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
901
+ " --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, white)));\n",
902
+ " --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
903
+ " --sklearn-color-icon: #696969;\n",
904
+ "\n",
905
+ " @media (prefers-color-scheme: dark) {\n",
906
+ " /* Redefinition of color scheme for dark theme */\n",
907
+ " --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
908
+ " --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, #111)));\n",
909
+ " --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
910
+ " --sklearn-color-icon: #878787;\n",
911
+ " }\n",
912
+ "}\n",
913
+ "\n",
914
+ "#sk-container-id-1 {\n",
915
+ " color: var(--sklearn-color-text);\n",
916
+ "}\n",
917
+ "\n",
918
+ "#sk-container-id-1 pre {\n",
919
+ " padding: 0;\n",
920
+ "}\n",
921
+ "\n",
922
+ "#sk-container-id-1 input.sk-hidden--visually {\n",
923
+ " border: 0;\n",
924
+ " clip: rect(1px 1px 1px 1px);\n",
925
+ " clip: rect(1px, 1px, 1px, 1px);\n",
926
+ " height: 1px;\n",
927
+ " margin: -1px;\n",
928
+ " overflow: hidden;\n",
929
+ " padding: 0;\n",
930
+ " position: absolute;\n",
931
+ " width: 1px;\n",
932
+ "}\n",
933
+ "\n",
934
+ "#sk-container-id-1 div.sk-dashed-wrapped {\n",
935
+ " border: 1px dashed var(--sklearn-color-line);\n",
936
+ " margin: 0 0.4em 0.5em 0.4em;\n",
937
+ " box-sizing: border-box;\n",
938
+ " padding-bottom: 0.4em;\n",
939
+ " background-color: var(--sklearn-color-background);\n",
940
+ "}\n",
941
+ "\n",
942
+ "#sk-container-id-1 div.sk-container {\n",
943
+ " /* jupyter's `normalize.less` sets `[hidden] { display: none; }`\n",
944
+ " but bootstrap.min.css set `[hidden] { display: none !important; }`\n",
945
+ " so we also need the `!important` here to be able to override the\n",
946
+ " default hidden behavior on the sphinx rendered scikit-learn.org.\n",
947
+ " See: https://github.com/scikit-learn/scikit-learn/issues/21755 */\n",
948
+ " display: inline-block !important;\n",
949
+ " position: relative;\n",
950
+ "}\n",
951
+ "\n",
952
+ "#sk-container-id-1 div.sk-text-repr-fallback {\n",
953
+ " display: none;\n",
954
+ "}\n",
955
+ "\n",
956
+ "div.sk-parallel-item,\n",
957
+ "div.sk-serial,\n",
958
+ "div.sk-item {\n",
959
+ " /* draw centered vertical line to link estimators */\n",
960
+ " background-image: linear-gradient(var(--sklearn-color-text-on-default-background), var(--sklearn-color-text-on-default-background));\n",
961
+ " background-size: 2px 100%;\n",
962
+ " background-repeat: no-repeat;\n",
963
+ " background-position: center center;\n",
964
+ "}\n",
965
+ "\n",
966
+ "/* Parallel-specific style estimator block */\n",
967
+ "\n",
968
+ "#sk-container-id-1 div.sk-parallel-item::after {\n",
969
+ " content: \"\";\n",
970
+ " width: 100%;\n",
971
+ " border-bottom: 2px solid var(--sklearn-color-text-on-default-background);\n",
972
+ " flex-grow: 1;\n",
973
+ "}\n",
974
+ "\n",
975
+ "#sk-container-id-1 div.sk-parallel {\n",
976
+ " display: flex;\n",
977
+ " align-items: stretch;\n",
978
+ " justify-content: center;\n",
979
+ " background-color: var(--sklearn-color-background);\n",
980
+ " position: relative;\n",
981
+ "}\n",
982
+ "\n",
983
+ "#sk-container-id-1 div.sk-parallel-item {\n",
984
+ " display: flex;\n",
985
+ " flex-direction: column;\n",
986
+ "}\n",
987
+ "\n",
988
+ "#sk-container-id-1 div.sk-parallel-item:first-child::after {\n",
989
+ " align-self: flex-end;\n",
990
+ " width: 50%;\n",
991
+ "}\n",
992
+ "\n",
993
+ "#sk-container-id-1 div.sk-parallel-item:last-child::after {\n",
994
+ " align-self: flex-start;\n",
995
+ " width: 50%;\n",
996
+ "}\n",
997
+ "\n",
998
+ "#sk-container-id-1 div.sk-parallel-item:only-child::after {\n",
999
+ " width: 0;\n",
1000
+ "}\n",
1001
+ "\n",
1002
+ "/* Serial-specific style estimator block */\n",
1003
+ "\n",
1004
+ "#sk-container-id-1 div.sk-serial {\n",
1005
+ " display: flex;\n",
1006
+ " flex-direction: column;\n",
1007
+ " align-items: center;\n",
1008
+ " background-color: var(--sklearn-color-background);\n",
1009
+ " padding-right: 1em;\n",
1010
+ " padding-left: 1em;\n",
1011
+ "}\n",
1012
+ "\n",
1013
+ "\n",
1014
+ "/* Toggleable style: style used for estimator/Pipeline/ColumnTransformer box that is\n",
1015
+ "clickable and can be expanded/collapsed.\n",
1016
+ "- Pipeline and ColumnTransformer use this feature and define the default style\n",
1017
+ "- Estimators will overwrite some part of the style using the `sk-estimator` class\n",
1018
+ "*/\n",
1019
+ "\n",
1020
+ "/* Pipeline and ColumnTransformer style (default) */\n",
1021
+ "\n",
1022
+ "#sk-container-id-1 div.sk-toggleable {\n",
1023
+ " /* Default theme specific background. It is overwritten whether we have a\n",
1024
+ " specific estimator or a Pipeline/ColumnTransformer */\n",
1025
+ " background-color: var(--sklearn-color-background);\n",
1026
+ "}\n",
1027
+ "\n",
1028
+ "/* Toggleable label */\n",
1029
+ "#sk-container-id-1 label.sk-toggleable__label {\n",
1030
+ " cursor: pointer;\n",
1031
+ " display: block;\n",
1032
+ " width: 100%;\n",
1033
+ " margin-bottom: 0;\n",
1034
+ " padding: 0.5em;\n",
1035
+ " box-sizing: border-box;\n",
1036
+ " text-align: center;\n",
1037
+ "}\n",
1038
+ "\n",
1039
+ "#sk-container-id-1 label.sk-toggleable__label-arrow:before {\n",
1040
+ " /* Arrow on the left of the label */\n",
1041
+ " content: \"▸\";\n",
1042
+ " float: left;\n",
1043
+ " margin-right: 0.25em;\n",
1044
+ " color: var(--sklearn-color-icon);\n",
1045
+ "}\n",
1046
+ "\n",
1047
+ "#sk-container-id-1 label.sk-toggleable__label-arrow:hover:before {\n",
1048
+ " color: var(--sklearn-color-text);\n",
1049
+ "}\n",
1050
+ "\n",
1051
+ "/* Toggleable content - dropdown */\n",
1052
+ "\n",
1053
+ "#sk-container-id-1 div.sk-toggleable__content {\n",
1054
+ " max-height: 0;\n",
1055
+ " max-width: 0;\n",
1056
+ " overflow: hidden;\n",
1057
+ " text-align: left;\n",
1058
+ " /* unfitted */\n",
1059
+ " background-color: var(--sklearn-color-unfitted-level-0);\n",
1060
+ "}\n",
1061
+ "\n",
1062
+ "#sk-container-id-1 div.sk-toggleable__content.fitted {\n",
1063
+ " /* fitted */\n",
1064
+ " background-color: var(--sklearn-color-fitted-level-0);\n",
1065
+ "}\n",
1066
+ "\n",
1067
+ "#sk-container-id-1 div.sk-toggleable__content pre {\n",
1068
+ " margin: 0.2em;\n",
1069
+ " border-radius: 0.25em;\n",
1070
+ " color: var(--sklearn-color-text);\n",
1071
+ " /* unfitted */\n",
1072
+ " background-color: var(--sklearn-color-unfitted-level-0);\n",
1073
+ "}\n",
1074
+ "\n",
1075
+ "#sk-container-id-1 div.sk-toggleable__content.fitted pre {\n",
1076
+ " /* unfitted */\n",
1077
+ " background-color: var(--sklearn-color-fitted-level-0);\n",
1078
+ "}\n",
1079
+ "\n",
1080
+ "#sk-container-id-1 input.sk-toggleable__control:checked~div.sk-toggleable__content {\n",
1081
+ " /* Expand drop-down */\n",
1082
+ " max-height: 200px;\n",
1083
+ " max-width: 100%;\n",
1084
+ " overflow: auto;\n",
1085
+ "}\n",
1086
+ "\n",
1087
+ "#sk-container-id-1 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {\n",
1088
+ " content: \"▾\";\n",
1089
+ "}\n",
1090
+ "\n",
1091
+ "/* Pipeline/ColumnTransformer-specific style */\n",
1092
+ "\n",
1093
+ "#sk-container-id-1 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
1094
+ " color: var(--sklearn-color-text);\n",
1095
+ " background-color: var(--sklearn-color-unfitted-level-2);\n",
1096
+ "}\n",
1097
+ "\n",
1098
+ "#sk-container-id-1 div.sk-label.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
1099
+ " background-color: var(--sklearn-color-fitted-level-2);\n",
1100
+ "}\n",
1101
+ "\n",
1102
+ "/* Estimator-specific style */\n",
1103
+ "\n",
1104
+ "/* Colorize estimator box */\n",
1105
+ "#sk-container-id-1 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
1106
+ " /* unfitted */\n",
1107
+ " background-color: var(--sklearn-color-unfitted-level-2);\n",
1108
+ "}\n",
1109
+ "\n",
1110
+ "#sk-container-id-1 div.sk-estimator.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
1111
+ " /* fitted */\n",
1112
+ " background-color: var(--sklearn-color-fitted-level-2);\n",
1113
+ "}\n",
1114
+ "\n",
1115
+ "#sk-container-id-1 div.sk-label label.sk-toggleable__label,\n",
1116
+ "#sk-container-id-1 div.sk-label label {\n",
1117
+ " /* The background is the default theme color */\n",
1118
+ " color: var(--sklearn-color-text-on-default-background);\n",
1119
+ "}\n",
1120
+ "\n",
1121
+ "/* On hover, darken the color of the background */\n",
1122
+ "#sk-container-id-1 div.sk-label:hover label.sk-toggleable__label {\n",
1123
+ " color: var(--sklearn-color-text);\n",
1124
+ " background-color: var(--sklearn-color-unfitted-level-2);\n",
1125
+ "}\n",
1126
+ "\n",
1127
+ "/* Label box, darken color on hover, fitted */\n",
1128
+ "#sk-container-id-1 div.sk-label.fitted:hover label.sk-toggleable__label.fitted {\n",
1129
+ " color: var(--sklearn-color-text);\n",
1130
+ " background-color: var(--sklearn-color-fitted-level-2);\n",
1131
+ "}\n",
1132
+ "\n",
1133
+ "/* Estimator label */\n",
1134
+ "\n",
1135
+ "#sk-container-id-1 div.sk-label label {\n",
1136
+ " font-family: monospace;\n",
1137
+ " font-weight: bold;\n",
1138
+ " display: inline-block;\n",
1139
+ " line-height: 1.2em;\n",
1140
+ "}\n",
1141
+ "\n",
1142
+ "#sk-container-id-1 div.sk-label-container {\n",
1143
+ " text-align: center;\n",
1144
+ "}\n",
1145
+ "\n",
1146
+ "/* Estimator-specific */\n",
1147
+ "#sk-container-id-1 div.sk-estimator {\n",
1148
+ " font-family: monospace;\n",
1149
+ " border: 1px dotted var(--sklearn-color-border-box);\n",
1150
+ " border-radius: 0.25em;\n",
1151
+ " box-sizing: border-box;\n",
1152
+ " margin-bottom: 0.5em;\n",
1153
+ " /* unfitted */\n",
1154
+ " background-color: var(--sklearn-color-unfitted-level-0);\n",
1155
+ "}\n",
1156
+ "\n",
1157
+ "#sk-container-id-1 div.sk-estimator.fitted {\n",
1158
+ " /* fitted */\n",
1159
+ " background-color: var(--sklearn-color-fitted-level-0);\n",
1160
+ "}\n",
1161
+ "\n",
1162
+ "/* on hover */\n",
1163
+ "#sk-container-id-1 div.sk-estimator:hover {\n",
1164
+ " /* unfitted */\n",
1165
+ " background-color: var(--sklearn-color-unfitted-level-2);\n",
1166
+ "}\n",
1167
+ "\n",
1168
+ "#sk-container-id-1 div.sk-estimator.fitted:hover {\n",
1169
+ " /* fitted */\n",
1170
+ " background-color: var(--sklearn-color-fitted-level-2);\n",
1171
+ "}\n",
1172
+ "\n",
1173
+ "/* Specification for estimator info (e.g. \"i\" and \"?\") */\n",
1174
+ "\n",
1175
+ "/* Common style for \"i\" and \"?\" */\n",
1176
+ "\n",
1177
+ ".sk-estimator-doc-link,\n",
1178
+ "a:link.sk-estimator-doc-link,\n",
1179
+ "a:visited.sk-estimator-doc-link {\n",
1180
+ " float: right;\n",
1181
+ " font-size: smaller;\n",
1182
+ " line-height: 1em;\n",
1183
+ " font-family: monospace;\n",
1184
+ " background-color: var(--sklearn-color-background);\n",
1185
+ " border-radius: 1em;\n",
1186
+ " height: 1em;\n",
1187
+ " width: 1em;\n",
1188
+ " text-decoration: none !important;\n",
1189
+ " margin-left: 1ex;\n",
1190
+ " /* unfitted */\n",
1191
+ " border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
1192
+ " color: var(--sklearn-color-unfitted-level-1);\n",
1193
+ "}\n",
1194
+ "\n",
1195
+ ".sk-estimator-doc-link.fitted,\n",
1196
+ "a:link.sk-estimator-doc-link.fitted,\n",
1197
+ "a:visited.sk-estimator-doc-link.fitted {\n",
1198
+ " /* fitted */\n",
1199
+ " border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
1200
+ " color: var(--sklearn-color-fitted-level-1);\n",
1201
+ "}\n",
1202
+ "\n",
1203
+ "/* On hover */\n",
1204
+ "div.sk-estimator:hover .sk-estimator-doc-link:hover,\n",
1205
+ ".sk-estimator-doc-link:hover,\n",
1206
+ "div.sk-label-container:hover .sk-estimator-doc-link:hover,\n",
1207
+ ".sk-estimator-doc-link:hover {\n",
1208
+ " /* unfitted */\n",
1209
+ " background-color: var(--sklearn-color-unfitted-level-3);\n",
1210
+ " color: var(--sklearn-color-background);\n",
1211
+ " text-decoration: none;\n",
1212
+ "}\n",
1213
+ "\n",
1214
+ "div.sk-estimator.fitted:hover .sk-estimator-doc-link.fitted:hover,\n",
1215
+ ".sk-estimator-doc-link.fitted:hover,\n",
1216
+ "div.sk-label-container:hover .sk-estimator-doc-link.fitted:hover,\n",
1217
+ ".sk-estimator-doc-link.fitted:hover {\n",
1218
+ " /* fitted */\n",
1219
+ " background-color: var(--sklearn-color-fitted-level-3);\n",
1220
+ " color: var(--sklearn-color-background);\n",
1221
+ " text-decoration: none;\n",
1222
+ "}\n",
1223
+ "\n",
1224
+ "/* Span, style for the box shown on hovering the info icon */\n",
1225
+ ".sk-estimator-doc-link span {\n",
1226
+ " display: none;\n",
1227
+ " z-index: 9999;\n",
1228
+ " position: relative;\n",
1229
+ " font-weight: normal;\n",
1230
+ " right: .2ex;\n",
1231
+ " padding: .5ex;\n",
1232
+ " margin: .5ex;\n",
1233
+ " width: min-content;\n",
1234
+ " min-width: 20ex;\n",
1235
+ " max-width: 50ex;\n",
1236
+ " color: var(--sklearn-color-text);\n",
1237
+ " box-shadow: 2pt 2pt 4pt #999;\n",
1238
+ " /* unfitted */\n",
1239
+ " background: var(--sklearn-color-unfitted-level-0);\n",
1240
+ " border: .5pt solid var(--sklearn-color-unfitted-level-3);\n",
1241
+ "}\n",
1242
+ "\n",
1243
+ ".sk-estimator-doc-link.fitted span {\n",
1244
+ " /* fitted */\n",
1245
+ " background: var(--sklearn-color-fitted-level-0);\n",
1246
+ " border: var(--sklearn-color-fitted-level-3);\n",
1247
+ "}\n",
1248
+ "\n",
1249
+ ".sk-estimator-doc-link:hover span {\n",
1250
+ " display: block;\n",
1251
+ "}\n",
1252
+ "\n",
1253
+ "/* \"?\"-specific style due to the `<a>` HTML tag */\n",
1254
+ "\n",
1255
+ "#sk-container-id-1 a.estimator_doc_link {\n",
1256
+ " float: right;\n",
1257
+ " font-size: 1rem;\n",
1258
+ " line-height: 1em;\n",
1259
+ " font-family: monospace;\n",
1260
+ " background-color: var(--sklearn-color-background);\n",
1261
+ " border-radius: 1rem;\n",
1262
+ " height: 1rem;\n",
1263
+ " width: 1rem;\n",
1264
+ " text-decoration: none;\n",
1265
+ " /* unfitted */\n",
1266
+ " color: var(--sklearn-color-unfitted-level-1);\n",
1267
+ " border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
1268
+ "}\n",
1269
+ "\n",
1270
+ "#sk-container-id-1 a.estimator_doc_link.fitted {\n",
1271
+ " /* fitted */\n",
1272
+ " border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
1273
+ " color: var(--sklearn-color-fitted-level-1);\n",
1274
+ "}\n",
1275
+ "\n",
1276
+ "/* On hover */\n",
1277
+ "#sk-container-id-1 a.estimator_doc_link:hover {\n",
1278
+ " /* unfitted */\n",
1279
+ " background-color: var(--sklearn-color-unfitted-level-3);\n",
1280
+ " color: var(--sklearn-color-background);\n",
1281
+ " text-decoration: none;\n",
1282
+ "}\n",
1283
+ "\n",
1284
+ "#sk-container-id-1 a.estimator_doc_link.fitted:hover {\n",
1285
+ " /* fitted */\n",
1286
+ " background-color: var(--sklearn-color-fitted-level-3);\n",
1287
+ "}\n",
1288
+ "</style><div id=\"sk-container-id-1\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>RandomForestClassifier(random_state=42)</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator fitted sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-1\" type=\"checkbox\" checked><label for=\"sk-estimator-id-1\" class=\"sk-toggleable__label fitted sk-toggleable__label-arrow fitted\">&nbsp;&nbsp;RandomForestClassifier<a class=\"sk-estimator-doc-link fitted\" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.4/modules/generated/sklearn.ensemble.RandomForestClassifier.html\">?<span>Documentation for RandomForestClassifier</span></a><span class=\"sk-estimator-doc-link fitted\">i<span>Fitted</span></span></label><div class=\"sk-toggleable__content fitted\"><pre>RandomForestClassifier(random_state=42)</pre></div> </div></div></div></div>"
1289
+ ],
1290
+ "text/plain": [
1291
+ "RandomForestClassifier(random_state=42)"
1292
+ ]
1293
+ },
1294
+ "execution_count": 20,
1295
+ "metadata": {},
1296
+ "output_type": "execute_result"
1297
+ }
1298
+ ],
1299
+ "source": [
1300
+ "clf = RandomForestClassifier(n_estimators=100, random_state=42)\n",
1301
+ "clf.fit(X_train, y_train)\n"
1302
+ ]
1303
+ },
1304
+ {
1305
+ "cell_type": "code",
1306
+ "execution_count": 36,
1307
+ "metadata": {},
1308
+ "outputs": [
1309
+ {
1310
+ "name": "stdout",
1311
+ "output_type": "stream",
1312
+ "text": [
1313
+ " precision recall f1-score support\n",
1314
+ "\n",
1315
+ " 0 0.66 0.52 0.58 277\n",
1316
+ " 1 0.62 0.80 0.70 237\n",
1317
+ " 2 0.55 0.52 0.54 228\n",
1318
+ "\n",
1319
+ " accuracy 0.61 742\n",
1320
+ " macro avg 0.61 0.61 0.61 742\n",
1321
+ "weighted avg 0.61 0.61 0.60 742\n",
1322
+ "\n"
1323
+ ]
1324
+ }
1325
+ ],
1326
+ "source": [
1327
+ "from sentence_transformers import SentenceTransformer\n",
1328
+ "from sklearn.ensemble import RandomForestClassifier\n",
1329
+ "from sklearn.model_selection import train_test_split\n",
1330
+ "from sklearn.preprocessing import LabelEncoder\n",
1331
+ "from sklearn.metrics import classification_report\n",
1332
+ "\n",
1333
+ "# Load model (already done)\n",
1334
+ "model = SentenceTransformer(\"all-MiniLM-L6-v2\")\n",
1335
+ "\n",
1336
+ "# Converting text to embeddings\n",
1337
+ "X = model.encode(df_balanced[\"user_prompt\"].tolist(), convert_to_numpy=True)\n",
1338
+ "\n",
1339
+ "# Encode labels (already done)\n",
1340
+ "label_encoder = LabelEncoder()\n",
1341
+ "y = label_encoder.fit_transform(df_balanced[\"answer\"])\n",
1342
+ "\n",
1343
+ "# Train-test split (already done)\n",
1344
+ "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n",
1345
+ "\n",
1346
+ "# Initialize and train RandomForestClassifier\n",
1347
+ "clf = RandomForestClassifier(n_estimators=100, random_state=42)\n",
1348
+ "clf.fit(X_train, y_train)\n",
1349
+ "\n",
1350
+ "# Make predictions on the test set\n",
1351
+ "y_pred = clf.predict(X_test)\n",
1352
+ "\n",
1353
+ "# Print classification report to evaluate performance\n",
1354
+ "print(classification_report(y_test, y_pred))\n"
1355
+ ]
1356
+ },
1357
+ {
1358
+ "cell_type": "code",
1359
+ "execution_count": 35,
1360
+ "metadata": {},
1361
+ "outputs": [
1362
+ {
1363
+ "name": "stderr",
1364
+ "output_type": "stream",
1365
+ "text": [
1366
+ "huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n",
1367
+ "To disable this warning, you can either:\n",
1368
+ "\t- Avoid using `tokenizers` before the fork if possible\n",
1369
+ "\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n",
1370
+ "huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n",
1371
+ "To disable this warning, you can either:\n",
1372
+ "\t- Avoid using `tokenizers` before the fork if possible\n",
1373
+ "\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n",
1374
+ "huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n",
1375
+ "To disable this warning, you can either:\n",
1376
+ "\t- Avoid using `tokenizers` before the fork if possible\n",
1377
+ "\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n",
1378
+ "huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n",
1379
+ "To disable this warning, you can either:\n",
1380
+ "\t- Avoid using `tokenizers` before the fork if possible\n",
1381
+ "\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n",
1382
+ "huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n",
1383
+ "To disable this warning, you can either:\n",
1384
+ "\t- Avoid using `tokenizers` before the fork if possible\n",
1385
+ "\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n",
1386
+ "huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n",
1387
+ "To disable this warning, you can either:\n",
1388
+ "\t- Avoid using `tokenizers` before the fork if possible\n",
1389
+ "\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n",
1390
+ "huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n",
1391
+ "To disable this warning, you can either:\n",
1392
+ "\t- Avoid using `tokenizers` before the fork if possible\n",
1393
+ "\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n",
1394
+ "huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n",
1395
+ "To disable this warning, you can either:\n",
1396
+ "\t- Avoid using `tokenizers` before the fork if possible\n",
1397
+ "\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n",
1398
+ "huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n",
1399
+ "To disable this warning, you can either:\n",
1400
+ "\t- Avoid using `tokenizers` before the fork if possible\n",
1401
+ "\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n"
1402
+ ]
1403
+ },
1404
+ {
1405
+ "name": "stdout",
1406
+ "output_type": "stream",
1407
+ "text": [
1408
+ "Best Parameters: {'max_depth': 20, 'min_samples_split': 5, 'n_estimators': 200}\n"
1409
+ ]
1410
+ }
1411
+ ],
1412
+ "source": [
1413
+ "from sklearn.model_selection import GridSearchCV\n",
1414
+ "\n",
1415
+ "param_grid = {\n",
1416
+ " 'n_estimators': [50, 100, 200],\n",
1417
+ " 'max_depth': [10, 20, 30],\n",
1418
+ " 'min_samples_split': [2, 5, 10]\n",
1419
+ "}\n",
1420
+ "\n",
1421
+ "grid_search = GridSearchCV(estimator=clf, param_grid=param_grid, cv=3, n_jobs=-1)\n",
1422
+ "grid_search.fit(X_train, y_train)\n",
1423
+ "print(\"Best Parameters:\", grid_search.best_params_)\n"
1424
+ ]
1425
+ },
1426
+ {
1427
+ "cell_type": "code",
1428
+ "execution_count": null,
1429
+ "metadata": {},
1430
+ "outputs": [],
1431
+ "source": []
1432
+ },
1433
+ {
1434
+ "cell_type": "code",
1435
+ "execution_count": null,
1436
+ "metadata": {
1437
+ "colab": {
1438
+ "base_uri": "https://localhost:8080/",
1439
+ "height": 339
1440
+ },
1441
+ "id": "QasSqfQhnsqs",
1442
+ "outputId": "ca0b33bf-d2b2-46a5-9e4f-9a68ff77abeb"
1443
+ },
1444
+ "outputs": [
1445
+ {
1446
+ "ename": "ValueError",
1447
+ "evalue": "No columns in the dataset match the model's forward method signature. The following columns have been ignored: [user_prompt, answer]. Please check the dataset and model. You may need to set `remove_unused_columns=False` in `TrainingArguments`.",
1448
+ "output_type": "error",
1449
+ "traceback": [
1450
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
1451
+ "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
1452
+ "\u001b[0;32m<ipython-input-127-6d82a26ee1d5>\u001b[0m in \u001b[0;36m<cell line: 0>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 32\u001b[0m )\n\u001b[1;32m 33\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 34\u001b[0;31m \u001b[0mtrainer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtrain\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
1453
+ "\u001b[0;32m/usr/local/lib/python3.11/dist-packages/transformers/trainer.py\u001b[0m in \u001b[0;36mtrain\u001b[0;34m(self, resume_from_checkpoint, trial, ignore_keys_for_eval, **kwargs)\u001b[0m\n\u001b[1;32m 2169\u001b[0m \u001b[0mhf_hub_utils\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0menable_progress_bars\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2170\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2171\u001b[0;31m return inner_training_loop(\n\u001b[0m\u001b[1;32m 2172\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2173\u001b[0m \u001b[0mresume_from_checkpoint\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mresume_from_checkpoint\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
1454
+ "\u001b[0;32m/usr/local/lib/python3.11/dist-packages/transformers/trainer.py\u001b[0m in \u001b[0;36m_inner_training_loop\u001b[0;34m(self, batch_size, args, resume_from_checkpoint, trial, ignore_keys_for_eval)\u001b[0m\n\u001b[1;32m 2198\u001b[0m \u001b[0mlogger\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdebug\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mf\"Currently training with a batch size of: {self._train_batch_size}\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2199\u001b[0m \u001b[0;31m# Data loader and number of training steps\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2200\u001b[0;31m \u001b[0mtrain_dataloader\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_train_dataloader\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2201\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_fsdp_xla_v2_enabled\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2202\u001b[0m \u001b[0mtrain_dataloader\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtpu_spmd_dataloader\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrain_dataloader\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
1455
+ "\u001b[0;32m/usr/local/lib/python3.11/dist-packages/transformers/trainer.py\u001b[0m in \u001b[0;36mget_train_dataloader\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 998\u001b[0m \u001b[0mdata_collator\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata_collator\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 999\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mis_datasets_available\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrain_dataset\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdatasets\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mDataset\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1000\u001b[0;31m \u001b[0mtrain_dataset\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_remove_unused_columns\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrain_dataset\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdescription\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"training\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1001\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1002\u001b[0m \u001b[0mdata_collator\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_get_collator_with_removed_columns\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata_collator\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdescription\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"training\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
1456
+ "\u001b[0;32m/usr/local/lib/python3.11/dist-packages/transformers/trainer.py\u001b[0m in \u001b[0;36m_remove_unused_columns\u001b[0;34m(self, dataset, description)\u001b[0m\n\u001b[1;32m 924\u001b[0m \u001b[0mcolumns\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mk\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mk\u001b[0m \u001b[0;32min\u001b[0m \u001b[0msignature_columns\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mk\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mdataset\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolumn_names\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 925\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 926\u001b[0;31m raise ValueError(\n\u001b[0m\u001b[1;32m 927\u001b[0m \u001b[0;34m\"No columns in the dataset match the model's forward method signature. \"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 928\u001b[0m \u001b[0;34mf\"The following columns have been ignored: [{', '.join(ignored_columns)}]. \"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
1457
+ "\u001b[0;31mValueError\u001b[0m: No columns in the dataset match the model's forward method signature. The following columns have been ignored: [user_prompt, answer]. Please check the dataset and model. You may need to set `remove_unused_columns=False` in `TrainingArguments`."
1458
+ ]
1459
+ }
1460
+ ],
1461
+ "source": [
1462
+ "from transformers import BertForSequenceClassification, Trainer, TrainingArguments\n",
1463
+ "from datasets import Dataset\n",
1464
+ "\n",
1465
+ "\n",
1466
+ "dataset = Dataset.from_pandas(df_balanced)\n",
1467
+ "\n",
1468
+ "\n",
1469
+ "#dataset = dataset.filter(lambda e: e['answer'] is not None and len(e['answer']) > 0)\n",
1470
+ "\n",
1471
+ "\n",
1472
+ "#dataset = dataset.map(lambda e: {'labels': label_encoder.transform([e['answer']])[0]}, batched=False) # Transform expects a list\n",
1473
+ "\n",
1474
+ "\n",
1475
+ "#model = BertForSequenceClassification.from_pretrained('bert-base-uncased', num_labels=len(label_encoder.classes_))\n",
1476
+ "\n",
1477
+ "\n",
1478
+ "#training_args = TrainingArguments(\n",
1479
+ " output_dir='./results',\n",
1480
+ " num_train_epochs=3,\n",
1481
+ " per_device_train_batch_size=8,\n",
1482
+ " per_device_eval_batch_size=16,\n",
1483
+ " warmup_steps=500,\n",
1484
+ " weight_decay=0.01,\n",
1485
+ " logging_dir='./logs',\n",
1486
+ ")\n",
1487
+ "\n",
1488
+ "trainer = Trainer(\n",
1489
+ " model=model,\n",
1490
+ " args=training_args,\n",
1491
+ " train_dataset=dataset,\n",
1492
+ " eval_dataset=dataset,\n",
1493
+ ")\n",
1494
+ "\n",
1495
+ "trainer.train()"
1496
+ ]
1497
+ },
1498
+ {
1499
+ "cell_type": "code",
1500
+ "execution_count": 41,
1501
+ "metadata": {
1502
+ "colab": {
1503
+ "base_uri": "https://localhost:8080/"
1504
+ },
1505
+ "id": "v8DE8aAzg4jQ",
1506
+ "outputId": "5ce78149-c53b-45f3-994f-5f6c7d21b819"
1507
+ },
1508
+ "outputs": [
1509
+ {
1510
+ "name": "stdout",
1511
+ "output_type": "stream",
1512
+ "text": [
1513
+ "Predicted Label: neutral\n"
1514
+ ]
1515
+ }
1516
+ ],
1517
+ "source": [
1518
+ "new_texts = [\"The company is doing OK\"]\n",
1519
+ "new_embeddings = model.encode(new_texts, convert_to_numpy=True)\n",
1520
+ "predicted_label = clf.predict(new_embeddings)\n",
1521
+ "\n",
1522
+ "# Convert back to original label names\n",
1523
+ "decoded_label = label_encoder.inverse_transform(predicted_label)\n",
1524
+ "print(\"Predicted Label:\", decoded_label[0])\n"
1525
+ ]
1526
+ }
1527
+ ],
1528
+ "metadata": {
1529
+ "colab": {
1530
+ "provenance": []
1531
+ },
1532
+ "kernelspec": {
1533
+ "display_name": "Python 3",
1534
+ "name": "python3"
1535
+ },
1536
+ "language_info": {
1537
+ "codemirror_mode": {
1538
+ "name": "ipython",
1539
+ "version": 3
1540
+ },
1541
+ "file_extension": ".py",
1542
+ "mimetype": "text/x-python",
1543
+ "name": "python",
1544
+ "nbconvert_exporter": "python",
1545
+ "pygments_lexer": "ipython3",
1546
+ "version": "3.12.2"
1547
+ }
1548
+ },
1549
+ "nbformat": 4,
1550
+ "nbformat_minor": 0
1551
+ }