Upload 10 files
Browse files- cds-detection-classification-full-pipeline (2).ipynb +0 -0
- cds-detection-classification-machine-learning.ipynb +0 -0
- cognitive-distortion-detection-deeplearning.ipynb +2674 -0
- data/distorted.csv +0 -0
- data/distorted_v2.csv +0 -0
- data/distortion.csv +0 -0
- data/distortion_processed.csv +0 -0
- distortion-MRC-extraction.ipynb +1 -0
- distortion-classification-deeplearning.ipynb +0 -0
- methods_output_compairision.ipynb +2278 -0
cds-detection-classification-full-pipeline (2).ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
cds-detection-classification-machine-learning.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
cognitive-distortion-detection-deeplearning.ipynb
ADDED
|
@@ -0,0 +1,2674 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": 1,
|
| 6 |
+
"id": "5bba7abb",
|
| 7 |
+
"metadata": {
|
| 8 |
+
"execution": {
|
| 9 |
+
"iopub.execute_input": "2025-09-29T03:52:15.252393Z",
|
| 10 |
+
"iopub.status.busy": "2025-09-29T03:52:15.252092Z",
|
| 11 |
+
"iopub.status.idle": "2025-09-29T03:52:17.151894Z",
|
| 12 |
+
"shell.execute_reply": "2025-09-29T03:52:17.150967Z"
|
| 13 |
+
},
|
| 14 |
+
"papermill": {
|
| 15 |
+
"duration": 1.90738,
|
| 16 |
+
"end_time": "2025-09-29T03:52:17.153646",
|
| 17 |
+
"exception": false,
|
| 18 |
+
"start_time": "2025-09-29T03:52:15.246266",
|
| 19 |
+
"status": "completed"
|
| 20 |
+
},
|
| 21 |
+
"tags": []
|
| 22 |
+
},
|
| 23 |
+
"outputs": [],
|
| 24 |
+
"source": [
|
| 25 |
+
"import numpy as np\n",
|
| 26 |
+
"import pandas as pd\n",
|
| 27 |
+
"import matplotlib.pyplot as plt \n",
|
| 28 |
+
"import seaborn as sns\n",
|
| 29 |
+
"import os, re, warnings\n",
|
| 30 |
+
"\n",
|
| 31 |
+
"warnings.filterwarnings('ignore')"
|
| 32 |
+
]
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"cell_type": "code",
|
| 36 |
+
"execution_count": 2,
|
| 37 |
+
"id": "9f73e599",
|
| 38 |
+
"metadata": {
|
| 39 |
+
"execution": {
|
| 40 |
+
"iopub.execute_input": "2025-09-29T03:52:17.163059Z",
|
| 41 |
+
"iopub.status.busy": "2025-09-29T03:52:17.162673Z",
|
| 42 |
+
"iopub.status.idle": "2025-09-29T03:52:17.251586Z",
|
| 43 |
+
"shell.execute_reply": "2025-09-29T03:52:17.250752Z"
|
| 44 |
+
},
|
| 45 |
+
"papermill": {
|
| 46 |
+
"duration": 0.094622,
|
| 47 |
+
"end_time": "2025-09-29T03:52:17.252914",
|
| 48 |
+
"exception": false,
|
| 49 |
+
"start_time": "2025-09-29T03:52:17.158292",
|
| 50 |
+
"status": "completed"
|
| 51 |
+
},
|
| 52 |
+
"tags": []
|
| 53 |
+
},
|
| 54 |
+
"outputs": [
|
| 55 |
+
{
|
| 56 |
+
"data": {
|
| 57 |
+
"text/html": [
|
| 58 |
+
"<div>\n",
|
| 59 |
+
"<style scoped>\n",
|
| 60 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 61 |
+
" vertical-align: middle;\n",
|
| 62 |
+
" }\n",
|
| 63 |
+
"\n",
|
| 64 |
+
" .dataframe tbody tr th {\n",
|
| 65 |
+
" vertical-align: top;\n",
|
| 66 |
+
" }\n",
|
| 67 |
+
"\n",
|
| 68 |
+
" .dataframe thead th {\n",
|
| 69 |
+
" text-align: right;\n",
|
| 70 |
+
" }\n",
|
| 71 |
+
"</style>\n",
|
| 72 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 73 |
+
" <thead>\n",
|
| 74 |
+
" <tr style=\"text-align: right;\">\n",
|
| 75 |
+
" <th></th>\n",
|
| 76 |
+
" <th>Id_Number</th>\n",
|
| 77 |
+
" <th>Patient Question</th>\n",
|
| 78 |
+
" <th>Distorted part</th>\n",
|
| 79 |
+
" <th>Dominant Distortion</th>\n",
|
| 80 |
+
" <th>Secondary Distortion (Optional)</th>\n",
|
| 81 |
+
" </tr>\n",
|
| 82 |
+
" </thead>\n",
|
| 83 |
+
" <tbody>\n",
|
| 84 |
+
" <tr>\n",
|
| 85 |
+
" <th>0</th>\n",
|
| 86 |
+
" <td>4500</td>\n",
|
| 87 |
+
" <td>Hello, I have a beautiful,smart,outgoing and a...</td>\n",
|
| 88 |
+
" <td>The voice are always fimilar (someone she know...</td>\n",
|
| 89 |
+
" <td>Personalization</td>\n",
|
| 90 |
+
" <td>NaN</td>\n",
|
| 91 |
+
" </tr>\n",
|
| 92 |
+
" <tr>\n",
|
| 93 |
+
" <th>1</th>\n",
|
| 94 |
+
" <td>4501</td>\n",
|
| 95 |
+
" <td>Since I was about 16 years old I’ve had these ...</td>\n",
|
| 96 |
+
" <td>I feel trapped inside my disgusting self and l...</td>\n",
|
| 97 |
+
" <td>Labeling</td>\n",
|
| 98 |
+
" <td>Emotional Reasoning</td>\n",
|
| 99 |
+
" </tr>\n",
|
| 100 |
+
" <tr>\n",
|
| 101 |
+
" <th>2</th>\n",
|
| 102 |
+
" <td>4502</td>\n",
|
| 103 |
+
" <td>So I’ve been dating on and off this guy for a...</td>\n",
|
| 104 |
+
" <td>NaN</td>\n",
|
| 105 |
+
" <td>No Distortion</td>\n",
|
| 106 |
+
" <td>NaN</td>\n",
|
| 107 |
+
" </tr>\n",
|
| 108 |
+
" <tr>\n",
|
| 109 |
+
" <th>3</th>\n",
|
| 110 |
+
" <td>4503</td>\n",
|
| 111 |
+
" <td>My parents got divorced in 2004. My mother has...</td>\n",
|
| 112 |
+
" <td>NaN</td>\n",
|
| 113 |
+
" <td>No Distortion</td>\n",
|
| 114 |
+
" <td>NaN</td>\n",
|
| 115 |
+
" </tr>\n",
|
| 116 |
+
" <tr>\n",
|
| 117 |
+
" <th>4</th>\n",
|
| 118 |
+
" <td>4504</td>\n",
|
| 119 |
+
" <td>I don’t really know how to explain the situati...</td>\n",
|
| 120 |
+
" <td>I refused to go because I didn’t know if it wa...</td>\n",
|
| 121 |
+
" <td>Fortune-telling</td>\n",
|
| 122 |
+
" <td>Emotional Reasoning</td>\n",
|
| 123 |
+
" </tr>\n",
|
| 124 |
+
" </tbody>\n",
|
| 125 |
+
"</table>\n",
|
| 126 |
+
"</div>"
|
| 127 |
+
],
|
| 128 |
+
"text/plain": [
|
| 129 |
+
" Id_Number Patient Question \\\n",
|
| 130 |
+
"0 4500 Hello, I have a beautiful,smart,outgoing and a... \n",
|
| 131 |
+
"1 4501 Since I was about 16 years old I’ve had these ... \n",
|
| 132 |
+
"2 4502 So I’ve been dating on and off this guy for a... \n",
|
| 133 |
+
"3 4503 My parents got divorced in 2004. My mother has... \n",
|
| 134 |
+
"4 4504 I don’t really know how to explain the situati... \n",
|
| 135 |
+
"\n",
|
| 136 |
+
" Distorted part Dominant Distortion \\\n",
|
| 137 |
+
"0 The voice are always fimilar (someone she know... Personalization \n",
|
| 138 |
+
"1 I feel trapped inside my disgusting self and l... Labeling \n",
|
| 139 |
+
"2 NaN No Distortion \n",
|
| 140 |
+
"3 NaN No Distortion \n",
|
| 141 |
+
"4 I refused to go because I didn’t know if it wa... Fortune-telling \n",
|
| 142 |
+
"\n",
|
| 143 |
+
" Secondary Distortion (Optional) \n",
|
| 144 |
+
"0 NaN \n",
|
| 145 |
+
"1 Emotional Reasoning \n",
|
| 146 |
+
"2 NaN \n",
|
| 147 |
+
"3 NaN \n",
|
| 148 |
+
"4 Emotional Reasoning "
|
| 149 |
+
]
|
| 150 |
+
},
|
| 151 |
+
"execution_count": 2,
|
| 152 |
+
"metadata": {},
|
| 153 |
+
"output_type": "execute_result"
|
| 154 |
+
}
|
| 155 |
+
],
|
| 156 |
+
"source": [
|
| 157 |
+
"df = pd.read_csv('/kaggle/input/cognitive-distortion-detetction-dataset/Annotated_data.csv')\n",
|
| 158 |
+
"df.head()"
|
| 159 |
+
]
|
| 160 |
+
},
|
| 161 |
+
{
|
| 162 |
+
"cell_type": "code",
|
| 163 |
+
"execution_count": 3,
|
| 164 |
+
"id": "4bdec7e0",
|
| 165 |
+
"metadata": {
|
| 166 |
+
"execution": {
|
| 167 |
+
"iopub.execute_input": "2025-09-29T03:52:17.262119Z",
|
| 168 |
+
"iopub.status.busy": "2025-09-29T03:52:17.261822Z",
|
| 169 |
+
"iopub.status.idle": "2025-09-29T03:52:17.264808Z",
|
| 170 |
+
"shell.execute_reply": "2025-09-29T03:52:17.264189Z"
|
| 171 |
+
},
|
| 172 |
+
"papermill": {
|
| 173 |
+
"duration": 0.00864,
|
| 174 |
+
"end_time": "2025-09-29T03:52:17.265921",
|
| 175 |
+
"exception": false,
|
| 176 |
+
"start_time": "2025-09-29T03:52:17.257281",
|
| 177 |
+
"status": "completed"
|
| 178 |
+
},
|
| 179 |
+
"tags": []
|
| 180 |
+
},
|
| 181 |
+
"outputs": [],
|
| 182 |
+
"source": [
|
| 183 |
+
"# df=df.dropna()"
|
| 184 |
+
]
|
| 185 |
+
},
|
| 186 |
+
{
|
| 187 |
+
"cell_type": "code",
|
| 188 |
+
"execution_count": 4,
|
| 189 |
+
"id": "49316246",
|
| 190 |
+
"metadata": {
|
| 191 |
+
"execution": {
|
| 192 |
+
"iopub.execute_input": "2025-09-29T03:52:17.274826Z",
|
| 193 |
+
"iopub.status.busy": "2025-09-29T03:52:17.274598Z",
|
| 194 |
+
"iopub.status.idle": "2025-09-29T03:52:17.277625Z",
|
| 195 |
+
"shell.execute_reply": "2025-09-29T03:52:17.276818Z"
|
| 196 |
+
},
|
| 197 |
+
"papermill": {
|
| 198 |
+
"duration": 0.009205,
|
| 199 |
+
"end_time": "2025-09-29T03:52:17.279273",
|
| 200 |
+
"exception": false,
|
| 201 |
+
"start_time": "2025-09-29T03:52:17.270068",
|
| 202 |
+
"status": "completed"
|
| 203 |
+
},
|
| 204 |
+
"tags": []
|
| 205 |
+
},
|
| 206 |
+
"outputs": [],
|
| 207 |
+
"source": [
|
| 208 |
+
"# lengths = df['Distorted part'].apply(lambda x: len(x.split()))\n",
|
| 209 |
+
"\n",
|
| 210 |
+
"# plt.figure(figsize=(10, 5))\n",
|
| 211 |
+
"# plt.hist(lengths, bins=30, edgecolor='k', alpha=0.7)\n",
|
| 212 |
+
"# plt.title('Distribution of sentence lengths')\n",
|
| 213 |
+
"# plt.xlabel('Sentence Length')\n",
|
| 214 |
+
"# plt.ylabel('Number of Sentences')\n",
|
| 215 |
+
"# plt.grid(True, which='both', linestyle='--', linewidth=0.5)\n",
|
| 216 |
+
"# plt.show()"
|
| 217 |
+
]
|
| 218 |
+
},
|
| 219 |
+
{
|
| 220 |
+
"cell_type": "code",
|
| 221 |
+
"execution_count": 5,
|
| 222 |
+
"id": "872f92ef",
|
| 223 |
+
"metadata": {
|
| 224 |
+
"execution": {
|
| 225 |
+
"iopub.execute_input": "2025-09-29T03:52:17.287846Z",
|
| 226 |
+
"iopub.status.busy": "2025-09-29T03:52:17.287596Z",
|
| 227 |
+
"iopub.status.idle": "2025-09-29T03:52:17.404691Z",
|
| 228 |
+
"shell.execute_reply": "2025-09-29T03:52:17.403977Z"
|
| 229 |
+
},
|
| 230 |
+
"papermill": {
|
| 231 |
+
"duration": 0.123138,
|
| 232 |
+
"end_time": "2025-09-29T03:52:17.406334",
|
| 233 |
+
"exception": false,
|
| 234 |
+
"start_time": "2025-09-29T03:52:17.283196",
|
| 235 |
+
"status": "completed"
|
| 236 |
+
},
|
| 237 |
+
"tags": []
|
| 238 |
+
},
|
| 239 |
+
"outputs": [],
|
| 240 |
+
"source": [
|
| 241 |
+
"from sklearn.preprocessing import LabelEncoder\n",
|
| 242 |
+
"# Tạo LabelEncoder\n",
|
| 243 |
+
"encoder = LabelEncoder()\n",
|
| 244 |
+
"\n",
|
| 245 |
+
"# Mã hóa cột 'Dominant Distortion', 'No Distortion' thành 0, các loại còn lại thành 1\n",
|
| 246 |
+
"df['Dominant Distortion Encoded'] = encoder.fit_transform(df['Dominant Distortion'].apply(lambda x: 0 if x == 'No Distortion' else 1))"
|
| 247 |
+
]
|
| 248 |
+
},
|
| 249 |
+
{
|
| 250 |
+
"cell_type": "code",
|
| 251 |
+
"execution_count": 6,
|
| 252 |
+
"id": "d0c55440",
|
| 253 |
+
"metadata": {
|
| 254 |
+
"execution": {
|
| 255 |
+
"iopub.execute_input": "2025-09-29T03:52:17.415784Z",
|
| 256 |
+
"iopub.status.busy": "2025-09-29T03:52:17.415525Z",
|
| 257 |
+
"iopub.status.idle": "2025-09-29T03:52:18.256425Z",
|
| 258 |
+
"shell.execute_reply": "2025-09-29T03:52:18.255403Z"
|
| 259 |
+
},
|
| 260 |
+
"papermill": {
|
| 261 |
+
"duration": 0.84688,
|
| 262 |
+
"end_time": "2025-09-29T03:52:18.257776",
|
| 263 |
+
"exception": false,
|
| 264 |
+
"start_time": "2025-09-29T03:52:17.410896",
|
| 265 |
+
"status": "completed"
|
| 266 |
+
},
|
| 267 |
+
"tags": []
|
| 268 |
+
},
|
| 269 |
+
"outputs": [
|
| 270 |
+
{
|
| 271 |
+
"name": "stdout",
|
| 272 |
+
"output_type": "stream",
|
| 273 |
+
"text": [
|
| 274 |
+
"[nltk_data] Downloading package punkt to /usr/share/nltk_data...\n",
|
| 275 |
+
"[nltk_data] Package punkt is already up-to-date!\n",
|
| 276 |
+
"[nltk_data] Downloading package stopwords to /usr/share/nltk_data...\n",
|
| 277 |
+
"[nltk_data] Unzipping corpora/stopwords.zip.\n",
|
| 278 |
+
"[nltk_data] Downloading package wordnet to /usr/share/nltk_data...\n",
|
| 279 |
+
"[nltk_data] Package wordnet is already up-to-date!\n",
|
| 280 |
+
"i luv programmng u r gr8 i cant believe its 123 times better\n"
|
| 281 |
+
]
|
| 282 |
+
}
|
| 283 |
+
],
|
| 284 |
+
"source": [
|
| 285 |
+
"# !pip install spellchecker\n",
|
| 286 |
+
"import re\n",
|
| 287 |
+
"import string\n",
|
| 288 |
+
"import nltk\n",
|
| 289 |
+
"from nltk.tokenize import word_tokenize\n",
|
| 290 |
+
"from nltk.corpus import stopwords\n",
|
| 291 |
+
"from nltk.stem import PorterStemmer, WordNetLemmatizer\n",
|
| 292 |
+
"# from spellchecker import SpellChecker\n",
|
| 293 |
+
"\n",
|
| 294 |
+
"# Tải các tài nguyên cần thiết\n",
|
| 295 |
+
"nltk.download(\"punkt\")\n",
|
| 296 |
+
"nltk.download(\"stopwords\")\n",
|
| 297 |
+
"nltk.download(\"wordnet\")\n",
|
| 298 |
+
"\n",
|
| 299 |
+
"# Khởi tạo các công cụ\n",
|
| 300 |
+
"stemmer = PorterStemmer()\n",
|
| 301 |
+
"lemmatizer = WordNetLemmatizer()\n",
|
| 302 |
+
"# spell = SpellChecker()\n",
|
| 303 |
+
"stop_words = set(stopwords.words(\"english\"))\n",
|
| 304 |
+
"\n",
|
| 305 |
+
"def preprocess_text(text, use_stemming=False, use_lemmatization=True, correct_spelling=False):\n",
|
| 306 |
+
" text = text.lower()\n",
|
| 307 |
+
" \n",
|
| 308 |
+
" text = text.translate(str.maketrans(\"\", \"\", string.punctuation))\n",
|
| 309 |
+
" \n",
|
| 310 |
+
" # tokens = word_tokenize(text)\n",
|
| 311 |
+
" \n",
|
| 312 |
+
" # tokens = [word for word in tokens if word not in stop_words]\n",
|
| 313 |
+
" \n",
|
| 314 |
+
" # if use_stemming:\n",
|
| 315 |
+
" # tokens = [stemmer.stem(word) for word in tokens]\n",
|
| 316 |
+
" # elif use_lemmatization:\n",
|
| 317 |
+
" # tokens = [lemmatizer.lemmatize(word) for word in tokens]\n",
|
| 318 |
+
" \n",
|
| 319 |
+
" # 7. Xóa khoảng trắng dư thừa (không cần vì token đã tách sẵn)\n",
|
| 320 |
+
" \n",
|
| 321 |
+
" # 8. Chuyển đổi số thành \"NUM\"\n",
|
| 322 |
+
" # tokens = [\"NUM\" if word.isdigit() else word for word in tokens]\n",
|
| 323 |
+
" \n",
|
| 324 |
+
" # 9. Xử lý lỗi chính tả\n",
|
| 325 |
+
" # if correct_spelling:\n",
|
| 326 |
+
" # tokens = [spell.correction(word) if word not in spell else word for word in tokens]\n",
|
| 327 |
+
" \n",
|
| 328 |
+
" return text#\" \".join(text)\n",
|
| 329 |
+
"\n",
|
| 330 |
+
"# Ví dụ sử dụng\n",
|
| 331 |
+
"text = \"I luv programmng! U r gr8. I can't believe it's 123 times better!\"\n",
|
| 332 |
+
"processed_text = preprocess_text(text)\n",
|
| 333 |
+
"print(processed_text)\n"
|
| 334 |
+
]
|
| 335 |
+
},
|
| 336 |
+
{
|
| 337 |
+
"cell_type": "code",
|
| 338 |
+
"execution_count": 7,
|
| 339 |
+
"id": "d232a9ba",
|
| 340 |
+
"metadata": {
|
| 341 |
+
"execution": {
|
| 342 |
+
"iopub.execute_input": "2025-09-29T03:52:18.267764Z",
|
| 343 |
+
"iopub.status.busy": "2025-09-29T03:52:18.267488Z",
|
| 344 |
+
"iopub.status.idle": "2025-09-29T03:52:18.451213Z",
|
| 345 |
+
"shell.execute_reply": "2025-09-29T03:52:18.450248Z"
|
| 346 |
+
},
|
| 347 |
+
"papermill": {
|
| 348 |
+
"duration": 0.190457,
|
| 349 |
+
"end_time": "2025-09-29T03:52:18.452821",
|
| 350 |
+
"exception": false,
|
| 351 |
+
"start_time": "2025-09-29T03:52:18.262364",
|
| 352 |
+
"status": "completed"
|
| 353 |
+
},
|
| 354 |
+
"tags": []
|
| 355 |
+
},
|
| 356 |
+
"outputs": [],
|
| 357 |
+
"source": [
|
| 358 |
+
"df['cleaned'] = df['Patient Question'].map(lambda text: preprocess_text(text))"
|
| 359 |
+
]
|
| 360 |
+
},
|
| 361 |
+
{
|
| 362 |
+
"cell_type": "code",
|
| 363 |
+
"execution_count": 8,
|
| 364 |
+
"id": "0e75019a",
|
| 365 |
+
"metadata": {
|
| 366 |
+
"execution": {
|
| 367 |
+
"iopub.execute_input": "2025-09-29T03:52:18.463419Z",
|
| 368 |
+
"iopub.status.busy": "2025-09-29T03:52:18.463120Z",
|
| 369 |
+
"iopub.status.idle": "2025-09-29T03:52:18.466631Z",
|
| 370 |
+
"shell.execute_reply": "2025-09-29T03:52:18.465966Z"
|
| 371 |
+
},
|
| 372 |
+
"papermill": {
|
| 373 |
+
"duration": 0.009927,
|
| 374 |
+
"end_time": "2025-09-29T03:52:18.467830",
|
| 375 |
+
"exception": false,
|
| 376 |
+
"start_time": "2025-09-29T03:52:18.457903",
|
| 377 |
+
"status": "completed"
|
| 378 |
+
},
|
| 379 |
+
"tags": []
|
| 380 |
+
},
|
| 381 |
+
"outputs": [],
|
| 382 |
+
"source": [
|
| 383 |
+
"# from collections import Counter\n",
|
| 384 |
+
"\n",
|
| 385 |
+
"# def create_corpus():\n",
|
| 386 |
+
"# corpus = []\n",
|
| 387 |
+
"# for x in df['cleaned'].str.split():\n",
|
| 388 |
+
"# for i in x:\n",
|
| 389 |
+
"# corpus.append(i)\n",
|
| 390 |
+
"# return corpus\n",
|
| 391 |
+
"\n",
|
| 392 |
+
"# corpus = create_corpus()\n",
|
| 393 |
+
"\n",
|
| 394 |
+
"# counter = Counter(corpus)\n",
|
| 395 |
+
"# most_common_words = counter.most_common(40)\n",
|
| 396 |
+
"\n",
|
| 397 |
+
"# x = []\n",
|
| 398 |
+
"# y = []\n",
|
| 399 |
+
"# for word, count in most_common_words:\n",
|
| 400 |
+
"# x.append(word)\n",
|
| 401 |
+
"# y.append(count)\n",
|
| 402 |
+
"\n",
|
| 403 |
+
"# plt.figure(figsize=(10, 8))\n",
|
| 404 |
+
"# sns.barplot(x=y, y=x, palette='viridis')\n",
|
| 405 |
+
"# plt.xlabel('Count')\n",
|
| 406 |
+
"# plt.ylabel('Words')\n",
|
| 407 |
+
"# plt.title('Top 40 Most Common Words in review')\n",
|
| 408 |
+
"# plt.show()"
|
| 409 |
+
]
|
| 410 |
+
},
|
| 411 |
+
{
|
| 412 |
+
"cell_type": "code",
|
| 413 |
+
"execution_count": 9,
|
| 414 |
+
"id": "a6d0e1ec",
|
| 415 |
+
"metadata": {
|
| 416 |
+
"execution": {
|
| 417 |
+
"iopub.execute_input": "2025-09-29T03:52:18.476634Z",
|
| 418 |
+
"iopub.status.busy": "2025-09-29T03:52:18.476371Z",
|
| 419 |
+
"iopub.status.idle": "2025-09-29T03:52:18.479532Z",
|
| 420 |
+
"shell.execute_reply": "2025-09-29T03:52:18.478900Z"
|
| 421 |
+
},
|
| 422 |
+
"papermill": {
|
| 423 |
+
"duration": 0.008762,
|
| 424 |
+
"end_time": "2025-09-29T03:52:18.480677",
|
| 425 |
+
"exception": false,
|
| 426 |
+
"start_time": "2025-09-29T03:52:18.471915",
|
| 427 |
+
"status": "completed"
|
| 428 |
+
},
|
| 429 |
+
"tags": []
|
| 430 |
+
},
|
| 431 |
+
"outputs": [],
|
| 432 |
+
"source": [
|
| 433 |
+
"# from wordcloud import WordCloud\n",
|
| 434 |
+
"# import matplotlib.pyplot as plt\n",
|
| 435 |
+
"# import numpy as np\n",
|
| 436 |
+
"# from PIL import Image, ImageOps\n",
|
| 437 |
+
"\n",
|
| 438 |
+
"# text = ' '.join(df['cleaned'])\n",
|
| 439 |
+
"\n",
|
| 440 |
+
"# mask_img = Image.open('/kaggle/input/butter-mask/c26289174f9d2ee80a9bc60455257030.png').convert(\"L\") \n",
|
| 441 |
+
"# mask_img_inverted = ImageOps.invert(mask_img) \n",
|
| 442 |
+
"\n",
|
| 443 |
+
"# mask = np.array(mask_img_inverted)\n",
|
| 444 |
+
"# mask[mask == 255] = 0\n",
|
| 445 |
+
"# mask[mask == 158] = 255\n",
|
| 446 |
+
"\n",
|
| 447 |
+
"# wordcloud = WordCloud(background_color='white',\n",
|
| 448 |
+
"# max_words=2000,\n",
|
| 449 |
+
"# mask=mask,\n",
|
| 450 |
+
"# contour_width=3,\n",
|
| 451 |
+
"# contour_color='white',\n",
|
| 452 |
+
"# colormap='viridis').generate(text)\n",
|
| 453 |
+
"\n",
|
| 454 |
+
"# # Hiển thị\n",
|
| 455 |
+
"# plt.figure(figsize=(10, 10))\n",
|
| 456 |
+
"# plt.imshow(wordcloud, interpolation='bilinear')\n",
|
| 457 |
+
"# plt.axis('off')\n",
|
| 458 |
+
"# plt.show()\n",
|
| 459 |
+
"\n"
|
| 460 |
+
]
|
| 461 |
+
},
|
| 462 |
+
{
|
| 463 |
+
"cell_type": "code",
|
| 464 |
+
"execution_count": 10,
|
| 465 |
+
"id": "cd48ecdc",
|
| 466 |
+
"metadata": {
|
| 467 |
+
"execution": {
|
| 468 |
+
"iopub.execute_input": "2025-09-29T03:52:18.489624Z",
|
| 469 |
+
"iopub.status.busy": "2025-09-29T03:52:18.489357Z",
|
| 470 |
+
"iopub.status.idle": "2025-09-29T03:52:18.494641Z",
|
| 471 |
+
"shell.execute_reply": "2025-09-29T03:52:18.493650Z"
|
| 472 |
+
},
|
| 473 |
+
"papermill": {
|
| 474 |
+
"duration": 0.011092,
|
| 475 |
+
"end_time": "2025-09-29T03:52:18.495952",
|
| 476 |
+
"exception": false,
|
| 477 |
+
"start_time": "2025-09-29T03:52:18.484860",
|
| 478 |
+
"status": "completed"
|
| 479 |
+
},
|
| 480 |
+
"tags": []
|
| 481 |
+
},
|
| 482 |
+
"outputs": [],
|
| 483 |
+
"source": [
|
| 484 |
+
"from sklearn.model_selection import train_test_split\n",
|
| 485 |
+
"\n",
|
| 486 |
+
"X_train, X_test, y_train, y_test = train_test_split(df['Patient Question'].values,\n",
|
| 487 |
+
" df['Dominant Distortion Encoded'].values,\n",
|
| 488 |
+
" test_size=0.2, random_state=42)"
|
| 489 |
+
]
|
| 490 |
+
},
|
| 491 |
+
{
|
| 492 |
+
"cell_type": "code",
|
| 493 |
+
"execution_count": 11,
|
| 494 |
+
"id": "a5c6c9cd",
|
| 495 |
+
"metadata": {
|
| 496 |
+
"execution": {
|
| 497 |
+
"iopub.execute_input": "2025-09-29T03:52:18.504805Z",
|
| 498 |
+
"iopub.status.busy": "2025-09-29T03:52:18.504562Z",
|
| 499 |
+
"iopub.status.idle": "2025-09-29T03:52:18.509148Z",
|
| 500 |
+
"shell.execute_reply": "2025-09-29T03:52:18.508343Z"
|
| 501 |
+
},
|
| 502 |
+
"papermill": {
|
| 503 |
+
"duration": 0.010425,
|
| 504 |
+
"end_time": "2025-09-29T03:52:18.510499",
|
| 505 |
+
"exception": false,
|
| 506 |
+
"start_time": "2025-09-29T03:52:18.500074",
|
| 507 |
+
"status": "completed"
|
| 508 |
+
},
|
| 509 |
+
"tags": []
|
| 510 |
+
},
|
| 511 |
+
"outputs": [
|
| 512 |
+
{
|
| 513 |
+
"data": {
|
| 514 |
+
"text/plain": [
|
| 515 |
+
"array([1, 1, 1, ..., 1, 0, 0])"
|
| 516 |
+
]
|
| 517 |
+
},
|
| 518 |
+
"execution_count": 11,
|
| 519 |
+
"metadata": {},
|
| 520 |
+
"output_type": "execute_result"
|
| 521 |
+
}
|
| 522 |
+
],
|
| 523 |
+
"source": [
|
| 524 |
+
"y_train"
|
| 525 |
+
]
|
| 526 |
+
},
|
| 527 |
+
{
|
| 528 |
+
"cell_type": "code",
|
| 529 |
+
"execution_count": 12,
|
| 530 |
+
"id": "ca64a24f",
|
| 531 |
+
"metadata": {
|
| 532 |
+
"execution": {
|
| 533 |
+
"iopub.execute_input": "2025-09-29T03:52:18.519582Z",
|
| 534 |
+
"iopub.status.busy": "2025-09-29T03:52:18.519345Z",
|
| 535 |
+
"iopub.status.idle": "2025-09-29T03:52:38.984259Z",
|
| 536 |
+
"shell.execute_reply": "2025-09-29T03:52:38.983492Z"
|
| 537 |
+
},
|
| 538 |
+
"papermill": {
|
| 539 |
+
"duration": 20.471052,
|
| 540 |
+
"end_time": "2025-09-29T03:52:38.985827",
|
| 541 |
+
"exception": false,
|
| 542 |
+
"start_time": "2025-09-29T03:52:18.514775",
|
| 543 |
+
"status": "completed"
|
| 544 |
+
},
|
| 545 |
+
"tags": []
|
| 546 |
+
},
|
| 547 |
+
"outputs": [],
|
| 548 |
+
"source": [
|
| 549 |
+
"import torch\n",
|
| 550 |
+
"from torch.optim import AdamW # ✅ Sửa tại đây\n",
|
| 551 |
+
"from torch.utils.data import Dataset, DataLoader\n",
|
| 552 |
+
"from transformers import RobertaTokenizer, RobertaForSequenceClassification\n",
|
| 553 |
+
"from sklearn.model_selection import train_test_split\n",
|
| 554 |
+
"from sklearn.metrics import accuracy_score\n",
|
| 555 |
+
"from transformers import AutoTokenizer, AutoModel"
|
| 556 |
+
]
|
| 557 |
+
},
|
| 558 |
+
{
|
| 559 |
+
"cell_type": "code",
|
| 560 |
+
"execution_count": 13,
|
| 561 |
+
"id": "7623d594",
|
| 562 |
+
"metadata": {
|
| 563 |
+
"execution": {
|
| 564 |
+
"iopub.execute_input": "2025-09-29T03:52:38.995659Z",
|
| 565 |
+
"iopub.status.busy": "2025-09-29T03:52:38.995122Z",
|
| 566 |
+
"iopub.status.idle": "2025-09-29T03:52:38.999547Z",
|
| 567 |
+
"shell.execute_reply": "2025-09-29T03:52:38.998744Z"
|
| 568 |
+
},
|
| 569 |
+
"papermill": {
|
| 570 |
+
"duration": 0.010439,
|
| 571 |
+
"end_time": "2025-09-29T03:52:39.000804",
|
| 572 |
+
"exception": false,
|
| 573 |
+
"start_time": "2025-09-29T03:52:38.990365",
|
| 574 |
+
"status": "completed"
|
| 575 |
+
},
|
| 576 |
+
"tags": []
|
| 577 |
+
},
|
| 578 |
+
"outputs": [
|
| 579 |
+
{
|
| 580 |
+
"name": "stdout",
|
| 581 |
+
"output_type": "stream",
|
| 582 |
+
"text": [
|
| 583 |
+
"4.47.0\n"
|
| 584 |
+
]
|
| 585 |
+
}
|
| 586 |
+
],
|
| 587 |
+
"source": [
|
| 588 |
+
"import transformers\n",
|
| 589 |
+
"\n",
|
| 590 |
+
"print(transformers.__version__)"
|
| 591 |
+
]
|
| 592 |
+
},
|
| 593 |
+
{
|
| 594 |
+
"cell_type": "code",
|
| 595 |
+
"execution_count": 14,
|
| 596 |
+
"id": "c06d0ef3",
|
| 597 |
+
"metadata": {
|
| 598 |
+
"execution": {
|
| 599 |
+
"iopub.execute_input": "2025-09-29T03:52:39.010246Z",
|
| 600 |
+
"iopub.status.busy": "2025-09-29T03:52:39.009943Z",
|
| 601 |
+
"iopub.status.idle": "2025-09-29T03:52:40.957564Z",
|
| 602 |
+
"shell.execute_reply": "2025-09-29T03:52:40.956570Z"
|
| 603 |
+
},
|
| 604 |
+
"papermill": {
|
| 605 |
+
"duration": 1.954124,
|
| 606 |
+
"end_time": "2025-09-29T03:52:40.959317",
|
| 607 |
+
"exception": false,
|
| 608 |
+
"start_time": "2025-09-29T03:52:39.005193",
|
| 609 |
+
"status": "completed"
|
| 610 |
+
},
|
| 611 |
+
"tags": []
|
| 612 |
+
},
|
| 613 |
+
"outputs": [
|
| 614 |
+
{
|
| 615 |
+
"data": {
|
| 616 |
+
"application/vnd.jupyter.widget-view+json": {
|
| 617 |
+
"model_id": "81d6d531b8bf46208b1dbf3a07b3da7b",
|
| 618 |
+
"version_major": 2,
|
| 619 |
+
"version_minor": 0
|
| 620 |
+
},
|
| 621 |
+
"text/plain": [
|
| 622 |
+
"tokenizer_config.json: 0%| | 0.00/52.0 [00:00<?, ?B/s]"
|
| 623 |
+
]
|
| 624 |
+
},
|
| 625 |
+
"metadata": {},
|
| 626 |
+
"output_type": "display_data"
|
| 627 |
+
},
|
| 628 |
+
{
|
| 629 |
+
"data": {
|
| 630 |
+
"application/vnd.jupyter.widget-view+json": {
|
| 631 |
+
"model_id": "95dc73ea287e4f65b5b9c2184828b60a",
|
| 632 |
+
"version_major": 2,
|
| 633 |
+
"version_minor": 0
|
| 634 |
+
},
|
| 635 |
+
"text/plain": [
|
| 636 |
+
"config.json: 0%| | 0.00/580 [00:00<?, ?B/s]"
|
| 637 |
+
]
|
| 638 |
+
},
|
| 639 |
+
"metadata": {},
|
| 640 |
+
"output_type": "display_data"
|
| 641 |
+
},
|
| 642 |
+
{
|
| 643 |
+
"data": {
|
| 644 |
+
"application/vnd.jupyter.widget-view+json": {
|
| 645 |
+
"model_id": "5e7dde90a5554fbba23248a6df60976d",
|
| 646 |
+
"version_major": 2,
|
| 647 |
+
"version_minor": 0
|
| 648 |
+
},
|
| 649 |
+
"text/plain": [
|
| 650 |
+
"spm.model: 0%| | 0.00/2.46M [00:00<?, ?B/s]"
|
| 651 |
+
]
|
| 652 |
+
},
|
| 653 |
+
"metadata": {},
|
| 654 |
+
"output_type": "display_data"
|
| 655 |
+
}
|
| 656 |
+
],
|
| 657 |
+
"source": [
|
| 658 |
+
"from transformers import AutoTokenizer, AutoModelForSequenceClassification\n",
|
| 659 |
+
"from transformers import RobertaTokenizer, RobertaForSequenceClassification\n",
|
| 660 |
+
"\n",
|
| 661 |
+
"# tokenizer = RobertaTokenizer.from_pretrained('roberta-large')\n",
|
| 662 |
+
"tokenizer = AutoTokenizer.from_pretrained('microsoft/deberta-v3-large')\n",
|
| 663 |
+
"\n",
|
| 664 |
+
"class TextDataset(Dataset):\n",
|
| 665 |
+
" def __init__(self, texts, labels, tokenizer, max_len=512):\n",
|
| 666 |
+
" self.texts = texts\n",
|
| 667 |
+
" self.labels = labels\n",
|
| 668 |
+
" self.tokenizer = tokenizer\n",
|
| 669 |
+
" self.max_len = max_len\n",
|
| 670 |
+
"\n",
|
| 671 |
+
" def __len__(self):\n",
|
| 672 |
+
" return len(self.texts)\n",
|
| 673 |
+
"\n",
|
| 674 |
+
" def __getitem__(self, idx):\n",
|
| 675 |
+
" encoding = self.tokenizer(\n",
|
| 676 |
+
" self.texts[idx],\n",
|
| 677 |
+
" truncation=True,\n",
|
| 678 |
+
" padding='max_length',\n",
|
| 679 |
+
" max_length=self.max_len,\n",
|
| 680 |
+
" return_tensors='pt'\n",
|
| 681 |
+
" )\n",
|
| 682 |
+
" item = {key: val.squeeze(0) for key, val in encoding.items()}\n",
|
| 683 |
+
" item['labels'] = torch.tensor(self.labels[idx], dtype=torch.long)\n",
|
| 684 |
+
" return item"
|
| 685 |
+
]
|
| 686 |
+
},
|
| 687 |
+
{
|
| 688 |
+
"cell_type": "code",
|
| 689 |
+
"execution_count": 15,
|
| 690 |
+
"id": "b3a23bed",
|
| 691 |
+
"metadata": {
|
| 692 |
+
"execution": {
|
| 693 |
+
"iopub.execute_input": "2025-09-29T03:52:40.969720Z",
|
| 694 |
+
"iopub.status.busy": "2025-09-29T03:52:40.969452Z",
|
| 695 |
+
"iopub.status.idle": "2025-09-29T03:52:40.973769Z",
|
| 696 |
+
"shell.execute_reply": "2025-09-29T03:52:40.972885Z"
|
| 697 |
+
},
|
| 698 |
+
"papermill": {
|
| 699 |
+
"duration": 0.010896,
|
| 700 |
+
"end_time": "2025-09-29T03:52:40.975148",
|
| 701 |
+
"exception": false,
|
| 702 |
+
"start_time": "2025-09-29T03:52:40.964252",
|
| 703 |
+
"status": "completed"
|
| 704 |
+
},
|
| 705 |
+
"tags": []
|
| 706 |
+
},
|
| 707 |
+
"outputs": [],
|
| 708 |
+
"source": [
|
| 709 |
+
"train_dataset = TextDataset(X_train, y_train, tokenizer)\n",
|
| 710 |
+
"test_dataset = TextDataset(X_test, y_test, tokenizer)\n",
|
| 711 |
+
"\n",
|
| 712 |
+
"train_loader = DataLoader(train_dataset, batch_size=2, shuffle=True)\n",
|
| 713 |
+
"test_loader = DataLoader(test_dataset, batch_size=2)"
|
| 714 |
+
]
|
| 715 |
+
},
|
| 716 |
+
{
|
| 717 |
+
"cell_type": "code",
|
| 718 |
+
"execution_count": 16,
|
| 719 |
+
"id": "5d8efc44",
|
| 720 |
+
"metadata": {
|
| 721 |
+
"execution": {
|
| 722 |
+
"iopub.execute_input": "2025-09-29T03:52:40.985643Z",
|
| 723 |
+
"iopub.status.busy": "2025-09-29T03:52:40.985391Z",
|
| 724 |
+
"iopub.status.idle": "2025-09-29T03:52:46.716501Z",
|
| 725 |
+
"shell.execute_reply": "2025-09-29T03:52:46.715103Z"
|
| 726 |
+
},
|
| 727 |
+
"papermill": {
|
| 728 |
+
"duration": 5.738345,
|
| 729 |
+
"end_time": "2025-09-29T03:52:46.718089",
|
| 730 |
+
"exception": false,
|
| 731 |
+
"start_time": "2025-09-29T03:52:40.979744",
|
| 732 |
+
"status": "completed"
|
| 733 |
+
},
|
| 734 |
+
"tags": []
|
| 735 |
+
},
|
| 736 |
+
"outputs": [
|
| 737 |
+
{
|
| 738 |
+
"data": {
|
| 739 |
+
"application/vnd.jupyter.widget-view+json": {
|
| 740 |
+
"model_id": "6fecc138b4f54f5b97d0b04442b6711a",
|
| 741 |
+
"version_major": 2,
|
| 742 |
+
"version_minor": 0
|
| 743 |
+
},
|
| 744 |
+
"text/plain": [
|
| 745 |
+
"pytorch_model.bin: 0%| | 0.00/874M [00:00<?, ?B/s]"
|
| 746 |
+
]
|
| 747 |
+
},
|
| 748 |
+
"metadata": {},
|
| 749 |
+
"output_type": "display_data"
|
| 750 |
+
},
|
| 751 |
+
{
|
| 752 |
+
"name": "stderr",
|
| 753 |
+
"output_type": "stream",
|
| 754 |
+
"text": [
|
| 755 |
+
"Some weights of DebertaV2ForSequenceClassification were not initialized from the model checkpoint at microsoft/deberta-v3-large and are newly initialized: ['classifier.bias', 'classifier.weight', 'pooler.dense.bias', 'pooler.dense.weight']\n",
|
| 756 |
+
"You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.\n"
|
| 757 |
+
]
|
| 758 |
+
},
|
| 759 |
+
{
|
| 760 |
+
"data": {
|
| 761 |
+
"text/plain": [
|
| 762 |
+
"DebertaV2ForSequenceClassification(\n",
|
| 763 |
+
" (deberta): DebertaV2Model(\n",
|
| 764 |
+
" (embeddings): DebertaV2Embeddings(\n",
|
| 765 |
+
" (word_embeddings): Embedding(128100, 1024, padding_idx=0)\n",
|
| 766 |
+
" (LayerNorm): LayerNorm((1024,), eps=1e-07, elementwise_affine=True)\n",
|
| 767 |
+
" (dropout): Dropout(p=0.1, inplace=False)\n",
|
| 768 |
+
" )\n",
|
| 769 |
+
" (encoder): DebertaV2Encoder(\n",
|
| 770 |
+
" (layer): ModuleList(\n",
|
| 771 |
+
" (0-23): 24 x DebertaV2Layer(\n",
|
| 772 |
+
" (attention): DebertaV2Attention(\n",
|
| 773 |
+
" (self): DisentangledSelfAttention(\n",
|
| 774 |
+
" (query_proj): Linear(in_features=1024, out_features=1024, bias=True)\n",
|
| 775 |
+
" (key_proj): Linear(in_features=1024, out_features=1024, bias=True)\n",
|
| 776 |
+
" (value_proj): Linear(in_features=1024, out_features=1024, bias=True)\n",
|
| 777 |
+
" (pos_dropout): Dropout(p=0.1, inplace=False)\n",
|
| 778 |
+
" (dropout): Dropout(p=0.1, inplace=False)\n",
|
| 779 |
+
" )\n",
|
| 780 |
+
" (output): DebertaV2SelfOutput(\n",
|
| 781 |
+
" (dense): Linear(in_features=1024, out_features=1024, bias=True)\n",
|
| 782 |
+
" (LayerNorm): LayerNorm((1024,), eps=1e-07, elementwise_affine=True)\n",
|
| 783 |
+
" (dropout): Dropout(p=0.1, inplace=False)\n",
|
| 784 |
+
" )\n",
|
| 785 |
+
" )\n",
|
| 786 |
+
" (intermediate): DebertaV2Intermediate(\n",
|
| 787 |
+
" (dense): Linear(in_features=1024, out_features=4096, bias=True)\n",
|
| 788 |
+
" (intermediate_act_fn): GELUActivation()\n",
|
| 789 |
+
" )\n",
|
| 790 |
+
" (output): DebertaV2Output(\n",
|
| 791 |
+
" (dense): Linear(in_features=4096, out_features=1024, bias=True)\n",
|
| 792 |
+
" (LayerNorm): LayerNorm((1024,), eps=1e-07, elementwise_affine=True)\n",
|
| 793 |
+
" (dropout): Dropout(p=0.1, inplace=False)\n",
|
| 794 |
+
" )\n",
|
| 795 |
+
" )\n",
|
| 796 |
+
" )\n",
|
| 797 |
+
" (rel_embeddings): Embedding(512, 1024)\n",
|
| 798 |
+
" (LayerNorm): LayerNorm((1024,), eps=1e-07, elementwise_affine=True)\n",
|
| 799 |
+
" )\n",
|
| 800 |
+
" )\n",
|
| 801 |
+
" (pooler): ContextPooler(\n",
|
| 802 |
+
" (dense): Linear(in_features=1024, out_features=1024, bias=True)\n",
|
| 803 |
+
" (dropout): Dropout(p=0, inplace=False)\n",
|
| 804 |
+
" )\n",
|
| 805 |
+
" (classifier): Linear(in_features=1024, out_features=2, bias=True)\n",
|
| 806 |
+
" (dropout): Dropout(p=0.1, inplace=False)\n",
|
| 807 |
+
")"
|
| 808 |
+
]
|
| 809 |
+
},
|
| 810 |
+
"execution_count": 16,
|
| 811 |
+
"metadata": {},
|
| 812 |
+
"output_type": "execute_result"
|
| 813 |
+
}
|
| 814 |
+
],
|
| 815 |
+
"source": [
|
| 816 |
+
"device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
|
| 817 |
+
"\n",
|
| 818 |
+
"# model = RobertaForSequenceClassification.from_pretrained(\n",
|
| 819 |
+
"# 'roberta-large',\n",
|
| 820 |
+
"# num_labels=len(set(y_train)) \n",
|
| 821 |
+
"# )\n",
|
| 822 |
+
"model = AutoModelForSequenceClassification.from_pretrained(\n",
|
| 823 |
+
" 'microsoft/deberta-v3-large',\n",
|
| 824 |
+
" num_labels=len(set(y_train)) \n",
|
| 825 |
+
")\n",
|
| 826 |
+
"model.to(device)"
|
| 827 |
+
]
|
| 828 |
+
},
|
| 829 |
+
{
|
| 830 |
+
"cell_type": "code",
|
| 831 |
+
"execution_count": 17,
|
| 832 |
+
"id": "3f6073fd",
|
| 833 |
+
"metadata": {
|
| 834 |
+
"execution": {
|
| 835 |
+
"iopub.execute_input": "2025-09-29T03:52:46.729189Z",
|
| 836 |
+
"iopub.status.busy": "2025-09-29T03:52:46.728839Z",
|
| 837 |
+
"iopub.status.idle": "2025-09-29T03:52:46.732796Z",
|
| 838 |
+
"shell.execute_reply": "2025-09-29T03:52:46.731925Z"
|
| 839 |
+
},
|
| 840 |
+
"papermill": {
|
| 841 |
+
"duration": 0.011498,
|
| 842 |
+
"end_time": "2025-09-29T03:52:46.734629",
|
| 843 |
+
"exception": false,
|
| 844 |
+
"start_time": "2025-09-29T03:52:46.723131",
|
| 845 |
+
"status": "completed"
|
| 846 |
+
},
|
| 847 |
+
"tags": []
|
| 848 |
+
},
|
| 849 |
+
"outputs": [],
|
| 850 |
+
"source": [
|
| 851 |
+
"# from sklearn.metrics import classification_report\n",
|
| 852 |
+
"\n",
|
| 853 |
+
"# optimizer = AdamW(model.parameters(), lr=2e-5)\n",
|
| 854 |
+
"\n",
|
| 855 |
+
"# model.train()\n",
|
| 856 |
+
"# for epoch in range(10):\n",
|
| 857 |
+
"# total_loss = 0\n",
|
| 858 |
+
"# for batch in train_loader:\n",
|
| 859 |
+
"# input_ids = batch['input_ids'].to(device)\n",
|
| 860 |
+
"# attention_mask = batch['attention_mask'].to(device)\n",
|
| 861 |
+
"# labels = batch['labels'].to(device)\n",
|
| 862 |
+
"\n",
|
| 863 |
+
"# optimizer.zero_grad()\n",
|
| 864 |
+
"# outputs = model(input_ids=input_ids, attention_mask=attention_mask, labels=labels)\n",
|
| 865 |
+
"# loss = outputs.loss\n",
|
| 866 |
+
"# loss.backward()\n",
|
| 867 |
+
"# optimizer.step()\n",
|
| 868 |
+
"\n",
|
| 869 |
+
"# total_loss += loss.item()\n",
|
| 870 |
+
"# model.eval()\n",
|
| 871 |
+
"# all_preds = []\n",
|
| 872 |
+
"# all_labels = []\n",
|
| 873 |
+
" \n",
|
| 874 |
+
"# with torch.no_grad():\n",
|
| 875 |
+
"# for batch in test_loader:\n",
|
| 876 |
+
"# input_ids = batch['input_ids'].to(device)\n",
|
| 877 |
+
"# attention_mask = batch['attention_mask'].to(device)\n",
|
| 878 |
+
"# labels = batch['labels'].to(device)\n",
|
| 879 |
+
" \n",
|
| 880 |
+
"# outputs = model(input_ids=input_ids, attention_mask=attention_mask)\n",
|
| 881 |
+
"# preds = torch.argmax(outputs.logits, dim=1)\n",
|
| 882 |
+
" \n",
|
| 883 |
+
"# all_preds.extend(preds.cpu().numpy())\n",
|
| 884 |
+
"# all_labels.extend(labels.cpu().numpy())\n",
|
| 885 |
+
" \n",
|
| 886 |
+
"# accuracy = accuracy_score(all_labels, all_preds)\n",
|
| 887 |
+
"# report = classification_report(all_labels, all_preds)\n",
|
| 888 |
+
"# print(f\"Accuracy: {accuracy:.4f}\")\n",
|
| 889 |
+
"# print(report)\n",
|
| 890 |
+
"# print(f\"Epoch {epoch+1}, Loss: {total_loss/len(train_loader):.4f}\")"
|
| 891 |
+
]
|
| 892 |
+
},
|
| 893 |
+
{
|
| 894 |
+
"cell_type": "code",
|
| 895 |
+
"execution_count": 18,
|
| 896 |
+
"id": "6ca40d29",
|
| 897 |
+
"metadata": {
|
| 898 |
+
"execution": {
|
| 899 |
+
"iopub.execute_input": "2025-09-29T03:52:46.754858Z",
|
| 900 |
+
"iopub.status.busy": "2025-09-29T03:52:46.754566Z",
|
| 901 |
+
"iopub.status.idle": "2025-09-29T05:30:24.025725Z",
|
| 902 |
+
"shell.execute_reply": "2025-09-29T05:30:24.024812Z"
|
| 903 |
+
},
|
| 904 |
+
"papermill": {
|
| 905 |
+
"duration": 5857.284843,
|
| 906 |
+
"end_time": "2025-09-29T05:30:24.032714",
|
| 907 |
+
"exception": false,
|
| 908 |
+
"start_time": "2025-09-29T03:52:46.747871",
|
| 909 |
+
"status": "completed"
|
| 910 |
+
},
|
| 911 |
+
"tags": []
|
| 912 |
+
},
|
| 913 |
+
"outputs": [
|
| 914 |
+
{
|
| 915 |
+
"name": "stdout",
|
| 916 |
+
"output_type": "stream",
|
| 917 |
+
"text": [
|
| 918 |
+
"Epoch 1, Loss: 0.1061\n",
|
| 919 |
+
"Accuracy: 0.6542\n",
|
| 920 |
+
" precision recall f1-score support\n",
|
| 921 |
+
"\n",
|
| 922 |
+
" 0 0.00 0.00 0.00 175\n",
|
| 923 |
+
" 1 0.65 1.00 0.79 331\n",
|
| 924 |
+
"\n",
|
| 925 |
+
" accuracy 0.65 506\n",
|
| 926 |
+
" macro avg 0.33 0.50 0.40 506\n",
|
| 927 |
+
"weighted avg 0.43 0.65 0.52 506\n",
|
| 928 |
+
"\n",
|
| 929 |
+
"Epoch 2, Loss: 0.0955\n",
|
| 930 |
+
"Accuracy: 0.7708\n",
|
| 931 |
+
" precision recall f1-score support\n",
|
| 932 |
+
"\n",
|
| 933 |
+
" 0 0.65 0.72 0.68 175\n",
|
| 934 |
+
" 1 0.84 0.80 0.82 331\n",
|
| 935 |
+
"\n",
|
| 936 |
+
" accuracy 0.77 506\n",
|
| 937 |
+
" macro avg 0.75 0.76 0.75 506\n",
|
| 938 |
+
"weighted avg 0.78 0.77 0.77 506\n",
|
| 939 |
+
"\n",
|
| 940 |
+
"Epoch 3, Loss: 0.0781\n",
|
| 941 |
+
"Accuracy: 0.6779\n",
|
| 942 |
+
" precision recall f1-score support\n",
|
| 943 |
+
"\n",
|
| 944 |
+
" 0 0.52 0.89 0.66 175\n",
|
| 945 |
+
" 1 0.90 0.57 0.70 331\n",
|
| 946 |
+
"\n",
|
| 947 |
+
" accuracy 0.68 506\n",
|
| 948 |
+
" macro avg 0.71 0.73 0.68 506\n",
|
| 949 |
+
"weighted avg 0.77 0.68 0.68 506\n",
|
| 950 |
+
"\n",
|
| 951 |
+
"Epoch 4, Loss: 0.0506\n",
|
| 952 |
+
"Accuracy: 0.7727\n",
|
| 953 |
+
" precision recall f1-score support\n",
|
| 954 |
+
"\n",
|
| 955 |
+
" 0 0.75 0.52 0.61 175\n",
|
| 956 |
+
" 1 0.78 0.91 0.84 331\n",
|
| 957 |
+
"\n",
|
| 958 |
+
" accuracy 0.77 506\n",
|
| 959 |
+
" macro avg 0.76 0.71 0.73 506\n",
|
| 960 |
+
"weighted avg 0.77 0.77 0.76 506\n",
|
| 961 |
+
"\n",
|
| 962 |
+
"Epoch 5, Loss: 0.0259\n",
|
| 963 |
+
"Accuracy: 0.7589\n",
|
| 964 |
+
" precision recall f1-score support\n",
|
| 965 |
+
"\n",
|
| 966 |
+
" 0 0.70 0.53 0.60 175\n",
|
| 967 |
+
" 1 0.78 0.88 0.83 331\n",
|
| 968 |
+
"\n",
|
| 969 |
+
" accuracy 0.76 506\n",
|
| 970 |
+
" macro avg 0.74 0.70 0.71 506\n",
|
| 971 |
+
"weighted avg 0.75 0.76 0.75 506\n",
|
| 972 |
+
"\n",
|
| 973 |
+
"Epoch 6, Loss: 0.0182\n",
|
| 974 |
+
"Accuracy: 0.7609\n",
|
| 975 |
+
" precision recall f1-score support\n",
|
| 976 |
+
"\n",
|
| 977 |
+
" 0 0.73 0.49 0.59 175\n",
|
| 978 |
+
" 1 0.77 0.90 0.83 331\n",
|
| 979 |
+
"\n",
|
| 980 |
+
" accuracy 0.76 506\n",
|
| 981 |
+
" macro avg 0.75 0.70 0.71 506\n",
|
| 982 |
+
"weighted avg 0.76 0.76 0.75 506\n",
|
| 983 |
+
"\n",
|
| 984 |
+
"Epoch 7, Loss: 0.0079\n",
|
| 985 |
+
"Accuracy: 0.7253\n",
|
| 986 |
+
" precision recall f1-score support\n",
|
| 987 |
+
"\n",
|
| 988 |
+
" 0 0.59 0.66 0.63 175\n",
|
| 989 |
+
" 1 0.81 0.76 0.78 331\n",
|
| 990 |
+
"\n",
|
| 991 |
+
" accuracy 0.73 506\n",
|
| 992 |
+
" macro avg 0.70 0.71 0.70 506\n",
|
| 993 |
+
"weighted avg 0.73 0.73 0.73 506\n",
|
| 994 |
+
"\n",
|
| 995 |
+
"Epoch 8, Loss: 0.0061\n",
|
| 996 |
+
"Accuracy: 0.7372\n",
|
| 997 |
+
" precision recall f1-score support\n",
|
| 998 |
+
"\n",
|
| 999 |
+
" 0 0.71 0.40 0.51 175\n",
|
| 1000 |
+
" 1 0.74 0.92 0.82 331\n",
|
| 1001 |
+
"\n",
|
| 1002 |
+
" accuracy 0.74 506\n",
|
| 1003 |
+
" macro avg 0.73 0.66 0.67 506\n",
|
| 1004 |
+
"weighted avg 0.73 0.74 0.71 506\n",
|
| 1005 |
+
"\n",
|
| 1006 |
+
"Epoch 9, Loss: 0.0030\n",
|
| 1007 |
+
"Accuracy: 0.7391\n",
|
| 1008 |
+
" precision recall f1-score support\n",
|
| 1009 |
+
"\n",
|
| 1010 |
+
" 0 0.60 0.71 0.65 175\n",
|
| 1011 |
+
" 1 0.83 0.76 0.79 331\n",
|
| 1012 |
+
"\n",
|
| 1013 |
+
" accuracy 0.74 506\n",
|
| 1014 |
+
" macro avg 0.72 0.73 0.72 506\n",
|
| 1015 |
+
"weighted avg 0.75 0.74 0.74 506\n",
|
| 1016 |
+
"\n",
|
| 1017 |
+
"Epoch 10, Loss: 0.0059\n",
|
| 1018 |
+
"Accuracy: 0.6917\n",
|
| 1019 |
+
" precision recall f1-score support\n",
|
| 1020 |
+
"\n",
|
| 1021 |
+
" 0 0.54 0.75 0.63 175\n",
|
| 1022 |
+
" 1 0.84 0.66 0.74 331\n",
|
| 1023 |
+
"\n",
|
| 1024 |
+
" accuracy 0.69 506\n",
|
| 1025 |
+
" macro avg 0.69 0.71 0.68 506\n",
|
| 1026 |
+
"weighted avg 0.73 0.69 0.70 506\n",
|
| 1027 |
+
"\n"
|
| 1028 |
+
]
|
| 1029 |
+
}
|
| 1030 |
+
],
|
| 1031 |
+
"source": [
|
| 1032 |
+
"from sklearn.metrics import classification_report, accuracy_score\n",
|
| 1033 |
+
"# from transformers import AdamW\n",
|
| 1034 |
+
"\n",
|
| 1035 |
+
"optimizer = AdamW(model.parameters(), lr=2e-5)\n",
|
| 1036 |
+
"\n",
|
| 1037 |
+
"accumulation_steps = 6 \n",
|
| 1038 |
+
"model.train()\n",
|
| 1039 |
+
"for epoch in range(10):\n",
|
| 1040 |
+
" total_loss = 0\n",
|
| 1041 |
+
" model.train()\n",
|
| 1042 |
+
"\n",
|
| 1043 |
+
" for step, batch in enumerate(train_loader):\n",
|
| 1044 |
+
" input_ids = batch['input_ids'].to(device)\n",
|
| 1045 |
+
" attention_mask = batch['attention_mask'].to(device)\n",
|
| 1046 |
+
" labels = batch['labels'].to(device)\n",
|
| 1047 |
+
"\n",
|
| 1048 |
+
" outputs = model(input_ids=input_ids, attention_mask=attention_mask, labels=labels)\n",
|
| 1049 |
+
" loss = outputs.loss / accumulation_steps \n",
|
| 1050 |
+
"\n",
|
| 1051 |
+
" loss.backward()\n",
|
| 1052 |
+
" total_loss += loss.item()\n",
|
| 1053 |
+
"\n",
|
| 1054 |
+
" if (step + 1) % accumulation_steps == 0:\n",
|
| 1055 |
+
" optimizer.step()\n",
|
| 1056 |
+
" optimizer.zero_grad()\n",
|
| 1057 |
+
"\n",
|
| 1058 |
+
" if (step + 1) % accumulation_steps != 0:\n",
|
| 1059 |
+
" optimizer.step()\n",
|
| 1060 |
+
" optimizer.zero_grad()\n",
|
| 1061 |
+
"\n",
|
| 1062 |
+
" model.eval()\n",
|
| 1063 |
+
" all_preds = []\n",
|
| 1064 |
+
" all_labels = []\n",
|
| 1065 |
+
"\n",
|
| 1066 |
+
" with torch.no_grad():\n",
|
| 1067 |
+
" for batch in test_loader:\n",
|
| 1068 |
+
" input_ids = batch['input_ids'].to(device)\n",
|
| 1069 |
+
" attention_mask = batch['attention_mask'].to(device)\n",
|
| 1070 |
+
" labels = batch['labels'].to(device)\n",
|
| 1071 |
+
"\n",
|
| 1072 |
+
" outputs = model(input_ids=input_ids, attention_mask=attention_mask)\n",
|
| 1073 |
+
" preds = torch.argmax(outputs.logits, dim=1)\n",
|
| 1074 |
+
"\n",
|
| 1075 |
+
" all_preds.extend(preds.cpu().numpy())\n",
|
| 1076 |
+
" all_labels.extend(labels.cpu().numpy())\n",
|
| 1077 |
+
"\n",
|
| 1078 |
+
" accuracy = accuracy_score(all_labels, all_preds)\n",
|
| 1079 |
+
" report = classification_report(all_labels, all_preds)\n",
|
| 1080 |
+
" print(f\"Epoch {epoch+1}, Loss: {total_loss/len(train_loader):.4f}\")\n",
|
| 1081 |
+
" print(f\"Accuracy: {accuracy:.4f}\")\n",
|
| 1082 |
+
" print(report)\n"
|
| 1083 |
+
]
|
| 1084 |
+
},
|
| 1085 |
+
{
|
| 1086 |
+
"cell_type": "code",
|
| 1087 |
+
"execution_count": 19,
|
| 1088 |
+
"id": "07ee95b3",
|
| 1089 |
+
"metadata": {
|
| 1090 |
+
"execution": {
|
| 1091 |
+
"iopub.execute_input": "2025-09-29T05:30:24.045329Z",
|
| 1092 |
+
"iopub.status.busy": "2025-09-29T05:30:24.045071Z",
|
| 1093 |
+
"iopub.status.idle": "2025-09-29T05:30:24.048378Z",
|
| 1094 |
+
"shell.execute_reply": "2025-09-29T05:30:24.047714Z"
|
| 1095 |
+
},
|
| 1096 |
+
"papermill": {
|
| 1097 |
+
"duration": 0.011299,
|
| 1098 |
+
"end_time": "2025-09-29T05:30:24.049538",
|
| 1099 |
+
"exception": false,
|
| 1100 |
+
"start_time": "2025-09-29T05:30:24.038239",
|
| 1101 |
+
"status": "completed"
|
| 1102 |
+
},
|
| 1103 |
+
"tags": []
|
| 1104 |
+
},
|
| 1105 |
+
"outputs": [],
|
| 1106 |
+
"source": [
|
| 1107 |
+
"# model.eval()\n",
|
| 1108 |
+
"# all_preds = []\n",
|
| 1109 |
+
"# all_labels = []\n",
|
| 1110 |
+
"\n",
|
| 1111 |
+
"# with torch.no_grad():\n",
|
| 1112 |
+
"# for batch in test_loader:\n",
|
| 1113 |
+
"# input_ids = batch['input_ids'].to(device)\n",
|
| 1114 |
+
"# attention_mask = batch['attention_mask'].to(device)\n",
|
| 1115 |
+
"# labels = batch['labels'].to(device)\n",
|
| 1116 |
+
"\n",
|
| 1117 |
+
"# outputs = model(input_ids=input_ids, attention_mask=attention_mask)\n",
|
| 1118 |
+
"# preds = torch.argmax(outputs.logits, dim=1)\n",
|
| 1119 |
+
"\n",
|
| 1120 |
+
"# all_preds.extend(preds.cpu().numpy())\n",
|
| 1121 |
+
"# all_labels.extend(labels.cpu().numpy())\n",
|
| 1122 |
+
"\n",
|
| 1123 |
+
"# accuracy = accuracy_score(all_labels, all_preds)\n",
|
| 1124 |
+
"# print(f\"Accuracy: {accuracy:.4f}\")\n"
|
| 1125 |
+
]
|
| 1126 |
+
},
|
| 1127 |
+
{
|
| 1128 |
+
"cell_type": "code",
|
| 1129 |
+
"execution_count": 20,
|
| 1130 |
+
"id": "bdea7785",
|
| 1131 |
+
"metadata": {
|
| 1132 |
+
"execution": {
|
| 1133 |
+
"iopub.execute_input": "2025-09-29T05:30:24.060690Z",
|
| 1134 |
+
"iopub.status.busy": "2025-09-29T05:30:24.060484Z",
|
| 1135 |
+
"iopub.status.idle": "2025-09-29T05:30:24.063360Z",
|
| 1136 |
+
"shell.execute_reply": "2025-09-29T05:30:24.062712Z"
|
| 1137 |
+
},
|
| 1138 |
+
"papermill": {
|
| 1139 |
+
"duration": 0.009619,
|
| 1140 |
+
"end_time": "2025-09-29T05:30:24.064456",
|
| 1141 |
+
"exception": false,
|
| 1142 |
+
"start_time": "2025-09-29T05:30:24.054837",
|
| 1143 |
+
"status": "completed"
|
| 1144 |
+
},
|
| 1145 |
+
"tags": []
|
| 1146 |
+
},
|
| 1147 |
+
"outputs": [],
|
| 1148 |
+
"source": [
|
| 1149 |
+
"# from sklearn.metrics import classification_report\n",
|
| 1150 |
+
"\n",
|
| 1151 |
+
"# report = classification_report(all_labels, all_preds)\n",
|
| 1152 |
+
"# print(report)\n"
|
| 1153 |
+
]
|
| 1154 |
+
},
|
| 1155 |
+
{
|
| 1156 |
+
"cell_type": "code",
|
| 1157 |
+
"execution_count": null,
|
| 1158 |
+
"id": "db6c1a7c",
|
| 1159 |
+
"metadata": {
|
| 1160 |
+
"papermill": {
|
| 1161 |
+
"duration": 0.005479,
|
| 1162 |
+
"end_time": "2025-09-29T05:30:24.075428",
|
| 1163 |
+
"exception": false,
|
| 1164 |
+
"start_time": "2025-09-29T05:30:24.069949",
|
| 1165 |
+
"status": "completed"
|
| 1166 |
+
},
|
| 1167 |
+
"tags": []
|
| 1168 |
+
},
|
| 1169 |
+
"outputs": [],
|
| 1170 |
+
"source": []
|
| 1171 |
+
}
|
| 1172 |
+
],
|
| 1173 |
+
"metadata": {
|
| 1174 |
+
"kaggle": {
|
| 1175 |
+
"accelerator": "gpu",
|
| 1176 |
+
"dataSources": [
|
| 1177 |
+
{
|
| 1178 |
+
"datasetId": 3335974,
|
| 1179 |
+
"sourceId": 5807888,
|
| 1180 |
+
"sourceType": "datasetVersion"
|
| 1181 |
+
},
|
| 1182 |
+
{
|
| 1183 |
+
"datasetId": 7433068,
|
| 1184 |
+
"sourceId": 11831832,
|
| 1185 |
+
"sourceType": "datasetVersion"
|
| 1186 |
+
}
|
| 1187 |
+
],
|
| 1188 |
+
"dockerImageVersionId": 30919,
|
| 1189 |
+
"isGpuEnabled": true,
|
| 1190 |
+
"isInternetEnabled": true,
|
| 1191 |
+
"language": "python",
|
| 1192 |
+
"sourceType": "notebook"
|
| 1193 |
+
},
|
| 1194 |
+
"kernelspec": {
|
| 1195 |
+
"display_name": "Python 3",
|
| 1196 |
+
"language": "python",
|
| 1197 |
+
"name": "python3"
|
| 1198 |
+
},
|
| 1199 |
+
"language_info": {
|
| 1200 |
+
"codemirror_mode": {
|
| 1201 |
+
"name": "ipython",
|
| 1202 |
+
"version": 3
|
| 1203 |
+
},
|
| 1204 |
+
"file_extension": ".py",
|
| 1205 |
+
"mimetype": "text/x-python",
|
| 1206 |
+
"name": "python",
|
| 1207 |
+
"nbconvert_exporter": "python",
|
| 1208 |
+
"pygments_lexer": "ipython3",
|
| 1209 |
+
"version": "3.10.12"
|
| 1210 |
+
},
|
| 1211 |
+
"papermill": {
|
| 1212 |
+
"default_parameters": {},
|
| 1213 |
+
"duration": 5894.527411,
|
| 1214 |
+
"end_time": "2025-09-29T05:30:27.169416",
|
| 1215 |
+
"environment_variables": {},
|
| 1216 |
+
"exception": null,
|
| 1217 |
+
"input_path": "__notebook__.ipynb",
|
| 1218 |
+
"output_path": "__notebook__.ipynb",
|
| 1219 |
+
"parameters": {},
|
| 1220 |
+
"start_time": "2025-09-29T03:52:12.642005",
|
| 1221 |
+
"version": "2.6.0"
|
| 1222 |
+
},
|
| 1223 |
+
"widgets": {
|
| 1224 |
+
"application/vnd.jupyter.widget-state+json": {
|
| 1225 |
+
"state": {
|
| 1226 |
+
"0c2f17627c384d54b7740b5d6b4d8c00": {
|
| 1227 |
+
"model_module": "@jupyter-widgets/controls",
|
| 1228 |
+
"model_module_version": "2.0.0",
|
| 1229 |
+
"model_name": "HTMLModel",
|
| 1230 |
+
"state": {
|
| 1231 |
+
"_dom_classes": [],
|
| 1232 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 1233 |
+
"_model_module_version": "2.0.0",
|
| 1234 |
+
"_model_name": "HTMLModel",
|
| 1235 |
+
"_view_count": null,
|
| 1236 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 1237 |
+
"_view_module_version": "2.0.0",
|
| 1238 |
+
"_view_name": "HTMLView",
|
| 1239 |
+
"description": "",
|
| 1240 |
+
"description_allow_html": false,
|
| 1241 |
+
"layout": "IPY_MODEL_7c283e9474ce4e9f9714a49d4a757f81",
|
| 1242 |
+
"placeholder": "",
|
| 1243 |
+
"style": "IPY_MODEL_3802337b7bd0462eb1abde9df5fb8ef2",
|
| 1244 |
+
"tabbable": null,
|
| 1245 |
+
"tooltip": null,
|
| 1246 |
+
"value": "config.json: 100%"
|
| 1247 |
+
}
|
| 1248 |
+
},
|
| 1249 |
+
"13329edc4b994296910273e9aaee5927": {
|
| 1250 |
+
"model_module": "@jupyter-widgets/controls",
|
| 1251 |
+
"model_module_version": "2.0.0",
|
| 1252 |
+
"model_name": "HTMLStyleModel",
|
| 1253 |
+
"state": {
|
| 1254 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 1255 |
+
"_model_module_version": "2.0.0",
|
| 1256 |
+
"_model_name": "HTMLStyleModel",
|
| 1257 |
+
"_view_count": null,
|
| 1258 |
+
"_view_module": "@jupyter-widgets/base",
|
| 1259 |
+
"_view_module_version": "2.0.0",
|
| 1260 |
+
"_view_name": "StyleView",
|
| 1261 |
+
"background": null,
|
| 1262 |
+
"description_width": "",
|
| 1263 |
+
"font_size": null,
|
| 1264 |
+
"text_color": null
|
| 1265 |
+
}
|
| 1266 |
+
},
|
| 1267 |
+
"165d6227d80f4e34a04098a9df44f90d": {
|
| 1268 |
+
"model_module": "@jupyter-widgets/base",
|
| 1269 |
+
"model_module_version": "2.0.0",
|
| 1270 |
+
"model_name": "LayoutModel",
|
| 1271 |
+
"state": {
|
| 1272 |
+
"_model_module": "@jupyter-widgets/base",
|
| 1273 |
+
"_model_module_version": "2.0.0",
|
| 1274 |
+
"_model_name": "LayoutModel",
|
| 1275 |
+
"_view_count": null,
|
| 1276 |
+
"_view_module": "@jupyter-widgets/base",
|
| 1277 |
+
"_view_module_version": "2.0.0",
|
| 1278 |
+
"_view_name": "LayoutView",
|
| 1279 |
+
"align_content": null,
|
| 1280 |
+
"align_items": null,
|
| 1281 |
+
"align_self": null,
|
| 1282 |
+
"border_bottom": null,
|
| 1283 |
+
"border_left": null,
|
| 1284 |
+
"border_right": null,
|
| 1285 |
+
"border_top": null,
|
| 1286 |
+
"bottom": null,
|
| 1287 |
+
"display": null,
|
| 1288 |
+
"flex": null,
|
| 1289 |
+
"flex_flow": null,
|
| 1290 |
+
"grid_area": null,
|
| 1291 |
+
"grid_auto_columns": null,
|
| 1292 |
+
"grid_auto_flow": null,
|
| 1293 |
+
"grid_auto_rows": null,
|
| 1294 |
+
"grid_column": null,
|
| 1295 |
+
"grid_gap": null,
|
| 1296 |
+
"grid_row": null,
|
| 1297 |
+
"grid_template_areas": null,
|
| 1298 |
+
"grid_template_columns": null,
|
| 1299 |
+
"grid_template_rows": null,
|
| 1300 |
+
"height": null,
|
| 1301 |
+
"justify_content": null,
|
| 1302 |
+
"justify_items": null,
|
| 1303 |
+
"left": null,
|
| 1304 |
+
"margin": null,
|
| 1305 |
+
"max_height": null,
|
| 1306 |
+
"max_width": null,
|
| 1307 |
+
"min_height": null,
|
| 1308 |
+
"min_width": null,
|
| 1309 |
+
"object_fit": null,
|
| 1310 |
+
"object_position": null,
|
| 1311 |
+
"order": null,
|
| 1312 |
+
"overflow": null,
|
| 1313 |
+
"padding": null,
|
| 1314 |
+
"right": null,
|
| 1315 |
+
"top": null,
|
| 1316 |
+
"visibility": null,
|
| 1317 |
+
"width": null
|
| 1318 |
+
}
|
| 1319 |
+
},
|
| 1320 |
+
"1b248f87427b40fd9d2a20b34daa8212": {
|
| 1321 |
+
"model_module": "@jupyter-widgets/controls",
|
| 1322 |
+
"model_module_version": "2.0.0",
|
| 1323 |
+
"model_name": "HTMLModel",
|
| 1324 |
+
"state": {
|
| 1325 |
+
"_dom_classes": [],
|
| 1326 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 1327 |
+
"_model_module_version": "2.0.0",
|
| 1328 |
+
"_model_name": "HTMLModel",
|
| 1329 |
+
"_view_count": null,
|
| 1330 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 1331 |
+
"_view_module_version": "2.0.0",
|
| 1332 |
+
"_view_name": "HTMLView",
|
| 1333 |
+
"description": "",
|
| 1334 |
+
"description_allow_html": false,
|
| 1335 |
+
"layout": "IPY_MODEL_417426d2318c4a3986805163b9162b7b",
|
| 1336 |
+
"placeholder": "",
|
| 1337 |
+
"style": "IPY_MODEL_fd999dd7a0b942e898fa6ef2a4c6a981",
|
| 1338 |
+
"tabbable": null,
|
| 1339 |
+
"tooltip": null,
|
| 1340 |
+
"value": " 52.0/52.0 [00:00<00:00, 4.72kB/s]"
|
| 1341 |
+
}
|
| 1342 |
+
},
|
| 1343 |
+
"2665da26142c47089af7ff1c738190a0": {
|
| 1344 |
+
"model_module": "@jupyter-widgets/controls",
|
| 1345 |
+
"model_module_version": "2.0.0",
|
| 1346 |
+
"model_name": "FloatProgressModel",
|
| 1347 |
+
"state": {
|
| 1348 |
+
"_dom_classes": [],
|
| 1349 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 1350 |
+
"_model_module_version": "2.0.0",
|
| 1351 |
+
"_model_name": "FloatProgressModel",
|
| 1352 |
+
"_view_count": null,
|
| 1353 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 1354 |
+
"_view_module_version": "2.0.0",
|
| 1355 |
+
"_view_name": "ProgressView",
|
| 1356 |
+
"bar_style": "success",
|
| 1357 |
+
"description": "",
|
| 1358 |
+
"description_allow_html": false,
|
| 1359 |
+
"layout": "IPY_MODEL_768c6965b7534d1d8ccb35fe089bf50b",
|
| 1360 |
+
"max": 873673253.0,
|
| 1361 |
+
"min": 0.0,
|
| 1362 |
+
"orientation": "horizontal",
|
| 1363 |
+
"style": "IPY_MODEL_4fcefafda03f4ddaa95085a77cf740b7",
|
| 1364 |
+
"tabbable": null,
|
| 1365 |
+
"tooltip": null,
|
| 1366 |
+
"value": 873673253.0
|
| 1367 |
+
}
|
| 1368 |
+
},
|
| 1369 |
+
"26a74c7023744bd19111a9a049a55b30": {
|
| 1370 |
+
"model_module": "@jupyter-widgets/base",
|
| 1371 |
+
"model_module_version": "2.0.0",
|
| 1372 |
+
"model_name": "LayoutModel",
|
| 1373 |
+
"state": {
|
| 1374 |
+
"_model_module": "@jupyter-widgets/base",
|
| 1375 |
+
"_model_module_version": "2.0.0",
|
| 1376 |
+
"_model_name": "LayoutModel",
|
| 1377 |
+
"_view_count": null,
|
| 1378 |
+
"_view_module": "@jupyter-widgets/base",
|
| 1379 |
+
"_view_module_version": "2.0.0",
|
| 1380 |
+
"_view_name": "LayoutView",
|
| 1381 |
+
"align_content": null,
|
| 1382 |
+
"align_items": null,
|
| 1383 |
+
"align_self": null,
|
| 1384 |
+
"border_bottom": null,
|
| 1385 |
+
"border_left": null,
|
| 1386 |
+
"border_right": null,
|
| 1387 |
+
"border_top": null,
|
| 1388 |
+
"bottom": null,
|
| 1389 |
+
"display": null,
|
| 1390 |
+
"flex": null,
|
| 1391 |
+
"flex_flow": null,
|
| 1392 |
+
"grid_area": null,
|
| 1393 |
+
"grid_auto_columns": null,
|
| 1394 |
+
"grid_auto_flow": null,
|
| 1395 |
+
"grid_auto_rows": null,
|
| 1396 |
+
"grid_column": null,
|
| 1397 |
+
"grid_gap": null,
|
| 1398 |
+
"grid_row": null,
|
| 1399 |
+
"grid_template_areas": null,
|
| 1400 |
+
"grid_template_columns": null,
|
| 1401 |
+
"grid_template_rows": null,
|
| 1402 |
+
"height": null,
|
| 1403 |
+
"justify_content": null,
|
| 1404 |
+
"justify_items": null,
|
| 1405 |
+
"left": null,
|
| 1406 |
+
"margin": null,
|
| 1407 |
+
"max_height": null,
|
| 1408 |
+
"max_width": null,
|
| 1409 |
+
"min_height": null,
|
| 1410 |
+
"min_width": null,
|
| 1411 |
+
"object_fit": null,
|
| 1412 |
+
"object_position": null,
|
| 1413 |
+
"order": null,
|
| 1414 |
+
"overflow": null,
|
| 1415 |
+
"padding": null,
|
| 1416 |
+
"right": null,
|
| 1417 |
+
"top": null,
|
| 1418 |
+
"visibility": null,
|
| 1419 |
+
"width": null
|
| 1420 |
+
}
|
| 1421 |
+
},
|
| 1422 |
+
"34313653b0e84e10a6ac067a87e7b685": {
|
| 1423 |
+
"model_module": "@jupyter-widgets/controls",
|
| 1424 |
+
"model_module_version": "2.0.0",
|
| 1425 |
+
"model_name": "HTMLStyleModel",
|
| 1426 |
+
"state": {
|
| 1427 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 1428 |
+
"_model_module_version": "2.0.0",
|
| 1429 |
+
"_model_name": "HTMLStyleModel",
|
| 1430 |
+
"_view_count": null,
|
| 1431 |
+
"_view_module": "@jupyter-widgets/base",
|
| 1432 |
+
"_view_module_version": "2.0.0",
|
| 1433 |
+
"_view_name": "StyleView",
|
| 1434 |
+
"background": null,
|
| 1435 |
+
"description_width": "",
|
| 1436 |
+
"font_size": null,
|
| 1437 |
+
"text_color": null
|
| 1438 |
+
}
|
| 1439 |
+
},
|
| 1440 |
+
"3802337b7bd0462eb1abde9df5fb8ef2": {
|
| 1441 |
+
"model_module": "@jupyter-widgets/controls",
|
| 1442 |
+
"model_module_version": "2.0.0",
|
| 1443 |
+
"model_name": "HTMLStyleModel",
|
| 1444 |
+
"state": {
|
| 1445 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 1446 |
+
"_model_module_version": "2.0.0",
|
| 1447 |
+
"_model_name": "HTMLStyleModel",
|
| 1448 |
+
"_view_count": null,
|
| 1449 |
+
"_view_module": "@jupyter-widgets/base",
|
| 1450 |
+
"_view_module_version": "2.0.0",
|
| 1451 |
+
"_view_name": "StyleView",
|
| 1452 |
+
"background": null,
|
| 1453 |
+
"description_width": "",
|
| 1454 |
+
"font_size": null,
|
| 1455 |
+
"text_color": null
|
| 1456 |
+
}
|
| 1457 |
+
},
|
| 1458 |
+
"3e27e692245e43b48bb726571b1597a7": {
|
| 1459 |
+
"model_module": "@jupyter-widgets/controls",
|
| 1460 |
+
"model_module_version": "2.0.0",
|
| 1461 |
+
"model_name": "HTMLStyleModel",
|
| 1462 |
+
"state": {
|
| 1463 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 1464 |
+
"_model_module_version": "2.0.0",
|
| 1465 |
+
"_model_name": "HTMLStyleModel",
|
| 1466 |
+
"_view_count": null,
|
| 1467 |
+
"_view_module": "@jupyter-widgets/base",
|
| 1468 |
+
"_view_module_version": "2.0.0",
|
| 1469 |
+
"_view_name": "StyleView",
|
| 1470 |
+
"background": null,
|
| 1471 |
+
"description_width": "",
|
| 1472 |
+
"font_size": null,
|
| 1473 |
+
"text_color": null
|
| 1474 |
+
}
|
| 1475 |
+
},
|
| 1476 |
+
"417426d2318c4a3986805163b9162b7b": {
|
| 1477 |
+
"model_module": "@jupyter-widgets/base",
|
| 1478 |
+
"model_module_version": "2.0.0",
|
| 1479 |
+
"model_name": "LayoutModel",
|
| 1480 |
+
"state": {
|
| 1481 |
+
"_model_module": "@jupyter-widgets/base",
|
| 1482 |
+
"_model_module_version": "2.0.0",
|
| 1483 |
+
"_model_name": "LayoutModel",
|
| 1484 |
+
"_view_count": null,
|
| 1485 |
+
"_view_module": "@jupyter-widgets/base",
|
| 1486 |
+
"_view_module_version": "2.0.0",
|
| 1487 |
+
"_view_name": "LayoutView",
|
| 1488 |
+
"align_content": null,
|
| 1489 |
+
"align_items": null,
|
| 1490 |
+
"align_self": null,
|
| 1491 |
+
"border_bottom": null,
|
| 1492 |
+
"border_left": null,
|
| 1493 |
+
"border_right": null,
|
| 1494 |
+
"border_top": null,
|
| 1495 |
+
"bottom": null,
|
| 1496 |
+
"display": null,
|
| 1497 |
+
"flex": null,
|
| 1498 |
+
"flex_flow": null,
|
| 1499 |
+
"grid_area": null,
|
| 1500 |
+
"grid_auto_columns": null,
|
| 1501 |
+
"grid_auto_flow": null,
|
| 1502 |
+
"grid_auto_rows": null,
|
| 1503 |
+
"grid_column": null,
|
| 1504 |
+
"grid_gap": null,
|
| 1505 |
+
"grid_row": null,
|
| 1506 |
+
"grid_template_areas": null,
|
| 1507 |
+
"grid_template_columns": null,
|
| 1508 |
+
"grid_template_rows": null,
|
| 1509 |
+
"height": null,
|
| 1510 |
+
"justify_content": null,
|
| 1511 |
+
"justify_items": null,
|
| 1512 |
+
"left": null,
|
| 1513 |
+
"margin": null,
|
| 1514 |
+
"max_height": null,
|
| 1515 |
+
"max_width": null,
|
| 1516 |
+
"min_height": null,
|
| 1517 |
+
"min_width": null,
|
| 1518 |
+
"object_fit": null,
|
| 1519 |
+
"object_position": null,
|
| 1520 |
+
"order": null,
|
| 1521 |
+
"overflow": null,
|
| 1522 |
+
"padding": null,
|
| 1523 |
+
"right": null,
|
| 1524 |
+
"top": null,
|
| 1525 |
+
"visibility": null,
|
| 1526 |
+
"width": null
|
| 1527 |
+
}
|
| 1528 |
+
},
|
| 1529 |
+
"4e8458b164d24b96868063f38ec0fdc6": {
|
| 1530 |
+
"model_module": "@jupyter-widgets/controls",
|
| 1531 |
+
"model_module_version": "2.0.0",
|
| 1532 |
+
"model_name": "HTMLModel",
|
| 1533 |
+
"state": {
|
| 1534 |
+
"_dom_classes": [],
|
| 1535 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 1536 |
+
"_model_module_version": "2.0.0",
|
| 1537 |
+
"_model_name": "HTMLModel",
|
| 1538 |
+
"_view_count": null,
|
| 1539 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 1540 |
+
"_view_module_version": "2.0.0",
|
| 1541 |
+
"_view_name": "HTMLView",
|
| 1542 |
+
"description": "",
|
| 1543 |
+
"description_allow_html": false,
|
| 1544 |
+
"layout": "IPY_MODEL_165d6227d80f4e34a04098a9df44f90d",
|
| 1545 |
+
"placeholder": "",
|
| 1546 |
+
"style": "IPY_MODEL_34313653b0e84e10a6ac067a87e7b685",
|
| 1547 |
+
"tabbable": null,
|
| 1548 |
+
"tooltip": null,
|
| 1549 |
+
"value": " 874M/874M [00:02<00:00, 304MB/s]"
|
| 1550 |
+
}
|
| 1551 |
+
},
|
| 1552 |
+
"4fcefafda03f4ddaa95085a77cf740b7": {
|
| 1553 |
+
"model_module": "@jupyter-widgets/controls",
|
| 1554 |
+
"model_module_version": "2.0.0",
|
| 1555 |
+
"model_name": "ProgressStyleModel",
|
| 1556 |
+
"state": {
|
| 1557 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 1558 |
+
"_model_module_version": "2.0.0",
|
| 1559 |
+
"_model_name": "ProgressStyleModel",
|
| 1560 |
+
"_view_count": null,
|
| 1561 |
+
"_view_module": "@jupyter-widgets/base",
|
| 1562 |
+
"_view_module_version": "2.0.0",
|
| 1563 |
+
"_view_name": "StyleView",
|
| 1564 |
+
"bar_color": null,
|
| 1565 |
+
"description_width": ""
|
| 1566 |
+
}
|
| 1567 |
+
},
|
| 1568 |
+
"54351e23d8fe431da1fc7fba4abfddf8": {
|
| 1569 |
+
"model_module": "@jupyter-widgets/controls",
|
| 1570 |
+
"model_module_version": "2.0.0",
|
| 1571 |
+
"model_name": "FloatProgressModel",
|
| 1572 |
+
"state": {
|
| 1573 |
+
"_dom_classes": [],
|
| 1574 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 1575 |
+
"_model_module_version": "2.0.0",
|
| 1576 |
+
"_model_name": "FloatProgressModel",
|
| 1577 |
+
"_view_count": null,
|
| 1578 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 1579 |
+
"_view_module_version": "2.0.0",
|
| 1580 |
+
"_view_name": "ProgressView",
|
| 1581 |
+
"bar_style": "success",
|
| 1582 |
+
"description": "",
|
| 1583 |
+
"description_allow_html": false,
|
| 1584 |
+
"layout": "IPY_MODEL_8a465a38c1e94d36a2af8f583a958267",
|
| 1585 |
+
"max": 2464616.0,
|
| 1586 |
+
"min": 0.0,
|
| 1587 |
+
"orientation": "horizontal",
|
| 1588 |
+
"style": "IPY_MODEL_d806a930970242538bba98b4c8b1e2db",
|
| 1589 |
+
"tabbable": null,
|
| 1590 |
+
"tooltip": null,
|
| 1591 |
+
"value": 2464616.0
|
| 1592 |
+
}
|
| 1593 |
+
},
|
| 1594 |
+
"5e7dde90a5554fbba23248a6df60976d": {
|
| 1595 |
+
"model_module": "@jupyter-widgets/controls",
|
| 1596 |
+
"model_module_version": "2.0.0",
|
| 1597 |
+
"model_name": "HBoxModel",
|
| 1598 |
+
"state": {
|
| 1599 |
+
"_dom_classes": [],
|
| 1600 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 1601 |
+
"_model_module_version": "2.0.0",
|
| 1602 |
+
"_model_name": "HBoxModel",
|
| 1603 |
+
"_view_count": null,
|
| 1604 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 1605 |
+
"_view_module_version": "2.0.0",
|
| 1606 |
+
"_view_name": "HBoxView",
|
| 1607 |
+
"box_style": "",
|
| 1608 |
+
"children": [
|
| 1609 |
+
"IPY_MODEL_7eeb9450410d4aafa92cf84293e117d4",
|
| 1610 |
+
"IPY_MODEL_54351e23d8fe431da1fc7fba4abfddf8",
|
| 1611 |
+
"IPY_MODEL_c44f21b446fd40b4a14e7b04cae081d3"
|
| 1612 |
+
],
|
| 1613 |
+
"layout": "IPY_MODEL_26a74c7023744bd19111a9a049a55b30",
|
| 1614 |
+
"tabbable": null,
|
| 1615 |
+
"tooltip": null
|
| 1616 |
+
}
|
| 1617 |
+
},
|
| 1618 |
+
"60277c8e01c5470ebd25b518e697673b": {
|
| 1619 |
+
"model_module": "@jupyter-widgets/base",
|
| 1620 |
+
"model_module_version": "2.0.0",
|
| 1621 |
+
"model_name": "LayoutModel",
|
| 1622 |
+
"state": {
|
| 1623 |
+
"_model_module": "@jupyter-widgets/base",
|
| 1624 |
+
"_model_module_version": "2.0.0",
|
| 1625 |
+
"_model_name": "LayoutModel",
|
| 1626 |
+
"_view_count": null,
|
| 1627 |
+
"_view_module": "@jupyter-widgets/base",
|
| 1628 |
+
"_view_module_version": "2.0.0",
|
| 1629 |
+
"_view_name": "LayoutView",
|
| 1630 |
+
"align_content": null,
|
| 1631 |
+
"align_items": null,
|
| 1632 |
+
"align_self": null,
|
| 1633 |
+
"border_bottom": null,
|
| 1634 |
+
"border_left": null,
|
| 1635 |
+
"border_right": null,
|
| 1636 |
+
"border_top": null,
|
| 1637 |
+
"bottom": null,
|
| 1638 |
+
"display": null,
|
| 1639 |
+
"flex": null,
|
| 1640 |
+
"flex_flow": null,
|
| 1641 |
+
"grid_area": null,
|
| 1642 |
+
"grid_auto_columns": null,
|
| 1643 |
+
"grid_auto_flow": null,
|
| 1644 |
+
"grid_auto_rows": null,
|
| 1645 |
+
"grid_column": null,
|
| 1646 |
+
"grid_gap": null,
|
| 1647 |
+
"grid_row": null,
|
| 1648 |
+
"grid_template_areas": null,
|
| 1649 |
+
"grid_template_columns": null,
|
| 1650 |
+
"grid_template_rows": null,
|
| 1651 |
+
"height": null,
|
| 1652 |
+
"justify_content": null,
|
| 1653 |
+
"justify_items": null,
|
| 1654 |
+
"left": null,
|
| 1655 |
+
"margin": null,
|
| 1656 |
+
"max_height": null,
|
| 1657 |
+
"max_width": null,
|
| 1658 |
+
"min_height": null,
|
| 1659 |
+
"min_width": null,
|
| 1660 |
+
"object_fit": null,
|
| 1661 |
+
"object_position": null,
|
| 1662 |
+
"order": null,
|
| 1663 |
+
"overflow": null,
|
| 1664 |
+
"padding": null,
|
| 1665 |
+
"right": null,
|
| 1666 |
+
"top": null,
|
| 1667 |
+
"visibility": null,
|
| 1668 |
+
"width": null
|
| 1669 |
+
}
|
| 1670 |
+
},
|
| 1671 |
+
"6f21b41c52df41349eba0aa25febd60e": {
|
| 1672 |
+
"model_module": "@jupyter-widgets/base",
|
| 1673 |
+
"model_module_version": "2.0.0",
|
| 1674 |
+
"model_name": "LayoutModel",
|
| 1675 |
+
"state": {
|
| 1676 |
+
"_model_module": "@jupyter-widgets/base",
|
| 1677 |
+
"_model_module_version": "2.0.0",
|
| 1678 |
+
"_model_name": "LayoutModel",
|
| 1679 |
+
"_view_count": null,
|
| 1680 |
+
"_view_module": "@jupyter-widgets/base",
|
| 1681 |
+
"_view_module_version": "2.0.0",
|
| 1682 |
+
"_view_name": "LayoutView",
|
| 1683 |
+
"align_content": null,
|
| 1684 |
+
"align_items": null,
|
| 1685 |
+
"align_self": null,
|
| 1686 |
+
"border_bottom": null,
|
| 1687 |
+
"border_left": null,
|
| 1688 |
+
"border_right": null,
|
| 1689 |
+
"border_top": null,
|
| 1690 |
+
"bottom": null,
|
| 1691 |
+
"display": null,
|
| 1692 |
+
"flex": null,
|
| 1693 |
+
"flex_flow": null,
|
| 1694 |
+
"grid_area": null,
|
| 1695 |
+
"grid_auto_columns": null,
|
| 1696 |
+
"grid_auto_flow": null,
|
| 1697 |
+
"grid_auto_rows": null,
|
| 1698 |
+
"grid_column": null,
|
| 1699 |
+
"grid_gap": null,
|
| 1700 |
+
"grid_row": null,
|
| 1701 |
+
"grid_template_areas": null,
|
| 1702 |
+
"grid_template_columns": null,
|
| 1703 |
+
"grid_template_rows": null,
|
| 1704 |
+
"height": null,
|
| 1705 |
+
"justify_content": null,
|
| 1706 |
+
"justify_items": null,
|
| 1707 |
+
"left": null,
|
| 1708 |
+
"margin": null,
|
| 1709 |
+
"max_height": null,
|
| 1710 |
+
"max_width": null,
|
| 1711 |
+
"min_height": null,
|
| 1712 |
+
"min_width": null,
|
| 1713 |
+
"object_fit": null,
|
| 1714 |
+
"object_position": null,
|
| 1715 |
+
"order": null,
|
| 1716 |
+
"overflow": null,
|
| 1717 |
+
"padding": null,
|
| 1718 |
+
"right": null,
|
| 1719 |
+
"top": null,
|
| 1720 |
+
"visibility": null,
|
| 1721 |
+
"width": null
|
| 1722 |
+
}
|
| 1723 |
+
},
|
| 1724 |
+
"6fecc138b4f54f5b97d0b04442b6711a": {
|
| 1725 |
+
"model_module": "@jupyter-widgets/controls",
|
| 1726 |
+
"model_module_version": "2.0.0",
|
| 1727 |
+
"model_name": "HBoxModel",
|
| 1728 |
+
"state": {
|
| 1729 |
+
"_dom_classes": [],
|
| 1730 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 1731 |
+
"_model_module_version": "2.0.0",
|
| 1732 |
+
"_model_name": "HBoxModel",
|
| 1733 |
+
"_view_count": null,
|
| 1734 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 1735 |
+
"_view_module_version": "2.0.0",
|
| 1736 |
+
"_view_name": "HBoxView",
|
| 1737 |
+
"box_style": "",
|
| 1738 |
+
"children": [
|
| 1739 |
+
"IPY_MODEL_aea586abd9944cecb932dcf4aaa5beb2",
|
| 1740 |
+
"IPY_MODEL_2665da26142c47089af7ff1c738190a0",
|
| 1741 |
+
"IPY_MODEL_4e8458b164d24b96868063f38ec0fdc6"
|
| 1742 |
+
],
|
| 1743 |
+
"layout": "IPY_MODEL_60277c8e01c5470ebd25b518e697673b",
|
| 1744 |
+
"tabbable": null,
|
| 1745 |
+
"tooltip": null
|
| 1746 |
+
}
|
| 1747 |
+
},
|
| 1748 |
+
"7613ab8cc598400395f1d4e8992f8c78": {
|
| 1749 |
+
"model_module": "@jupyter-widgets/base",
|
| 1750 |
+
"model_module_version": "2.0.0",
|
| 1751 |
+
"model_name": "LayoutModel",
|
| 1752 |
+
"state": {
|
| 1753 |
+
"_model_module": "@jupyter-widgets/base",
|
| 1754 |
+
"_model_module_version": "2.0.0",
|
| 1755 |
+
"_model_name": "LayoutModel",
|
| 1756 |
+
"_view_count": null,
|
| 1757 |
+
"_view_module": "@jupyter-widgets/base",
|
| 1758 |
+
"_view_module_version": "2.0.0",
|
| 1759 |
+
"_view_name": "LayoutView",
|
| 1760 |
+
"align_content": null,
|
| 1761 |
+
"align_items": null,
|
| 1762 |
+
"align_self": null,
|
| 1763 |
+
"border_bottom": null,
|
| 1764 |
+
"border_left": null,
|
| 1765 |
+
"border_right": null,
|
| 1766 |
+
"border_top": null,
|
| 1767 |
+
"bottom": null,
|
| 1768 |
+
"display": null,
|
| 1769 |
+
"flex": null,
|
| 1770 |
+
"flex_flow": null,
|
| 1771 |
+
"grid_area": null,
|
| 1772 |
+
"grid_auto_columns": null,
|
| 1773 |
+
"grid_auto_flow": null,
|
| 1774 |
+
"grid_auto_rows": null,
|
| 1775 |
+
"grid_column": null,
|
| 1776 |
+
"grid_gap": null,
|
| 1777 |
+
"grid_row": null,
|
| 1778 |
+
"grid_template_areas": null,
|
| 1779 |
+
"grid_template_columns": null,
|
| 1780 |
+
"grid_template_rows": null,
|
| 1781 |
+
"height": null,
|
| 1782 |
+
"justify_content": null,
|
| 1783 |
+
"justify_items": null,
|
| 1784 |
+
"left": null,
|
| 1785 |
+
"margin": null,
|
| 1786 |
+
"max_height": null,
|
| 1787 |
+
"max_width": null,
|
| 1788 |
+
"min_height": null,
|
| 1789 |
+
"min_width": null,
|
| 1790 |
+
"object_fit": null,
|
| 1791 |
+
"object_position": null,
|
| 1792 |
+
"order": null,
|
| 1793 |
+
"overflow": null,
|
| 1794 |
+
"padding": null,
|
| 1795 |
+
"right": null,
|
| 1796 |
+
"top": null,
|
| 1797 |
+
"visibility": null,
|
| 1798 |
+
"width": null
|
| 1799 |
+
}
|
| 1800 |
+
},
|
| 1801 |
+
"768c6965b7534d1d8ccb35fe089bf50b": {
|
| 1802 |
+
"model_module": "@jupyter-widgets/base",
|
| 1803 |
+
"model_module_version": "2.0.0",
|
| 1804 |
+
"model_name": "LayoutModel",
|
| 1805 |
+
"state": {
|
| 1806 |
+
"_model_module": "@jupyter-widgets/base",
|
| 1807 |
+
"_model_module_version": "2.0.0",
|
| 1808 |
+
"_model_name": "LayoutModel",
|
| 1809 |
+
"_view_count": null,
|
| 1810 |
+
"_view_module": "@jupyter-widgets/base",
|
| 1811 |
+
"_view_module_version": "2.0.0",
|
| 1812 |
+
"_view_name": "LayoutView",
|
| 1813 |
+
"align_content": null,
|
| 1814 |
+
"align_items": null,
|
| 1815 |
+
"align_self": null,
|
| 1816 |
+
"border_bottom": null,
|
| 1817 |
+
"border_left": null,
|
| 1818 |
+
"border_right": null,
|
| 1819 |
+
"border_top": null,
|
| 1820 |
+
"bottom": null,
|
| 1821 |
+
"display": null,
|
| 1822 |
+
"flex": null,
|
| 1823 |
+
"flex_flow": null,
|
| 1824 |
+
"grid_area": null,
|
| 1825 |
+
"grid_auto_columns": null,
|
| 1826 |
+
"grid_auto_flow": null,
|
| 1827 |
+
"grid_auto_rows": null,
|
| 1828 |
+
"grid_column": null,
|
| 1829 |
+
"grid_gap": null,
|
| 1830 |
+
"grid_row": null,
|
| 1831 |
+
"grid_template_areas": null,
|
| 1832 |
+
"grid_template_columns": null,
|
| 1833 |
+
"grid_template_rows": null,
|
| 1834 |
+
"height": null,
|
| 1835 |
+
"justify_content": null,
|
| 1836 |
+
"justify_items": null,
|
| 1837 |
+
"left": null,
|
| 1838 |
+
"margin": null,
|
| 1839 |
+
"max_height": null,
|
| 1840 |
+
"max_width": null,
|
| 1841 |
+
"min_height": null,
|
| 1842 |
+
"min_width": null,
|
| 1843 |
+
"object_fit": null,
|
| 1844 |
+
"object_position": null,
|
| 1845 |
+
"order": null,
|
| 1846 |
+
"overflow": null,
|
| 1847 |
+
"padding": null,
|
| 1848 |
+
"right": null,
|
| 1849 |
+
"top": null,
|
| 1850 |
+
"visibility": null,
|
| 1851 |
+
"width": null
|
| 1852 |
+
}
|
| 1853 |
+
},
|
| 1854 |
+
"790cc8bb311940a389f911f4b1029065": {
|
| 1855 |
+
"model_module": "@jupyter-widgets/controls",
|
| 1856 |
+
"model_module_version": "2.0.0",
|
| 1857 |
+
"model_name": "HTMLStyleModel",
|
| 1858 |
+
"state": {
|
| 1859 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 1860 |
+
"_model_module_version": "2.0.0",
|
| 1861 |
+
"_model_name": "HTMLStyleModel",
|
| 1862 |
+
"_view_count": null,
|
| 1863 |
+
"_view_module": "@jupyter-widgets/base",
|
| 1864 |
+
"_view_module_version": "2.0.0",
|
| 1865 |
+
"_view_name": "StyleView",
|
| 1866 |
+
"background": null,
|
| 1867 |
+
"description_width": "",
|
| 1868 |
+
"font_size": null,
|
| 1869 |
+
"text_color": null
|
| 1870 |
+
}
|
| 1871 |
+
},
|
| 1872 |
+
"7c283e9474ce4e9f9714a49d4a757f81": {
|
| 1873 |
+
"model_module": "@jupyter-widgets/base",
|
| 1874 |
+
"model_module_version": "2.0.0",
|
| 1875 |
+
"model_name": "LayoutModel",
|
| 1876 |
+
"state": {
|
| 1877 |
+
"_model_module": "@jupyter-widgets/base",
|
| 1878 |
+
"_model_module_version": "2.0.0",
|
| 1879 |
+
"_model_name": "LayoutModel",
|
| 1880 |
+
"_view_count": null,
|
| 1881 |
+
"_view_module": "@jupyter-widgets/base",
|
| 1882 |
+
"_view_module_version": "2.0.0",
|
| 1883 |
+
"_view_name": "LayoutView",
|
| 1884 |
+
"align_content": null,
|
| 1885 |
+
"align_items": null,
|
| 1886 |
+
"align_self": null,
|
| 1887 |
+
"border_bottom": null,
|
| 1888 |
+
"border_left": null,
|
| 1889 |
+
"border_right": null,
|
| 1890 |
+
"border_top": null,
|
| 1891 |
+
"bottom": null,
|
| 1892 |
+
"display": null,
|
| 1893 |
+
"flex": null,
|
| 1894 |
+
"flex_flow": null,
|
| 1895 |
+
"grid_area": null,
|
| 1896 |
+
"grid_auto_columns": null,
|
| 1897 |
+
"grid_auto_flow": null,
|
| 1898 |
+
"grid_auto_rows": null,
|
| 1899 |
+
"grid_column": null,
|
| 1900 |
+
"grid_gap": null,
|
| 1901 |
+
"grid_row": null,
|
| 1902 |
+
"grid_template_areas": null,
|
| 1903 |
+
"grid_template_columns": null,
|
| 1904 |
+
"grid_template_rows": null,
|
| 1905 |
+
"height": null,
|
| 1906 |
+
"justify_content": null,
|
| 1907 |
+
"justify_items": null,
|
| 1908 |
+
"left": null,
|
| 1909 |
+
"margin": null,
|
| 1910 |
+
"max_height": null,
|
| 1911 |
+
"max_width": null,
|
| 1912 |
+
"min_height": null,
|
| 1913 |
+
"min_width": null,
|
| 1914 |
+
"object_fit": null,
|
| 1915 |
+
"object_position": null,
|
| 1916 |
+
"order": null,
|
| 1917 |
+
"overflow": null,
|
| 1918 |
+
"padding": null,
|
| 1919 |
+
"right": null,
|
| 1920 |
+
"top": null,
|
| 1921 |
+
"visibility": null,
|
| 1922 |
+
"width": null
|
| 1923 |
+
}
|
| 1924 |
+
},
|
| 1925 |
+
"7ec51114c76845108ea291a4b8aa1615": {
|
| 1926 |
+
"model_module": "@jupyter-widgets/controls",
|
| 1927 |
+
"model_module_version": "2.0.0",
|
| 1928 |
+
"model_name": "HTMLStyleModel",
|
| 1929 |
+
"state": {
|
| 1930 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 1931 |
+
"_model_module_version": "2.0.0",
|
| 1932 |
+
"_model_name": "HTMLStyleModel",
|
| 1933 |
+
"_view_count": null,
|
| 1934 |
+
"_view_module": "@jupyter-widgets/base",
|
| 1935 |
+
"_view_module_version": "2.0.0",
|
| 1936 |
+
"_view_name": "StyleView",
|
| 1937 |
+
"background": null,
|
| 1938 |
+
"description_width": "",
|
| 1939 |
+
"font_size": null,
|
| 1940 |
+
"text_color": null
|
| 1941 |
+
}
|
| 1942 |
+
},
|
| 1943 |
+
"7eeb9450410d4aafa92cf84293e117d4": {
|
| 1944 |
+
"model_module": "@jupyter-widgets/controls",
|
| 1945 |
+
"model_module_version": "2.0.0",
|
| 1946 |
+
"model_name": "HTMLModel",
|
| 1947 |
+
"state": {
|
| 1948 |
+
"_dom_classes": [],
|
| 1949 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 1950 |
+
"_model_module_version": "2.0.0",
|
| 1951 |
+
"_model_name": "HTMLModel",
|
| 1952 |
+
"_view_count": null,
|
| 1953 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 1954 |
+
"_view_module_version": "2.0.0",
|
| 1955 |
+
"_view_name": "HTMLView",
|
| 1956 |
+
"description": "",
|
| 1957 |
+
"description_allow_html": false,
|
| 1958 |
+
"layout": "IPY_MODEL_fe0b02dba87e4117af98a5428c438353",
|
| 1959 |
+
"placeholder": "",
|
| 1960 |
+
"style": "IPY_MODEL_13329edc4b994296910273e9aaee5927",
|
| 1961 |
+
"tabbable": null,
|
| 1962 |
+
"tooltip": null,
|
| 1963 |
+
"value": "spm.model: 100%"
|
| 1964 |
+
}
|
| 1965 |
+
},
|
| 1966 |
+
"8052618ba58a4b04af69627fc9d74a15": {
|
| 1967 |
+
"model_module": "@jupyter-widgets/base",
|
| 1968 |
+
"model_module_version": "2.0.0",
|
| 1969 |
+
"model_name": "LayoutModel",
|
| 1970 |
+
"state": {
|
| 1971 |
+
"_model_module": "@jupyter-widgets/base",
|
| 1972 |
+
"_model_module_version": "2.0.0",
|
| 1973 |
+
"_model_name": "LayoutModel",
|
| 1974 |
+
"_view_count": null,
|
| 1975 |
+
"_view_module": "@jupyter-widgets/base",
|
| 1976 |
+
"_view_module_version": "2.0.0",
|
| 1977 |
+
"_view_name": "LayoutView",
|
| 1978 |
+
"align_content": null,
|
| 1979 |
+
"align_items": null,
|
| 1980 |
+
"align_self": null,
|
| 1981 |
+
"border_bottom": null,
|
| 1982 |
+
"border_left": null,
|
| 1983 |
+
"border_right": null,
|
| 1984 |
+
"border_top": null,
|
| 1985 |
+
"bottom": null,
|
| 1986 |
+
"display": null,
|
| 1987 |
+
"flex": null,
|
| 1988 |
+
"flex_flow": null,
|
| 1989 |
+
"grid_area": null,
|
| 1990 |
+
"grid_auto_columns": null,
|
| 1991 |
+
"grid_auto_flow": null,
|
| 1992 |
+
"grid_auto_rows": null,
|
| 1993 |
+
"grid_column": null,
|
| 1994 |
+
"grid_gap": null,
|
| 1995 |
+
"grid_row": null,
|
| 1996 |
+
"grid_template_areas": null,
|
| 1997 |
+
"grid_template_columns": null,
|
| 1998 |
+
"grid_template_rows": null,
|
| 1999 |
+
"height": null,
|
| 2000 |
+
"justify_content": null,
|
| 2001 |
+
"justify_items": null,
|
| 2002 |
+
"left": null,
|
| 2003 |
+
"margin": null,
|
| 2004 |
+
"max_height": null,
|
| 2005 |
+
"max_width": null,
|
| 2006 |
+
"min_height": null,
|
| 2007 |
+
"min_width": null,
|
| 2008 |
+
"object_fit": null,
|
| 2009 |
+
"object_position": null,
|
| 2010 |
+
"order": null,
|
| 2011 |
+
"overflow": null,
|
| 2012 |
+
"padding": null,
|
| 2013 |
+
"right": null,
|
| 2014 |
+
"top": null,
|
| 2015 |
+
"visibility": null,
|
| 2016 |
+
"width": null
|
| 2017 |
+
}
|
| 2018 |
+
},
|
| 2019 |
+
"81d6d531b8bf46208b1dbf3a07b3da7b": {
|
| 2020 |
+
"model_module": "@jupyter-widgets/controls",
|
| 2021 |
+
"model_module_version": "2.0.0",
|
| 2022 |
+
"model_name": "HBoxModel",
|
| 2023 |
+
"state": {
|
| 2024 |
+
"_dom_classes": [],
|
| 2025 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 2026 |
+
"_model_module_version": "2.0.0",
|
| 2027 |
+
"_model_name": "HBoxModel",
|
| 2028 |
+
"_view_count": null,
|
| 2029 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 2030 |
+
"_view_module_version": "2.0.0",
|
| 2031 |
+
"_view_name": "HBoxView",
|
| 2032 |
+
"box_style": "",
|
| 2033 |
+
"children": [
|
| 2034 |
+
"IPY_MODEL_d58b8a0aa347441aa1737ebcee58e884",
|
| 2035 |
+
"IPY_MODEL_9979cd0f851f470ea72f3ed91d2b89e6",
|
| 2036 |
+
"IPY_MODEL_1b248f87427b40fd9d2a20b34daa8212"
|
| 2037 |
+
],
|
| 2038 |
+
"layout": "IPY_MODEL_7613ab8cc598400395f1d4e8992f8c78",
|
| 2039 |
+
"tabbable": null,
|
| 2040 |
+
"tooltip": null
|
| 2041 |
+
}
|
| 2042 |
+
},
|
| 2043 |
+
"833aadefad91424ca925275aad2a716c": {
|
| 2044 |
+
"model_module": "@jupyter-widgets/controls",
|
| 2045 |
+
"model_module_version": "2.0.0",
|
| 2046 |
+
"model_name": "ProgressStyleModel",
|
| 2047 |
+
"state": {
|
| 2048 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 2049 |
+
"_model_module_version": "2.0.0",
|
| 2050 |
+
"_model_name": "ProgressStyleModel",
|
| 2051 |
+
"_view_count": null,
|
| 2052 |
+
"_view_module": "@jupyter-widgets/base",
|
| 2053 |
+
"_view_module_version": "2.0.0",
|
| 2054 |
+
"_view_name": "StyleView",
|
| 2055 |
+
"bar_color": null,
|
| 2056 |
+
"description_width": ""
|
| 2057 |
+
}
|
| 2058 |
+
},
|
| 2059 |
+
"8a465a38c1e94d36a2af8f583a958267": {
|
| 2060 |
+
"model_module": "@jupyter-widgets/base",
|
| 2061 |
+
"model_module_version": "2.0.0",
|
| 2062 |
+
"model_name": "LayoutModel",
|
| 2063 |
+
"state": {
|
| 2064 |
+
"_model_module": "@jupyter-widgets/base",
|
| 2065 |
+
"_model_module_version": "2.0.0",
|
| 2066 |
+
"_model_name": "LayoutModel",
|
| 2067 |
+
"_view_count": null,
|
| 2068 |
+
"_view_module": "@jupyter-widgets/base",
|
| 2069 |
+
"_view_module_version": "2.0.0",
|
| 2070 |
+
"_view_name": "LayoutView",
|
| 2071 |
+
"align_content": null,
|
| 2072 |
+
"align_items": null,
|
| 2073 |
+
"align_self": null,
|
| 2074 |
+
"border_bottom": null,
|
| 2075 |
+
"border_left": null,
|
| 2076 |
+
"border_right": null,
|
| 2077 |
+
"border_top": null,
|
| 2078 |
+
"bottom": null,
|
| 2079 |
+
"display": null,
|
| 2080 |
+
"flex": null,
|
| 2081 |
+
"flex_flow": null,
|
| 2082 |
+
"grid_area": null,
|
| 2083 |
+
"grid_auto_columns": null,
|
| 2084 |
+
"grid_auto_flow": null,
|
| 2085 |
+
"grid_auto_rows": null,
|
| 2086 |
+
"grid_column": null,
|
| 2087 |
+
"grid_gap": null,
|
| 2088 |
+
"grid_row": null,
|
| 2089 |
+
"grid_template_areas": null,
|
| 2090 |
+
"grid_template_columns": null,
|
| 2091 |
+
"grid_template_rows": null,
|
| 2092 |
+
"height": null,
|
| 2093 |
+
"justify_content": null,
|
| 2094 |
+
"justify_items": null,
|
| 2095 |
+
"left": null,
|
| 2096 |
+
"margin": null,
|
| 2097 |
+
"max_height": null,
|
| 2098 |
+
"max_width": null,
|
| 2099 |
+
"min_height": null,
|
| 2100 |
+
"min_width": null,
|
| 2101 |
+
"object_fit": null,
|
| 2102 |
+
"object_position": null,
|
| 2103 |
+
"order": null,
|
| 2104 |
+
"overflow": null,
|
| 2105 |
+
"padding": null,
|
| 2106 |
+
"right": null,
|
| 2107 |
+
"top": null,
|
| 2108 |
+
"visibility": null,
|
| 2109 |
+
"width": null
|
| 2110 |
+
}
|
| 2111 |
+
},
|
| 2112 |
+
"8bd6257607ab4c369b253a2269ad3adc": {
|
| 2113 |
+
"model_module": "@jupyter-widgets/controls",
|
| 2114 |
+
"model_module_version": "2.0.0",
|
| 2115 |
+
"model_name": "ProgressStyleModel",
|
| 2116 |
+
"state": {
|
| 2117 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 2118 |
+
"_model_module_version": "2.0.0",
|
| 2119 |
+
"_model_name": "ProgressStyleModel",
|
| 2120 |
+
"_view_count": null,
|
| 2121 |
+
"_view_module": "@jupyter-widgets/base",
|
| 2122 |
+
"_view_module_version": "2.0.0",
|
| 2123 |
+
"_view_name": "StyleView",
|
| 2124 |
+
"bar_color": null,
|
| 2125 |
+
"description_width": ""
|
| 2126 |
+
}
|
| 2127 |
+
},
|
| 2128 |
+
"8e8a0f67ae074b16b788d6a885f766c4": {
|
| 2129 |
+
"model_module": "@jupyter-widgets/controls",
|
| 2130 |
+
"model_module_version": "2.0.0",
|
| 2131 |
+
"model_name": "HTMLStyleModel",
|
| 2132 |
+
"state": {
|
| 2133 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 2134 |
+
"_model_module_version": "2.0.0",
|
| 2135 |
+
"_model_name": "HTMLStyleModel",
|
| 2136 |
+
"_view_count": null,
|
| 2137 |
+
"_view_module": "@jupyter-widgets/base",
|
| 2138 |
+
"_view_module_version": "2.0.0",
|
| 2139 |
+
"_view_name": "StyleView",
|
| 2140 |
+
"background": null,
|
| 2141 |
+
"description_width": "",
|
| 2142 |
+
"font_size": null,
|
| 2143 |
+
"text_color": null
|
| 2144 |
+
}
|
| 2145 |
+
},
|
| 2146 |
+
"95dc73ea287e4f65b5b9c2184828b60a": {
|
| 2147 |
+
"model_module": "@jupyter-widgets/controls",
|
| 2148 |
+
"model_module_version": "2.0.0",
|
| 2149 |
+
"model_name": "HBoxModel",
|
| 2150 |
+
"state": {
|
| 2151 |
+
"_dom_classes": [],
|
| 2152 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 2153 |
+
"_model_module_version": "2.0.0",
|
| 2154 |
+
"_model_name": "HBoxModel",
|
| 2155 |
+
"_view_count": null,
|
| 2156 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 2157 |
+
"_view_module_version": "2.0.0",
|
| 2158 |
+
"_view_name": "HBoxView",
|
| 2159 |
+
"box_style": "",
|
| 2160 |
+
"children": [
|
| 2161 |
+
"IPY_MODEL_0c2f17627c384d54b7740b5d6b4d8c00",
|
| 2162 |
+
"IPY_MODEL_e84365e096464a688a6e3a824a462f65",
|
| 2163 |
+
"IPY_MODEL_cd29d19617be4e6dbb730857a5d4030c"
|
| 2164 |
+
],
|
| 2165 |
+
"layout": "IPY_MODEL_afff59a6af90408db2bbe5e647d939a7",
|
| 2166 |
+
"tabbable": null,
|
| 2167 |
+
"tooltip": null
|
| 2168 |
+
}
|
| 2169 |
+
},
|
| 2170 |
+
"9979cd0f851f470ea72f3ed91d2b89e6": {
|
| 2171 |
+
"model_module": "@jupyter-widgets/controls",
|
| 2172 |
+
"model_module_version": "2.0.0",
|
| 2173 |
+
"model_name": "FloatProgressModel",
|
| 2174 |
+
"state": {
|
| 2175 |
+
"_dom_classes": [],
|
| 2176 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 2177 |
+
"_model_module_version": "2.0.0",
|
| 2178 |
+
"_model_name": "FloatProgressModel",
|
| 2179 |
+
"_view_count": null,
|
| 2180 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 2181 |
+
"_view_module_version": "2.0.0",
|
| 2182 |
+
"_view_name": "ProgressView",
|
| 2183 |
+
"bar_style": "success",
|
| 2184 |
+
"description": "",
|
| 2185 |
+
"description_allow_html": false,
|
| 2186 |
+
"layout": "IPY_MODEL_e57bc4f765c04aec8cbe5a3dc6ee2048",
|
| 2187 |
+
"max": 52.0,
|
| 2188 |
+
"min": 0.0,
|
| 2189 |
+
"orientation": "horizontal",
|
| 2190 |
+
"style": "IPY_MODEL_833aadefad91424ca925275aad2a716c",
|
| 2191 |
+
"tabbable": null,
|
| 2192 |
+
"tooltip": null,
|
| 2193 |
+
"value": 52.0
|
| 2194 |
+
}
|
| 2195 |
+
},
|
| 2196 |
+
"aa86e9fdb7d6460195b07e152a1c7745": {
|
| 2197 |
+
"model_module": "@jupyter-widgets/base",
|
| 2198 |
+
"model_module_version": "2.0.0",
|
| 2199 |
+
"model_name": "LayoutModel",
|
| 2200 |
+
"state": {
|
| 2201 |
+
"_model_module": "@jupyter-widgets/base",
|
| 2202 |
+
"_model_module_version": "2.0.0",
|
| 2203 |
+
"_model_name": "LayoutModel",
|
| 2204 |
+
"_view_count": null,
|
| 2205 |
+
"_view_module": "@jupyter-widgets/base",
|
| 2206 |
+
"_view_module_version": "2.0.0",
|
| 2207 |
+
"_view_name": "LayoutView",
|
| 2208 |
+
"align_content": null,
|
| 2209 |
+
"align_items": null,
|
| 2210 |
+
"align_self": null,
|
| 2211 |
+
"border_bottom": null,
|
| 2212 |
+
"border_left": null,
|
| 2213 |
+
"border_right": null,
|
| 2214 |
+
"border_top": null,
|
| 2215 |
+
"bottom": null,
|
| 2216 |
+
"display": null,
|
| 2217 |
+
"flex": null,
|
| 2218 |
+
"flex_flow": null,
|
| 2219 |
+
"grid_area": null,
|
| 2220 |
+
"grid_auto_columns": null,
|
| 2221 |
+
"grid_auto_flow": null,
|
| 2222 |
+
"grid_auto_rows": null,
|
| 2223 |
+
"grid_column": null,
|
| 2224 |
+
"grid_gap": null,
|
| 2225 |
+
"grid_row": null,
|
| 2226 |
+
"grid_template_areas": null,
|
| 2227 |
+
"grid_template_columns": null,
|
| 2228 |
+
"grid_template_rows": null,
|
| 2229 |
+
"height": null,
|
| 2230 |
+
"justify_content": null,
|
| 2231 |
+
"justify_items": null,
|
| 2232 |
+
"left": null,
|
| 2233 |
+
"margin": null,
|
| 2234 |
+
"max_height": null,
|
| 2235 |
+
"max_width": null,
|
| 2236 |
+
"min_height": null,
|
| 2237 |
+
"min_width": null,
|
| 2238 |
+
"object_fit": null,
|
| 2239 |
+
"object_position": null,
|
| 2240 |
+
"order": null,
|
| 2241 |
+
"overflow": null,
|
| 2242 |
+
"padding": null,
|
| 2243 |
+
"right": null,
|
| 2244 |
+
"top": null,
|
| 2245 |
+
"visibility": null,
|
| 2246 |
+
"width": null
|
| 2247 |
+
}
|
| 2248 |
+
},
|
| 2249 |
+
"aea586abd9944cecb932dcf4aaa5beb2": {
|
| 2250 |
+
"model_module": "@jupyter-widgets/controls",
|
| 2251 |
+
"model_module_version": "2.0.0",
|
| 2252 |
+
"model_name": "HTMLModel",
|
| 2253 |
+
"state": {
|
| 2254 |
+
"_dom_classes": [],
|
| 2255 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 2256 |
+
"_model_module_version": "2.0.0",
|
| 2257 |
+
"_model_name": "HTMLModel",
|
| 2258 |
+
"_view_count": null,
|
| 2259 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 2260 |
+
"_view_module_version": "2.0.0",
|
| 2261 |
+
"_view_name": "HTMLView",
|
| 2262 |
+
"description": "",
|
| 2263 |
+
"description_allow_html": false,
|
| 2264 |
+
"layout": "IPY_MODEL_b2af5a48a55e474da4dc334906881b67",
|
| 2265 |
+
"placeholder": "",
|
| 2266 |
+
"style": "IPY_MODEL_790cc8bb311940a389f911f4b1029065",
|
| 2267 |
+
"tabbable": null,
|
| 2268 |
+
"tooltip": null,
|
| 2269 |
+
"value": "pytorch_model.bin: 100%"
|
| 2270 |
+
}
|
| 2271 |
+
},
|
| 2272 |
+
"afff59a6af90408db2bbe5e647d939a7": {
|
| 2273 |
+
"model_module": "@jupyter-widgets/base",
|
| 2274 |
+
"model_module_version": "2.0.0",
|
| 2275 |
+
"model_name": "LayoutModel",
|
| 2276 |
+
"state": {
|
| 2277 |
+
"_model_module": "@jupyter-widgets/base",
|
| 2278 |
+
"_model_module_version": "2.0.0",
|
| 2279 |
+
"_model_name": "LayoutModel",
|
| 2280 |
+
"_view_count": null,
|
| 2281 |
+
"_view_module": "@jupyter-widgets/base",
|
| 2282 |
+
"_view_module_version": "2.0.0",
|
| 2283 |
+
"_view_name": "LayoutView",
|
| 2284 |
+
"align_content": null,
|
| 2285 |
+
"align_items": null,
|
| 2286 |
+
"align_self": null,
|
| 2287 |
+
"border_bottom": null,
|
| 2288 |
+
"border_left": null,
|
| 2289 |
+
"border_right": null,
|
| 2290 |
+
"border_top": null,
|
| 2291 |
+
"bottom": null,
|
| 2292 |
+
"display": null,
|
| 2293 |
+
"flex": null,
|
| 2294 |
+
"flex_flow": null,
|
| 2295 |
+
"grid_area": null,
|
| 2296 |
+
"grid_auto_columns": null,
|
| 2297 |
+
"grid_auto_flow": null,
|
| 2298 |
+
"grid_auto_rows": null,
|
| 2299 |
+
"grid_column": null,
|
| 2300 |
+
"grid_gap": null,
|
| 2301 |
+
"grid_row": null,
|
| 2302 |
+
"grid_template_areas": null,
|
| 2303 |
+
"grid_template_columns": null,
|
| 2304 |
+
"grid_template_rows": null,
|
| 2305 |
+
"height": null,
|
| 2306 |
+
"justify_content": null,
|
| 2307 |
+
"justify_items": null,
|
| 2308 |
+
"left": null,
|
| 2309 |
+
"margin": null,
|
| 2310 |
+
"max_height": null,
|
| 2311 |
+
"max_width": null,
|
| 2312 |
+
"min_height": null,
|
| 2313 |
+
"min_width": null,
|
| 2314 |
+
"object_fit": null,
|
| 2315 |
+
"object_position": null,
|
| 2316 |
+
"order": null,
|
| 2317 |
+
"overflow": null,
|
| 2318 |
+
"padding": null,
|
| 2319 |
+
"right": null,
|
| 2320 |
+
"top": null,
|
| 2321 |
+
"visibility": null,
|
| 2322 |
+
"width": null
|
| 2323 |
+
}
|
| 2324 |
+
},
|
| 2325 |
+
"b2af5a48a55e474da4dc334906881b67": {
|
| 2326 |
+
"model_module": "@jupyter-widgets/base",
|
| 2327 |
+
"model_module_version": "2.0.0",
|
| 2328 |
+
"model_name": "LayoutModel",
|
| 2329 |
+
"state": {
|
| 2330 |
+
"_model_module": "@jupyter-widgets/base",
|
| 2331 |
+
"_model_module_version": "2.0.0",
|
| 2332 |
+
"_model_name": "LayoutModel",
|
| 2333 |
+
"_view_count": null,
|
| 2334 |
+
"_view_module": "@jupyter-widgets/base",
|
| 2335 |
+
"_view_module_version": "2.0.0",
|
| 2336 |
+
"_view_name": "LayoutView",
|
| 2337 |
+
"align_content": null,
|
| 2338 |
+
"align_items": null,
|
| 2339 |
+
"align_self": null,
|
| 2340 |
+
"border_bottom": null,
|
| 2341 |
+
"border_left": null,
|
| 2342 |
+
"border_right": null,
|
| 2343 |
+
"border_top": null,
|
| 2344 |
+
"bottom": null,
|
| 2345 |
+
"display": null,
|
| 2346 |
+
"flex": null,
|
| 2347 |
+
"flex_flow": null,
|
| 2348 |
+
"grid_area": null,
|
| 2349 |
+
"grid_auto_columns": null,
|
| 2350 |
+
"grid_auto_flow": null,
|
| 2351 |
+
"grid_auto_rows": null,
|
| 2352 |
+
"grid_column": null,
|
| 2353 |
+
"grid_gap": null,
|
| 2354 |
+
"grid_row": null,
|
| 2355 |
+
"grid_template_areas": null,
|
| 2356 |
+
"grid_template_columns": null,
|
| 2357 |
+
"grid_template_rows": null,
|
| 2358 |
+
"height": null,
|
| 2359 |
+
"justify_content": null,
|
| 2360 |
+
"justify_items": null,
|
| 2361 |
+
"left": null,
|
| 2362 |
+
"margin": null,
|
| 2363 |
+
"max_height": null,
|
| 2364 |
+
"max_width": null,
|
| 2365 |
+
"min_height": null,
|
| 2366 |
+
"min_width": null,
|
| 2367 |
+
"object_fit": null,
|
| 2368 |
+
"object_position": null,
|
| 2369 |
+
"order": null,
|
| 2370 |
+
"overflow": null,
|
| 2371 |
+
"padding": null,
|
| 2372 |
+
"right": null,
|
| 2373 |
+
"top": null,
|
| 2374 |
+
"visibility": null,
|
| 2375 |
+
"width": null
|
| 2376 |
+
}
|
| 2377 |
+
},
|
| 2378 |
+
"c44f21b446fd40b4a14e7b04cae081d3": {
|
| 2379 |
+
"model_module": "@jupyter-widgets/controls",
|
| 2380 |
+
"model_module_version": "2.0.0",
|
| 2381 |
+
"model_name": "HTMLModel",
|
| 2382 |
+
"state": {
|
| 2383 |
+
"_dom_classes": [],
|
| 2384 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 2385 |
+
"_model_module_version": "2.0.0",
|
| 2386 |
+
"_model_name": "HTMLModel",
|
| 2387 |
+
"_view_count": null,
|
| 2388 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 2389 |
+
"_view_module_version": "2.0.0",
|
| 2390 |
+
"_view_name": "HTMLView",
|
| 2391 |
+
"description": "",
|
| 2392 |
+
"description_allow_html": false,
|
| 2393 |
+
"layout": "IPY_MODEL_f531b091335c4579b84c1668863e5027",
|
| 2394 |
+
"placeholder": "",
|
| 2395 |
+
"style": "IPY_MODEL_3e27e692245e43b48bb726571b1597a7",
|
| 2396 |
+
"tabbable": null,
|
| 2397 |
+
"tooltip": null,
|
| 2398 |
+
"value": " 2.46M/2.46M [00:00<00:00, 38.4MB/s]"
|
| 2399 |
+
}
|
| 2400 |
+
},
|
| 2401 |
+
"cd29d19617be4e6dbb730857a5d4030c": {
|
| 2402 |
+
"model_module": "@jupyter-widgets/controls",
|
| 2403 |
+
"model_module_version": "2.0.0",
|
| 2404 |
+
"model_name": "HTMLModel",
|
| 2405 |
+
"state": {
|
| 2406 |
+
"_dom_classes": [],
|
| 2407 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 2408 |
+
"_model_module_version": "2.0.0",
|
| 2409 |
+
"_model_name": "HTMLModel",
|
| 2410 |
+
"_view_count": null,
|
| 2411 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 2412 |
+
"_view_module_version": "2.0.0",
|
| 2413 |
+
"_view_name": "HTMLView",
|
| 2414 |
+
"description": "",
|
| 2415 |
+
"description_allow_html": false,
|
| 2416 |
+
"layout": "IPY_MODEL_8052618ba58a4b04af69627fc9d74a15",
|
| 2417 |
+
"placeholder": "",
|
| 2418 |
+
"style": "IPY_MODEL_7ec51114c76845108ea291a4b8aa1615",
|
| 2419 |
+
"tabbable": null,
|
| 2420 |
+
"tooltip": null,
|
| 2421 |
+
"value": " 580/580 [00:00<00:00, 54.5kB/s]"
|
| 2422 |
+
}
|
| 2423 |
+
},
|
| 2424 |
+
"d58b8a0aa347441aa1737ebcee58e884": {
|
| 2425 |
+
"model_module": "@jupyter-widgets/controls",
|
| 2426 |
+
"model_module_version": "2.0.0",
|
| 2427 |
+
"model_name": "HTMLModel",
|
| 2428 |
+
"state": {
|
| 2429 |
+
"_dom_classes": [],
|
| 2430 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 2431 |
+
"_model_module_version": "2.0.0",
|
| 2432 |
+
"_model_name": "HTMLModel",
|
| 2433 |
+
"_view_count": null,
|
| 2434 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 2435 |
+
"_view_module_version": "2.0.0",
|
| 2436 |
+
"_view_name": "HTMLView",
|
| 2437 |
+
"description": "",
|
| 2438 |
+
"description_allow_html": false,
|
| 2439 |
+
"layout": "IPY_MODEL_6f21b41c52df41349eba0aa25febd60e",
|
| 2440 |
+
"placeholder": "",
|
| 2441 |
+
"style": "IPY_MODEL_8e8a0f67ae074b16b788d6a885f766c4",
|
| 2442 |
+
"tabbable": null,
|
| 2443 |
+
"tooltip": null,
|
| 2444 |
+
"value": "tokenizer_config.json: 100%"
|
| 2445 |
+
}
|
| 2446 |
+
},
|
| 2447 |
+
"d806a930970242538bba98b4c8b1e2db": {
|
| 2448 |
+
"model_module": "@jupyter-widgets/controls",
|
| 2449 |
+
"model_module_version": "2.0.0",
|
| 2450 |
+
"model_name": "ProgressStyleModel",
|
| 2451 |
+
"state": {
|
| 2452 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 2453 |
+
"_model_module_version": "2.0.0",
|
| 2454 |
+
"_model_name": "ProgressStyleModel",
|
| 2455 |
+
"_view_count": null,
|
| 2456 |
+
"_view_module": "@jupyter-widgets/base",
|
| 2457 |
+
"_view_module_version": "2.0.0",
|
| 2458 |
+
"_view_name": "StyleView",
|
| 2459 |
+
"bar_color": null,
|
| 2460 |
+
"description_width": ""
|
| 2461 |
+
}
|
| 2462 |
+
},
|
| 2463 |
+
"e57bc4f765c04aec8cbe5a3dc6ee2048": {
|
| 2464 |
+
"model_module": "@jupyter-widgets/base",
|
| 2465 |
+
"model_module_version": "2.0.0",
|
| 2466 |
+
"model_name": "LayoutModel",
|
| 2467 |
+
"state": {
|
| 2468 |
+
"_model_module": "@jupyter-widgets/base",
|
| 2469 |
+
"_model_module_version": "2.0.0",
|
| 2470 |
+
"_model_name": "LayoutModel",
|
| 2471 |
+
"_view_count": null,
|
| 2472 |
+
"_view_module": "@jupyter-widgets/base",
|
| 2473 |
+
"_view_module_version": "2.0.0",
|
| 2474 |
+
"_view_name": "LayoutView",
|
| 2475 |
+
"align_content": null,
|
| 2476 |
+
"align_items": null,
|
| 2477 |
+
"align_self": null,
|
| 2478 |
+
"border_bottom": null,
|
| 2479 |
+
"border_left": null,
|
| 2480 |
+
"border_right": null,
|
| 2481 |
+
"border_top": null,
|
| 2482 |
+
"bottom": null,
|
| 2483 |
+
"display": null,
|
| 2484 |
+
"flex": null,
|
| 2485 |
+
"flex_flow": null,
|
| 2486 |
+
"grid_area": null,
|
| 2487 |
+
"grid_auto_columns": null,
|
| 2488 |
+
"grid_auto_flow": null,
|
| 2489 |
+
"grid_auto_rows": null,
|
| 2490 |
+
"grid_column": null,
|
| 2491 |
+
"grid_gap": null,
|
| 2492 |
+
"grid_row": null,
|
| 2493 |
+
"grid_template_areas": null,
|
| 2494 |
+
"grid_template_columns": null,
|
| 2495 |
+
"grid_template_rows": null,
|
| 2496 |
+
"height": null,
|
| 2497 |
+
"justify_content": null,
|
| 2498 |
+
"justify_items": null,
|
| 2499 |
+
"left": null,
|
| 2500 |
+
"margin": null,
|
| 2501 |
+
"max_height": null,
|
| 2502 |
+
"max_width": null,
|
| 2503 |
+
"min_height": null,
|
| 2504 |
+
"min_width": null,
|
| 2505 |
+
"object_fit": null,
|
| 2506 |
+
"object_position": null,
|
| 2507 |
+
"order": null,
|
| 2508 |
+
"overflow": null,
|
| 2509 |
+
"padding": null,
|
| 2510 |
+
"right": null,
|
| 2511 |
+
"top": null,
|
| 2512 |
+
"visibility": null,
|
| 2513 |
+
"width": null
|
| 2514 |
+
}
|
| 2515 |
+
},
|
| 2516 |
+
"e84365e096464a688a6e3a824a462f65": {
|
| 2517 |
+
"model_module": "@jupyter-widgets/controls",
|
| 2518 |
+
"model_module_version": "2.0.0",
|
| 2519 |
+
"model_name": "FloatProgressModel",
|
| 2520 |
+
"state": {
|
| 2521 |
+
"_dom_classes": [],
|
| 2522 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 2523 |
+
"_model_module_version": "2.0.0",
|
| 2524 |
+
"_model_name": "FloatProgressModel",
|
| 2525 |
+
"_view_count": null,
|
| 2526 |
+
"_view_module": "@jupyter-widgets/controls",
|
| 2527 |
+
"_view_module_version": "2.0.0",
|
| 2528 |
+
"_view_name": "ProgressView",
|
| 2529 |
+
"bar_style": "success",
|
| 2530 |
+
"description": "",
|
| 2531 |
+
"description_allow_html": false,
|
| 2532 |
+
"layout": "IPY_MODEL_aa86e9fdb7d6460195b07e152a1c7745",
|
| 2533 |
+
"max": 580.0,
|
| 2534 |
+
"min": 0.0,
|
| 2535 |
+
"orientation": "horizontal",
|
| 2536 |
+
"style": "IPY_MODEL_8bd6257607ab4c369b253a2269ad3adc",
|
| 2537 |
+
"tabbable": null,
|
| 2538 |
+
"tooltip": null,
|
| 2539 |
+
"value": 580.0
|
| 2540 |
+
}
|
| 2541 |
+
},
|
| 2542 |
+
"f531b091335c4579b84c1668863e5027": {
|
| 2543 |
+
"model_module": "@jupyter-widgets/base",
|
| 2544 |
+
"model_module_version": "2.0.0",
|
| 2545 |
+
"model_name": "LayoutModel",
|
| 2546 |
+
"state": {
|
| 2547 |
+
"_model_module": "@jupyter-widgets/base",
|
| 2548 |
+
"_model_module_version": "2.0.0",
|
| 2549 |
+
"_model_name": "LayoutModel",
|
| 2550 |
+
"_view_count": null,
|
| 2551 |
+
"_view_module": "@jupyter-widgets/base",
|
| 2552 |
+
"_view_module_version": "2.0.0",
|
| 2553 |
+
"_view_name": "LayoutView",
|
| 2554 |
+
"align_content": null,
|
| 2555 |
+
"align_items": null,
|
| 2556 |
+
"align_self": null,
|
| 2557 |
+
"border_bottom": null,
|
| 2558 |
+
"border_left": null,
|
| 2559 |
+
"border_right": null,
|
| 2560 |
+
"border_top": null,
|
| 2561 |
+
"bottom": null,
|
| 2562 |
+
"display": null,
|
| 2563 |
+
"flex": null,
|
| 2564 |
+
"flex_flow": null,
|
| 2565 |
+
"grid_area": null,
|
| 2566 |
+
"grid_auto_columns": null,
|
| 2567 |
+
"grid_auto_flow": null,
|
| 2568 |
+
"grid_auto_rows": null,
|
| 2569 |
+
"grid_column": null,
|
| 2570 |
+
"grid_gap": null,
|
| 2571 |
+
"grid_row": null,
|
| 2572 |
+
"grid_template_areas": null,
|
| 2573 |
+
"grid_template_columns": null,
|
| 2574 |
+
"grid_template_rows": null,
|
| 2575 |
+
"height": null,
|
| 2576 |
+
"justify_content": null,
|
| 2577 |
+
"justify_items": null,
|
| 2578 |
+
"left": null,
|
| 2579 |
+
"margin": null,
|
| 2580 |
+
"max_height": null,
|
| 2581 |
+
"max_width": null,
|
| 2582 |
+
"min_height": null,
|
| 2583 |
+
"min_width": null,
|
| 2584 |
+
"object_fit": null,
|
| 2585 |
+
"object_position": null,
|
| 2586 |
+
"order": null,
|
| 2587 |
+
"overflow": null,
|
| 2588 |
+
"padding": null,
|
| 2589 |
+
"right": null,
|
| 2590 |
+
"top": null,
|
| 2591 |
+
"visibility": null,
|
| 2592 |
+
"width": null
|
| 2593 |
+
}
|
| 2594 |
+
},
|
| 2595 |
+
"fd999dd7a0b942e898fa6ef2a4c6a981": {
|
| 2596 |
+
"model_module": "@jupyter-widgets/controls",
|
| 2597 |
+
"model_module_version": "2.0.0",
|
| 2598 |
+
"model_name": "HTMLStyleModel",
|
| 2599 |
+
"state": {
|
| 2600 |
+
"_model_module": "@jupyter-widgets/controls",
|
| 2601 |
+
"_model_module_version": "2.0.0",
|
| 2602 |
+
"_model_name": "HTMLStyleModel",
|
| 2603 |
+
"_view_count": null,
|
| 2604 |
+
"_view_module": "@jupyter-widgets/base",
|
| 2605 |
+
"_view_module_version": "2.0.0",
|
| 2606 |
+
"_view_name": "StyleView",
|
| 2607 |
+
"background": null,
|
| 2608 |
+
"description_width": "",
|
| 2609 |
+
"font_size": null,
|
| 2610 |
+
"text_color": null
|
| 2611 |
+
}
|
| 2612 |
+
},
|
| 2613 |
+
"fe0b02dba87e4117af98a5428c438353": {
|
| 2614 |
+
"model_module": "@jupyter-widgets/base",
|
| 2615 |
+
"model_module_version": "2.0.0",
|
| 2616 |
+
"model_name": "LayoutModel",
|
| 2617 |
+
"state": {
|
| 2618 |
+
"_model_module": "@jupyter-widgets/base",
|
| 2619 |
+
"_model_module_version": "2.0.0",
|
| 2620 |
+
"_model_name": "LayoutModel",
|
| 2621 |
+
"_view_count": null,
|
| 2622 |
+
"_view_module": "@jupyter-widgets/base",
|
| 2623 |
+
"_view_module_version": "2.0.0",
|
| 2624 |
+
"_view_name": "LayoutView",
|
| 2625 |
+
"align_content": null,
|
| 2626 |
+
"align_items": null,
|
| 2627 |
+
"align_self": null,
|
| 2628 |
+
"border_bottom": null,
|
| 2629 |
+
"border_left": null,
|
| 2630 |
+
"border_right": null,
|
| 2631 |
+
"border_top": null,
|
| 2632 |
+
"bottom": null,
|
| 2633 |
+
"display": null,
|
| 2634 |
+
"flex": null,
|
| 2635 |
+
"flex_flow": null,
|
| 2636 |
+
"grid_area": null,
|
| 2637 |
+
"grid_auto_columns": null,
|
| 2638 |
+
"grid_auto_flow": null,
|
| 2639 |
+
"grid_auto_rows": null,
|
| 2640 |
+
"grid_column": null,
|
| 2641 |
+
"grid_gap": null,
|
| 2642 |
+
"grid_row": null,
|
| 2643 |
+
"grid_template_areas": null,
|
| 2644 |
+
"grid_template_columns": null,
|
| 2645 |
+
"grid_template_rows": null,
|
| 2646 |
+
"height": null,
|
| 2647 |
+
"justify_content": null,
|
| 2648 |
+
"justify_items": null,
|
| 2649 |
+
"left": null,
|
| 2650 |
+
"margin": null,
|
| 2651 |
+
"max_height": null,
|
| 2652 |
+
"max_width": null,
|
| 2653 |
+
"min_height": null,
|
| 2654 |
+
"min_width": null,
|
| 2655 |
+
"object_fit": null,
|
| 2656 |
+
"object_position": null,
|
| 2657 |
+
"order": null,
|
| 2658 |
+
"overflow": null,
|
| 2659 |
+
"padding": null,
|
| 2660 |
+
"right": null,
|
| 2661 |
+
"top": null,
|
| 2662 |
+
"visibility": null,
|
| 2663 |
+
"width": null
|
| 2664 |
+
}
|
| 2665 |
+
}
|
| 2666 |
+
},
|
| 2667 |
+
"version_major": 2,
|
| 2668 |
+
"version_minor": 0
|
| 2669 |
+
}
|
| 2670 |
+
}
|
| 2671 |
+
},
|
| 2672 |
+
"nbformat": 4,
|
| 2673 |
+
"nbformat_minor": 5
|
| 2674 |
+
}
|
data/distorted.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/distorted_v2.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/distortion.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/distortion_processed.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
distortion-MRC-extraction.ipynb
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"gpu","dataSources":[{"sourceType":"datasetVersion","sourceId":5807888,"datasetId":3335974,"databundleVersionId":5884620},{"sourceType":"datasetVersion","sourceId":11282395,"datasetId":7053929,"databundleVersionId":11701009},{"sourceType":"datasetVersion","sourceId":11282071,"datasetId":7053688,"databundleVersionId":11700642},{"sourceType":"datasetVersion","sourceId":11280450,"datasetId":7052486,"databundleVersionId":11698796}],"dockerImageVersionId":30919,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\n\ndf = pd.read_csv('/kaggle/input/d-qa-v3/distortion_processed.csv')\n\ndf['Question']=\"What is the distorted part?\"\n\nimport re\n\ndef find_answer_start(context, answer):\n match = re.search(re.escape(answer.strip()), context)\n return match.start() if match else -1\n\n# Chuyển đổi DataFrame thành định dạng cho mô hình QA\nquestions = df[\"Question\"].tolist()\ncontexts = df[\"Patient Question\"].tolist()\nanswer_ = df[\"processed_substrings\"].tolist()\n\nanswers = []\nfor i, row in df.iterrows():\n if pd.isna(row[\"processed_substrings\"]): # Không có câu trả lời\n answer = {\"text\": [\"\"], \"answer_start\": [-1]} \n else:\n start_idx = find_answer_start(row[\"Patient Question\"], answer_[i])\n answer = {\n \"text\": [row[\"processed_substrings\"]],\n \"answer_start\": [start_idx]\n }\n answers.append(answer)\n\n\n\n# Tạo dataset theo định dạng của Hugging Face\nqa_data = {\n \"distortion\": df[\"Dominant Distortion\"].tolist(),\n \"question\": questions,\n \"context\": df[\"Patient Question\"].tolist(),\n \"answers\": answers\n}\n\n#Chuyển sang Dataset của Hugging Face\nfrom datasets import Dataset\ndataset = Dataset.from_dict(qa_data)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-09T02:49:04.123373Z","iopub.execute_input":"2026-04-09T02:49:04.123801Z","iopub.status.idle":"2026-04-09T02:49:07.702176Z","shell.execute_reply.started":"2026-04-09T02:49:04.123770Z","shell.execute_reply":"2026-04-09T02:49:07.701266Z"}},"outputs":[],"execution_count":1},{"cell_type":"code","source":"# dataset = dataset.train_test_split(test_size=0.2, seed=42)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-09T02:49:07.703325Z","iopub.execute_input":"2026-04-09T02:49:07.703649Z","iopub.status.idle":"2026-04-09T02:49:07.707440Z","shell.execute_reply.started":"2026-04-09T02:49:07.703626Z","shell.execute_reply":"2026-04-09T02:49:07.706400Z"}},"outputs":[],"execution_count":2},{"cell_type":"code","source":"# dataset","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-09T02:49:07.709576Z","iopub.execute_input":"2026-04-09T02:49:07.709829Z","iopub.status.idle":"2026-04-09T02:49:07.735105Z","shell.execute_reply.started":"2026-04-09T02:49:07.709809Z","shell.execute_reply":"2026-04-09T02:49:07.734071Z"}},"outputs":[],"execution_count":3},{"cell_type":"code","source":"def predict_answer(question, context):\n # Tokenize with overflow & offset mapping\n inputs = tokenizer(\n question,\n context,\n return_tensors=\"pt\",\n max_length=512,\n truncation=\"only_second\",\n stride=256,\n return_overflowing_tokens=True,\n return_offsets_mapping=True,\n padding=\"max_length\",\n )\n\n # Pop những thông tin không phải input cho model\n offset_mapping = inputs.pop(\"offset_mapping\")\n overflow_mapping = inputs.pop(\"overflow_to_sample_mapping\")\n\n input_ids = inputs[\"input_ids\"]\n # print(\"Số đoạn context:\", input_ids.shape[0])\n inputs = {k: v.to(device) for k, v in inputs.items()}\n\n with torch.no_grad():\n outputs = model(**inputs)\n\n start_logits = outputs.start_logits\n end_logits = outputs.end_logits\n\n best_score = float('-inf')\n best_answer = \"\"\n\n for i in range(len(start_logits)):\n start_logit = start_logits[i]\n end_logit = end_logits[i]\n offsets = offset_mapping[i]\n\n start_index = torch.argmax(start_logit).item()\n end_index = torch.argmax(end_logit).item()\n\n # Kiểm tra chỉ số có hợp lệ không\n if (\n start_index >= len(offsets)\n or end_index >= len(offsets)\n or offsets[start_index] is None\n or offsets[end_index] is None\n ):\n continue\n\n start_char = offsets[start_index][0]\n end_char = offsets[end_index][1]\n\n score = start_logit[start_index] + end_logit[end_index]\n # print(score)\n if score > best_score and start_char < end_char:\n best_score = score\n best_answer = context[start_char:end_char]\n\n return best_answer","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-09T02:49:07.736360Z","iopub.execute_input":"2026-04-09T02:49:07.736718Z","iopub.status.idle":"2026-04-09T02:49:07.762185Z","shell.execute_reply.started":"2026-04-09T02:49:07.736682Z","shell.execute_reply":"2026-04-09T02:49:07.761018Z"}},"outputs":[],"execution_count":4},{"cell_type":"code","source":"from collections import Counter\nimport string\n\n# Hàm tính toán Exact Match và F1 (như đã trình bày trước đó)\ndef calculate_exact_match(predictions, ground_truths):\n exact_match = 0\n for pred, truth in zip(predictions, ground_truths):\n if pred.strip().lower() == truth.strip().lower():\n exact_match += 1\n return exact_match / len(predictions)\n\ndef calculate_f1_score(predictions, ground_truths):\n def f1(pred, truth):\n pred_tokens = normalize_text(pred).split()\n truth_tokens = normalize_text(truth).split()\n\n # Trường hợp cả hai chuỗi đều rỗng\n if not pred_tokens and not truth_tokens:\n return 1.0 # Có thể cho là F1 score hoàn hảo trong trường hợp này\n\n common_tokens = Counter(pred_tokens) & Counter(truth_tokens)\n num_common = sum(common_tokens.values())\n\n if num_common == 0:\n return 0.0 # Trả về giá trị 0 nếu không có sự giao nhau\n\n precision = num_common / len(pred_tokens) if len(pred_tokens) > 0 else 0\n recall = num_common / len(truth_tokens) if len(truth_tokens) > 0 else 0\n\n if precision + recall == 0:\n return 0.0 # Tránh trường hợp chia cho 0\n\n return 2 * (precision * recall) / (precision + recall)\n\n f1_scores = [f1(pred, truth) for pred, truth in zip(predictions, ground_truths)]\n return sum(f1_scores) / len(f1_scores)\n\n\ndef normalize_text(text):\n return text.translate(str.maketrans(\"\", \"\", string.punctuation)).lower()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-09T02:49:07.762952Z","iopub.execute_input":"2026-04-09T02:49:07.763265Z","iopub.status.idle":"2026-04-09T02:49:07.821812Z","shell.execute_reply.started":"2026-04-09T02:49:07.763226Z","shell.execute_reply":"2026-04-09T02:49:07.820355Z"}},"outputs":[],"execution_count":5},{"cell_type":"code","source":"import torch\nimport numpy as np\nfrom datasets import Dataset\nfrom transformers import AutoTokenizer, AutoModelForQuestionAnswering\nfrom torch.utils.data import DataLoader\nfrom transformers import default_data_collator\nfrom tqdm.auto import tqdm\n\n# Tokenizer\nmodel_checkpoint = \"bert-base-cased\"\ntokenizer = AutoTokenizer.from_pretrained(model_checkpoint)\n\n# Preprocessing function\ndef preprocess_examples(examples):\n questions = [q.strip() for q in examples[\"question\"]]\n inputs = tokenizer(\n questions,\n examples[\"context\"],\n max_length=512,\n truncation=\"only_second\",\n stride=256,\n return_overflowing_tokens=True,\n return_offsets_mapping=True,\n padding=\"max_length\",\n )\n \n offset_mapping = inputs.pop(\"offset_mapping\")\n sample_map = inputs.pop(\"overflow_to_sample_mapping\")\n answers = examples[\"answers\"]\n start_positions, end_positions = [], []\n \n for i, offsets in enumerate(offset_mapping):\n sample_idx = sample_map[i]\n answer = answers[sample_idx]\n if len(answer[\"text\"]) == 0:\n start_positions.append(0)\n end_positions.append(0)\n else:\n start_char = answer[\"answer_start\"][0]\n end_char = start_char + len(answer[\"text\"][0])\n sequence_ids = inputs.sequence_ids(i)\n \n idx = 0\n while sequence_ids[idx] != 1:\n idx += 1\n context_start = idx\n while idx < len(sequence_ids) and sequence_ids[idx] == 1:\n idx += 1\n context_end = idx - 1\n \n if offsets[context_start][0] > start_char or offsets[context_end][1] < end_char:\n start_positions.append(0)\n end_positions.append(0)\n else:\n idx = context_start\n while idx <= context_end and offsets[idx][0] <= start_char:\n idx += 1\n start_positions.append(idx - 1)\n \n idx = context_end\n while idx >= context_start and offsets[idx][1] >= end_char:\n idx -= 1\n end_positions.append(idx + 1)\n \n inputs[\"start_positions\"] = start_positions\n inputs[\"end_positions\"] = end_positions\n return inputs\n\n# Apply preprocessing\ndataset_processed = dataset.map(preprocess_examples, batched=True, remove_columns=dataset.column_names)\ndataset_splited = dataset_processed.train_test_split(test_size=0.2, seed=42)\n\ndataset.set_format(\"torch\")\ntrain_dataloader = DataLoader(dataset_splited['train'], batch_size=3, shuffle=True, collate_fn=default_data_collator)\ntest_dataloader = DataLoader(dataset_splited['test'], batch_size=3, shuffle=False, collate_fn=default_data_collator)\n\n# Model and optimizer\nmodel = AutoModelForQuestionAnswering.from_pretrained(model_checkpoint)\ndevice = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\nmodel.to(device)\noptimizer = torch.optim.AdamW(model.parameters(), lr=2e-5)\n\n# Training loop\nnum_epochs = 20\nprogress_bar = tqdm(range(len(train_dataloader) * num_epochs))\n\ndataset = Dataset.from_dict(qa_data)\ndataset = dataset.train_test_split(test_size=0.2, seed=42)\n\nfor epoch in range(num_epochs):\n model.train()\n for batch in train_dataloader:\n batch = {k: v.to(device) for k, v in batch.items()}\n optimizer.zero_grad()\n outputs = model(**batch)\n loss = outputs.loss\n loss.backward()\n optimizer.step()\n progress_bar.update(1)\n predictions = []\n references = []\n model.eval()\n # Lặp qua từng dòng trong tập test\n for example in dataset['test']:\n question = example[\"question\"]\n context = example[\"context\"]\n ground_truth = example[\"answers\"][\"text\"][0]\n \n # Dự đoán câu trả lời\n result = predict_answer(question, context)\n \n # Thêm vào danh sách đánh giá\n predictions.append(result)\n references.append(ground_truth)\n \n \n # Tính Exact Match và F1\n em = calculate_exact_match(predictions, references)\n f1 = calculate_f1_score(predictions, references)\n \n print(f\"Exact Match: {em * 100:.2f}%\")\n print(f\"F1 Score: {f1:.4f}\")\n print(f\"Epoch {epoch + 1} completed.\")\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-09T02:49:08.670359Z","iopub.execute_input":"2026-04-09T02:49:08.670795Z","execution_failed":"2026-04-08T19:52:18.847Z"}},"outputs":[{"output_type":"display_data","data":{"text/plain":"tokenizer_config.json: 0%| | 0.00/49.0 [00:00<?, ?B/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"4459cdddee0241a2b16fe972fa08c58e"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"config.json: 0%| | 0.00/570 [00:00<?, ?B/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"3e9bcdf9144749fa8259f0eaad45fdad"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"vocab.txt: 0.00B [00:00, ?B/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"01fbb2df8b8a403dbfc30ffc2f5260f3"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"tokenizer.json: 0.00B [00:00, ?B/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"e857c1b04ebf46ceafb90f3190c7151d"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"Map: 0%| | 0/2530 [00:00<?, ? examples/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"4a73070a62df42788f1144353d05b292"}},"metadata":{}},{"output_type":"display_data","data":{"text/plain":"model.safetensors: 0%| | 0.00/436M [00:00<?, ?B/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"fc08de0a23244b0ca9f6e3b1cdc2a7c7"}},"metadata":{}},{"name":"stderr","text":"Some weights of BertForQuestionAnswering were not initialized from the model checkpoint at bert-base-cased and are newly initialized: ['qa_outputs.bias', 'qa_outputs.weight']\nYou should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.\n","output_type":"stream"},{"output_type":"display_data","data":{"text/plain":" 0%| | 0/13960 [00:00<?, ?it/s]","application/vnd.jupyter.widget-view+json":{"version_major":2,"version_minor":0,"model_id":"372a4f27c1104f01985e59672266f38d"}},"metadata":{}},{"name":"stdout","text":"Exact Match: 40.12%\nF1 Score: 0.4749\nEpoch 1 completed.\n","output_type":"stream"}],"execution_count":null},{"cell_type":"code","source":"# Save model\nmodel.save_pretrained(\"bert-finetuned-distortion\")\ntokenizer.save_pretrained(\"bert-finetuned-distortion\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-09-29T04:02:20.639851Z","iopub.status.idle":"2025-09-29T04:02:20.640119Z","shell.execute_reply":"2025-09-29T04:02:20.640009Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"\n# def predict_answer(question, context):\n# inputs = tokenizer(question, context, return_tensors=\"pt\", truncation=True, max_length=384)\n# inputs = {k: v.to(device) for k, v in inputs.items()}\n \n# with torch.no_grad():\n# outputs = model(**inputs)\n \n# start_logits = outputs.start_logits\n# end_logits = outputs.end_logits\n# start_index = torch.argmax(start_logits, dim=-1).item()\n# end_index = torch.argmax(end_logits, dim=-1).item()\n \n# all_tokens = tokenizer.convert_ids_to_tokens(inputs[\"input_ids\"].squeeze())\n# answer = tokenizer.convert_tokens_to_string(all_tokens[start_index:end_index+1])\n \n# return answer\n\n# def predict_answer(question, context):\n# # Tokenize with offset mapping to align tokens with original text\n# inputs = tokenizer(\n# question,\n# context,\n# return_tensors=\"pt\",\n# max_length=512,\n# truncation=\"only_second\",\n# stride=256,\n# return_offsets_mapping=True,\n# padding=\"max_length\",\n# )\n\n# offset_mapping = inputs.pop(\"offset_mapping\")\n# input_ids = inputs[\"input_ids\"]\n# inputs = {k: v.to(device) for k, v in inputs.items()}\n\n# with torch.no_grad():\n# outputs = model(**inputs)\n\n# start_logits = outputs.start_logits\n# end_logits = outputs.end_logits\n\n# # Get the most probable start and end token positions\n# start_index = torch.argmax(start_logits, dim=-1).item()\n# end_index = torch.argmax(end_logits, dim=-1).item()\n\n# # Extract character positions from offset mapping\n# offsets = offset_mapping[0]\n# start_char = offsets[start_index][0]\n# end_char = offsets[end_index][1]\n\n# # Extract the predicted answer from the original context\n# answer = context[start_char:end_char]\n\n# return answer\n\n\n\n# Example inference\n# for i in range(15):\n# question = qa_data[\"question\"][i]\n# context = qa_data[\"context\"][i]\n# print(context)\n# print(qa_data[\"answers\"][i])\n# predicted_answer = predict_answer(question, context)\n# print(f\"Question: {question}\")\n# print(f\"Predicted Answer: {predicted_answer}\\n\")\n ","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-04-09T02:38:13.063799Z","iopub.execute_input":"2026-04-09T02:38:13.064239Z","iopub.status.idle":"2026-04-09T02:38:13.074009Z","shell.execute_reply.started":"2026-04-09T02:38:13.064205Z","shell.execute_reply":"2026-04-09T02:38:13.072689Z"}},"outputs":[],"execution_count":7},{"cell_type":"code","source":"# # !pip install evaluate\n# import evaluate\n\n# # Load metrics\n# squad_metric = evaluate.load(\"squad\")\n\n# # Chuẩn bị prediction và references\n# predictions = []\n# references = []\n\n# for i in range(len(qa_data[\"question\"])):\n# question = qa_data[\"question\"][i]\n# context = qa_data[\"context\"][i]\n# ground_truth = qa_data[\"answers\"][i][\"text\"][0]\n\n# result = predict_answer(question, context)\n\n# # Thêm vào danh sách đánh giá\n# predictions.append({\n# \"id\": str(i),\n# \"prediction_text\": result\n# })\n# references.append({\n# \"id\": str(i),\n# \"answers\": {\n# \"answer_start\": [qa_data[\"answers\"][i][\"answer_start\"][0]],\n# \"text\": [ground_truth]\n# }\n# })\n\n# # Tính EM và F1\n# results = squad_metric.compute(predictions=predictions, references=references)\n# print(f\"Exact Match: {results['exact_match']:.2f}\")\n# print(f\"F1 Score: {results['f1']:.2f}\")\nfrom collections import Counter\nimport string\n\n# Hàm tính toán Exact Match và F1 (như đã trình bày trước đó)\ndef calculate_exact_match(predictions, ground_truths):\n exact_match = 0\n for pred, truth in zip(predictions, ground_truths):\n if pred.strip().lower() == truth.strip().lower():\n exact_match += 1\n return exact_match / len(predictions)\n\ndef calculate_f1_score(predictions, ground_truths):\n def f1(pred, truth):\n pred_tokens = normalize_text(pred).split()\n truth_tokens = normalize_text(truth).split()\n\n # Trường hợp cả hai chuỗi đều rỗng\n if not pred_tokens and not truth_tokens:\n return 1.0 # Có thể cho là F1 score hoàn hảo trong trường hợp này\n\n common_tokens = Counter(pred_tokens) & Counter(truth_tokens)\n num_common = sum(common_tokens.values())\n\n if num_common == 0:\n return 0.0 # Trả về giá trị 0 nếu không có sự giao nhau\n\n precision = num_common / len(pred_tokens) if len(pred_tokens) > 0 else 0\n recall = num_common / len(truth_tokens) if len(truth_tokens) > 0 else 0\n\n if precision + recall == 0:\n return 0.0 # Tránh trường hợp chia cho 0\n\n return 2 * (precision * recall) / (precision + recall)\n\n f1_scores = [f1(pred, truth) for pred, truth in zip(predictions, ground_truths)]\n return sum(f1_scores) / len(f1_scores)\n\n\ndef normalize_text(text):\n return text.translate(str.maketrans(\"\", \"\", string.punctuation)).lower()\n\n#Chuẩn bị dữ liệu từ qa_data\n# predictions = []\n# references = []\n\n# for i in range(len(qa_data[\"question\"])):\n# question = qa_data[\"question\"][i]\n# context = qa_data[\"context\"][i]\n# ground_truth = qa_data[\"answers\"][i][\"text\"][0]\n\n# # Dự đoán câu trả lời cho từng câu hỏi\n# result = predict_answer(question, context)\n# qa_data[\"predict\"][i]= result\n# # Thêm vào danh sách đánh giá\n# predictions.append(result)\n# references.append(ground_truth)\n\n# predictions = []\n# references = []\n\n# # Lặp qua từng dòng trong tập test\n# for example in dataset['test']:\n# question = example[\"question\"]\n# context = example[\"context\"]\n# ground_truth = example[\"answers\"][\"text\"][0]\n\n# # Dự đoán câu trả lời\n# result = predict_answer(question, context)\n\n# # Thêm vào danh sách đánh giá\n# predictions.append(result)\n# references.append(ground_truth)\n\n\n# # Tính Exact Match và F1\n# em = calculate_exact_match(predictions, references)\n# f1 = calculate_f1_score(predictions, references)\n\n# print(f\"Exact Match: {em * 100:.2f}%\")\n# print(f\"F1 Score: {f1:.4f}\")\n\n# qa_data[\"predict\"] = [] # Tạo danh sách rỗng trước\n\n# for i in range(len(qa_data[\"question\"])):\n# question = qa_data[\"question\"][i]\n# context = qa_data[\"context\"][i]\n# ground_truth = qa_data[\"answers\"][i][\"text\"][0]\n\n# # Dự đoán câu trả lời cho từng câu hỏi\n# result = predict_answer(question, context)\n\n# qa_data[\"predict\"].append(result) # Thêm kết quả dự đoán\n\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-09-29T04:49:23.854050Z","iopub.execute_input":"2025-09-29T04:49:23.854337Z","iopub.status.idle":"2025-09-29T04:49:23.862356Z","shell.execute_reply.started":"2025-09-29T04:49:23.854316Z","shell.execute_reply":"2025-09-29T04:49:23.861378Z"}},"outputs":[],"execution_count":4},{"cell_type":"code","source":"import pandas as pd\n\n# Chuyển dict thành DataFrame\ndf_qa = pd.DataFrame(qa_data)\n","metadata":{"trusted":true,"execution":{"execution_failed":"2025-05-19T01:36:39.991Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df_qa.to_csv('distorted.csv', index = False)","metadata":{"trusted":true,"execution":{"execution_failed":"2025-05-19T01:36:39.991Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":" df['Distorted part']=df['Distorted part'].fillna('')","metadata":{"trusted":true,"execution":{"execution_failed":"2025-05-19T01:36:39.991Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"references","metadata":{"trusted":true,"execution":{"execution_failed":"2025-05-19T01:36:39.991Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"qa_data[\"context\"][91]","metadata":{"trusted":true,"execution":{"execution_failed":"2025-05-19T01:36:39.991Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df.head()","metadata":{"trusted":true,"execution":{"execution_failed":"2025-05-19T01:36:39.992Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df['Distorted part'][91]","metadata":{"trusted":true,"execution":{"execution_failed":"2025-05-19T01:36:39.992Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df['Longest Match'][91]","metadata":{"trusted":true,"execution":{"execution_failed":"2025-05-19T01:36:39.992Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"qa_data[\"answers\"][91]","metadata":{"trusted":true,"execution":{"execution_failed":"2025-05-19T01:36:39.992Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"for i in range(len(references)):\n print(references[i])\n print(predictions[i])","metadata":{"trusted":true,"execution":{"execution_failed":"2025-05-19T01:36:39.992Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"predictions[2]","metadata":{"trusted":true,"execution":{"execution_failed":"2025-05-19T01:36:39.992Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"references","metadata":{"trusted":true,"execution":{"execution_failed":"2025-05-19T01:36:39.992Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"predictions[0]","metadata":{"trusted":true,"execution":{"execution_failed":"2025-05-19T01:36:39.992Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"references[0]","metadata":{"trusted":true,"execution":{"execution_failed":"2025-05-19T01:36:39.992Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Load pipeline\nquestion_answerer = pipeline(\"question-answering\", model=model, tokenizer=tokenizer)\n\n# Example inference\nfor i in range(len(qa_data[\"question\"])):\n question = qa_data[\"question\"][i]\n context = qa_data[\"context\"][i]\n result = question_answerer(question=question, context=context)\n print(\"Answer:\", result[\"answer\"])\n print(\"Start index:\", result[\"start\"])\n print(\"End index:\", result[\"end\"])\n print(\"Confidence score:\", result[\"score\"])\n print(f\"Question: {question}\")\n print(f\"Predicted Answer: {result['answer']}\\n\")\n break","metadata":{"trusted":true,"execution":{"execution_failed":"2025-05-19T01:36:39.992Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"len(\"I don’t really know how to explain the situation. \")","metadata":{"trusted":true,"execution":{"execution_failed":"2025-05-19T01:36:39.992Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"qa_data","metadata":{"trusted":true,"execution":{"execution_failed":"2025-05-19T01:36:39.993Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}
|
distortion-classification-deeplearning.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
methods_output_compairision.ipynb
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": 1,
|
| 6 |
+
"id": "8cf922fd",
|
| 7 |
+
"metadata": {},
|
| 8 |
+
"outputs": [],
|
| 9 |
+
"source": [
|
| 10 |
+
"import numpy as np\n",
|
| 11 |
+
"import pandas as pd\n",
|
| 12 |
+
"import matplotlib.pyplot as plt\n",
|
| 13 |
+
"import warnings \n",
|
| 14 |
+
"warnings.filterwarnings('ignore')"
|
| 15 |
+
]
|
| 16 |
+
},
|
| 17 |
+
{
|
| 18 |
+
"cell_type": "markdown",
|
| 19 |
+
"id": "6c53d9c9",
|
| 20 |
+
"metadata": {},
|
| 21 |
+
"source": [
|
| 22 |
+
"# 2021 methods"
|
| 23 |
+
]
|
| 24 |
+
},
|
| 25 |
+
{
|
| 26 |
+
"cell_type": "code",
|
| 27 |
+
"execution_count": 2,
|
| 28 |
+
"id": "043ac410",
|
| 29 |
+
"metadata": {},
|
| 30 |
+
"outputs": [
|
| 31 |
+
{
|
| 32 |
+
"data": {
|
| 33 |
+
"text/html": [
|
| 34 |
+
"<div>\n",
|
| 35 |
+
"<style scoped>\n",
|
| 36 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 37 |
+
" vertical-align: middle;\n",
|
| 38 |
+
" }\n",
|
| 39 |
+
"\n",
|
| 40 |
+
" .dataframe tbody tr th {\n",
|
| 41 |
+
" vertical-align: top;\n",
|
| 42 |
+
" }\n",
|
| 43 |
+
"\n",
|
| 44 |
+
" .dataframe thead th {\n",
|
| 45 |
+
" text-align: right;\n",
|
| 46 |
+
" }\n",
|
| 47 |
+
"</style>\n",
|
| 48 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 49 |
+
" <thead>\n",
|
| 50 |
+
" <tr style=\"text-align: right;\">\n",
|
| 51 |
+
" <th></th>\n",
|
| 52 |
+
" <th>Id_Number</th>\n",
|
| 53 |
+
" <th>Patient Question</th>\n",
|
| 54 |
+
" <th>Distorted part</th>\n",
|
| 55 |
+
" <th>Dominant Distortion</th>\n",
|
| 56 |
+
" <th>Secondary Distortion (Optional)</th>\n",
|
| 57 |
+
" </tr>\n",
|
| 58 |
+
" </thead>\n",
|
| 59 |
+
" <tbody>\n",
|
| 60 |
+
" <tr>\n",
|
| 61 |
+
" <th>0</th>\n",
|
| 62 |
+
" <td>4500</td>\n",
|
| 63 |
+
" <td>Hello, I have a beautiful,smart,outgoing and a...</td>\n",
|
| 64 |
+
" <td>The voice are always fimilar (someone she know...</td>\n",
|
| 65 |
+
" <td>Personalization</td>\n",
|
| 66 |
+
" <td>NaN</td>\n",
|
| 67 |
+
" </tr>\n",
|
| 68 |
+
" <tr>\n",
|
| 69 |
+
" <th>1</th>\n",
|
| 70 |
+
" <td>4501</td>\n",
|
| 71 |
+
" <td>Since I was about 16 years old I’ve had these ...</td>\n",
|
| 72 |
+
" <td>I feel trapped inside my disgusting self and l...</td>\n",
|
| 73 |
+
" <td>Labeling</td>\n",
|
| 74 |
+
" <td>Emotional Reasoning</td>\n",
|
| 75 |
+
" </tr>\n",
|
| 76 |
+
" <tr>\n",
|
| 77 |
+
" <th>2</th>\n",
|
| 78 |
+
" <td>4502</td>\n",
|
| 79 |
+
" <td>So I’ve been dating on and off this guy for a...</td>\n",
|
| 80 |
+
" <td>NaN</td>\n",
|
| 81 |
+
" <td>No Distortion</td>\n",
|
| 82 |
+
" <td>NaN</td>\n",
|
| 83 |
+
" </tr>\n",
|
| 84 |
+
" <tr>\n",
|
| 85 |
+
" <th>3</th>\n",
|
| 86 |
+
" <td>4503</td>\n",
|
| 87 |
+
" <td>My parents got divorced in 2004. My mother has...</td>\n",
|
| 88 |
+
" <td>NaN</td>\n",
|
| 89 |
+
" <td>No Distortion</td>\n",
|
| 90 |
+
" <td>NaN</td>\n",
|
| 91 |
+
" </tr>\n",
|
| 92 |
+
" <tr>\n",
|
| 93 |
+
" <th>4</th>\n",
|
| 94 |
+
" <td>4504</td>\n",
|
| 95 |
+
" <td>I don’t really know how to explain the situati...</td>\n",
|
| 96 |
+
" <td>I refused to go because I didn’t know if it wa...</td>\n",
|
| 97 |
+
" <td>Fortune-telling</td>\n",
|
| 98 |
+
" <td>Emotional Reasoning</td>\n",
|
| 99 |
+
" </tr>\n",
|
| 100 |
+
" </tbody>\n",
|
| 101 |
+
"</table>\n",
|
| 102 |
+
"</div>"
|
| 103 |
+
],
|
| 104 |
+
"text/plain": [
|
| 105 |
+
" Id_Number Patient Question \\\n",
|
| 106 |
+
"0 4500 Hello, I have a beautiful,smart,outgoing and a... \n",
|
| 107 |
+
"1 4501 Since I was about 16 years old I’ve had these ... \n",
|
| 108 |
+
"2 4502 So I’ve been dating on and off this guy for a... \n",
|
| 109 |
+
"3 4503 My parents got divorced in 2004. My mother has... \n",
|
| 110 |
+
"4 4504 I don’t really know how to explain the situati... \n",
|
| 111 |
+
"\n",
|
| 112 |
+
" Distorted part Dominant Distortion \\\n",
|
| 113 |
+
"0 The voice are always fimilar (someone she know... Personalization \n",
|
| 114 |
+
"1 I feel trapped inside my disgusting self and l... Labeling \n",
|
| 115 |
+
"2 NaN No Distortion \n",
|
| 116 |
+
"3 NaN No Distortion \n",
|
| 117 |
+
"4 I refused to go because I didn’t know if it wa... Fortune-telling \n",
|
| 118 |
+
"\n",
|
| 119 |
+
" Secondary Distortion (Optional) \n",
|
| 120 |
+
"0 NaN \n",
|
| 121 |
+
"1 Emotional Reasoning \n",
|
| 122 |
+
"2 NaN \n",
|
| 123 |
+
"3 NaN \n",
|
| 124 |
+
"4 Emotional Reasoning "
|
| 125 |
+
]
|
| 126 |
+
},
|
| 127 |
+
"execution_count": 2,
|
| 128 |
+
"metadata": {},
|
| 129 |
+
"output_type": "execute_result"
|
| 130 |
+
}
|
| 131 |
+
],
|
| 132 |
+
"source": [
|
| 133 |
+
"df_2021 = pd.read_csv('data/distortion.csv')\n",
|
| 134 |
+
"df_2021.head()"
|
| 135 |
+
]
|
| 136 |
+
},
|
| 137 |
+
{
|
| 138 |
+
"cell_type": "code",
|
| 139 |
+
"execution_count": 3,
|
| 140 |
+
"id": "7dac60fb",
|
| 141 |
+
"metadata": {},
|
| 142 |
+
"outputs": [
|
| 143 |
+
{
|
| 144 |
+
"data": {
|
| 145 |
+
"text/html": [
|
| 146 |
+
"<div>\n",
|
| 147 |
+
"<style scoped>\n",
|
| 148 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 149 |
+
" vertical-align: middle;\n",
|
| 150 |
+
" }\n",
|
| 151 |
+
"\n",
|
| 152 |
+
" .dataframe tbody tr th {\n",
|
| 153 |
+
" vertical-align: top;\n",
|
| 154 |
+
" }\n",
|
| 155 |
+
"\n",
|
| 156 |
+
" .dataframe thead th {\n",
|
| 157 |
+
" text-align: right;\n",
|
| 158 |
+
" }\n",
|
| 159 |
+
"</style>\n",
|
| 160 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 161 |
+
" <thead>\n",
|
| 162 |
+
" <tr style=\"text-align: right;\">\n",
|
| 163 |
+
" <th></th>\n",
|
| 164 |
+
" <th>Id_Number</th>\n",
|
| 165 |
+
" <th>Patient Question</th>\n",
|
| 166 |
+
" <th>Distorted part</th>\n",
|
| 167 |
+
" <th>Dominant Distortion</th>\n",
|
| 168 |
+
" <th>Secondary Distortion (Optional)</th>\n",
|
| 169 |
+
" </tr>\n",
|
| 170 |
+
" </thead>\n",
|
| 171 |
+
" <tbody>\n",
|
| 172 |
+
" <tr>\n",
|
| 173 |
+
" <th>0</th>\n",
|
| 174 |
+
" <td>4500</td>\n",
|
| 175 |
+
" <td>Hello, I have a beautiful,smart,outgoing and a...</td>\n",
|
| 176 |
+
" <td>The voice are always fimilar (someone she know...</td>\n",
|
| 177 |
+
" <td>Personalization</td>\n",
|
| 178 |
+
" <td>NaN</td>\n",
|
| 179 |
+
" </tr>\n",
|
| 180 |
+
" <tr>\n",
|
| 181 |
+
" <th>1</th>\n",
|
| 182 |
+
" <td>4501</td>\n",
|
| 183 |
+
" <td>Since I was about 16 years old I’ve had these ...</td>\n",
|
| 184 |
+
" <td>I feel trapped inside my disgusting self and l...</td>\n",
|
| 185 |
+
" <td>Labeling</td>\n",
|
| 186 |
+
" <td>Emotional Reasoning</td>\n",
|
| 187 |
+
" </tr>\n",
|
| 188 |
+
" <tr>\n",
|
| 189 |
+
" <th>4</th>\n",
|
| 190 |
+
" <td>4504</td>\n",
|
| 191 |
+
" <td>I don’t really know how to explain the situati...</td>\n",
|
| 192 |
+
" <td>I refused to go because I didn’t know if it wa...</td>\n",
|
| 193 |
+
" <td>Fortune-telling</td>\n",
|
| 194 |
+
" <td>Emotional Reasoning</td>\n",
|
| 195 |
+
" </tr>\n",
|
| 196 |
+
" <tr>\n",
|
| 197 |
+
" <th>9</th>\n",
|
| 198 |
+
" <td>4510</td>\n",
|
| 199 |
+
" <td>I have been with my fiancé for two years now....</td>\n",
|
| 200 |
+
" <td>I felt like the response was totally irrationa...</td>\n",
|
| 201 |
+
" <td>Magnification</td>\n",
|
| 202 |
+
" <td>NaN</td>\n",
|
| 203 |
+
" </tr>\n",
|
| 204 |
+
" <tr>\n",
|
| 205 |
+
" <th>10</th>\n",
|
| 206 |
+
" <td>4511</td>\n",
|
| 207 |
+
" <td>My husband and I have been married for over a ...</td>\n",
|
| 208 |
+
" <td>I thought that he displayed traits of honor, l...</td>\n",
|
| 209 |
+
" <td>Labeling</td>\n",
|
| 210 |
+
" <td>NaN</td>\n",
|
| 211 |
+
" </tr>\n",
|
| 212 |
+
" </tbody>\n",
|
| 213 |
+
"</table>\n",
|
| 214 |
+
"</div>"
|
| 215 |
+
],
|
| 216 |
+
"text/plain": [
|
| 217 |
+
" Id_Number Patient Question \\\n",
|
| 218 |
+
"0 4500 Hello, I have a beautiful,smart,outgoing and a... \n",
|
| 219 |
+
"1 4501 Since I was about 16 years old I’ve had these ... \n",
|
| 220 |
+
"4 4504 I don’t really know how to explain the situati... \n",
|
| 221 |
+
"9 4510 I have been with my fiancé for two years now.... \n",
|
| 222 |
+
"10 4511 My husband and I have been married for over a ... \n",
|
| 223 |
+
"\n",
|
| 224 |
+
" Distorted part Dominant Distortion \\\n",
|
| 225 |
+
"0 The voice are always fimilar (someone she know... Personalization \n",
|
| 226 |
+
"1 I feel trapped inside my disgusting self and l... Labeling \n",
|
| 227 |
+
"4 I refused to go because I didn’t know if it wa... Fortune-telling \n",
|
| 228 |
+
"9 I felt like the response was totally irrationa... Magnification \n",
|
| 229 |
+
"10 I thought that he displayed traits of honor, l... Labeling \n",
|
| 230 |
+
"\n",
|
| 231 |
+
" Secondary Distortion (Optional) \n",
|
| 232 |
+
"0 NaN \n",
|
| 233 |
+
"1 Emotional Reasoning \n",
|
| 234 |
+
"4 Emotional Reasoning \n",
|
| 235 |
+
"9 NaN \n",
|
| 236 |
+
"10 NaN "
|
| 237 |
+
]
|
| 238 |
+
},
|
| 239 |
+
"execution_count": 3,
|
| 240 |
+
"metadata": {},
|
| 241 |
+
"output_type": "execute_result"
|
| 242 |
+
}
|
| 243 |
+
],
|
| 244 |
+
"source": [
|
| 245 |
+
"df_2021 = df_2021[df_2021['Dominant Distortion'] != 'No Distortion']\n",
|
| 246 |
+
"df_2021.head()"
|
| 247 |
+
]
|
| 248 |
+
},
|
| 249 |
+
{
|
| 250 |
+
"cell_type": "code",
|
| 251 |
+
"execution_count": 4,
|
| 252 |
+
"id": "c75ed93d",
|
| 253 |
+
"metadata": {},
|
| 254 |
+
"outputs": [
|
| 255 |
+
{
|
| 256 |
+
"name": "stderr",
|
| 257 |
+
"output_type": "stream",
|
| 258 |
+
"text": [
|
| 259 |
+
"[nltk_data] Downloading package punkt to\n",
|
| 260 |
+
"[nltk_data] C:\\Users\\Admin\\AppData\\Roaming\\nltk_data...\n",
|
| 261 |
+
"[nltk_data] Package punkt is already up-to-date!\n",
|
| 262 |
+
"[nltk_data] Downloading package stopwords to\n",
|
| 263 |
+
"[nltk_data] C:\\Users\\Admin\\AppData\\Roaming\\nltk_data...\n",
|
| 264 |
+
"[nltk_data] Package stopwords is already up-to-date!\n",
|
| 265 |
+
"[nltk_data] Downloading package wordnet to\n",
|
| 266 |
+
"[nltk_data] C:\\Users\\Admin\\AppData\\Roaming\\nltk_data...\n",
|
| 267 |
+
"[nltk_data] Package wordnet is already up-to-date!\n"
|
| 268 |
+
]
|
| 269 |
+
}
|
| 270 |
+
],
|
| 271 |
+
"source": [
|
| 272 |
+
"import re\n",
|
| 273 |
+
"import string\n",
|
| 274 |
+
"import nltk\n",
|
| 275 |
+
"from nltk.tokenize import word_tokenize\n",
|
| 276 |
+
"from nltk.corpus import stopwords\n",
|
| 277 |
+
"from nltk.stem import PorterStemmer, WordNetLemmatizer\n",
|
| 278 |
+
"\n",
|
| 279 |
+
"nltk.download(\"punkt\")\n",
|
| 280 |
+
"nltk.download(\"stopwords\")\n",
|
| 281 |
+
"nltk.download(\"wordnet\")\n",
|
| 282 |
+
"\n",
|
| 283 |
+
"stemmer = PorterStemmer()\n",
|
| 284 |
+
"lemmatizer = WordNetLemmatizer()\n",
|
| 285 |
+
"stop_words = set(stopwords.words(\"english\"))\n",
|
| 286 |
+
"\n",
|
| 287 |
+
"def preprocess_text(text, use_stemming=False, use_lemmatization=True, correct_spelling=False):\n",
|
| 288 |
+
" text = text.lower()\n",
|
| 289 |
+
" text = text.translate(str.maketrans(\"\", \"\", string.punctuation))\n",
|
| 290 |
+
" return text"
|
| 291 |
+
]
|
| 292 |
+
},
|
| 293 |
+
{
|
| 294 |
+
"cell_type": "code",
|
| 295 |
+
"execution_count": 5,
|
| 296 |
+
"id": "c1943d1a",
|
| 297 |
+
"metadata": {},
|
| 298 |
+
"outputs": [
|
| 299 |
+
{
|
| 300 |
+
"data": {
|
| 301 |
+
"text/html": [
|
| 302 |
+
"<div>\n",
|
| 303 |
+
"<style scoped>\n",
|
| 304 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 305 |
+
" vertical-align: middle;\n",
|
| 306 |
+
" }\n",
|
| 307 |
+
"\n",
|
| 308 |
+
" .dataframe tbody tr th {\n",
|
| 309 |
+
" vertical-align: top;\n",
|
| 310 |
+
" }\n",
|
| 311 |
+
"\n",
|
| 312 |
+
" .dataframe thead th {\n",
|
| 313 |
+
" text-align: right;\n",
|
| 314 |
+
" }\n",
|
| 315 |
+
"</style>\n",
|
| 316 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 317 |
+
" <thead>\n",
|
| 318 |
+
" <tr style=\"text-align: right;\">\n",
|
| 319 |
+
" <th></th>\n",
|
| 320 |
+
" <th>Id_Number</th>\n",
|
| 321 |
+
" <th>Patient Question</th>\n",
|
| 322 |
+
" <th>Distorted part</th>\n",
|
| 323 |
+
" <th>Dominant Distortion</th>\n",
|
| 324 |
+
" <th>Secondary Distortion (Optional)</th>\n",
|
| 325 |
+
" <th>cleaned</th>\n",
|
| 326 |
+
" </tr>\n",
|
| 327 |
+
" </thead>\n",
|
| 328 |
+
" <tbody>\n",
|
| 329 |
+
" <tr>\n",
|
| 330 |
+
" <th>0</th>\n",
|
| 331 |
+
" <td>4500</td>\n",
|
| 332 |
+
" <td>Hello, I have a beautiful,smart,outgoing and a...</td>\n",
|
| 333 |
+
" <td>The voice are always fimilar (someone she know...</td>\n",
|
| 334 |
+
" <td>Personalization</td>\n",
|
| 335 |
+
" <td>NaN</td>\n",
|
| 336 |
+
" <td>hello i have a beautifulsmartoutgoing and amaz...</td>\n",
|
| 337 |
+
" </tr>\n",
|
| 338 |
+
" <tr>\n",
|
| 339 |
+
" <th>1</th>\n",
|
| 340 |
+
" <td>4501</td>\n",
|
| 341 |
+
" <td>Since I was about 16 years old I’ve had these ...</td>\n",
|
| 342 |
+
" <td>I feel trapped inside my disgusting self and l...</td>\n",
|
| 343 |
+
" <td>Labeling</td>\n",
|
| 344 |
+
" <td>Emotional Reasoning</td>\n",
|
| 345 |
+
" <td>since i was about 16 years old i’ve had these ...</td>\n",
|
| 346 |
+
" </tr>\n",
|
| 347 |
+
" <tr>\n",
|
| 348 |
+
" <th>4</th>\n",
|
| 349 |
+
" <td>4504</td>\n",
|
| 350 |
+
" <td>I don’t really know how to explain the situati...</td>\n",
|
| 351 |
+
" <td>I refused to go because I didn’t know if it wa...</td>\n",
|
| 352 |
+
" <td>Fortune-telling</td>\n",
|
| 353 |
+
" <td>Emotional Reasoning</td>\n",
|
| 354 |
+
" <td>i don’t really know how to explain the situati...</td>\n",
|
| 355 |
+
" </tr>\n",
|
| 356 |
+
" <tr>\n",
|
| 357 |
+
" <th>9</th>\n",
|
| 358 |
+
" <td>4510</td>\n",
|
| 359 |
+
" <td>I have been with my fiancé for two years now....</td>\n",
|
| 360 |
+
" <td>I felt like the response was totally irrationa...</td>\n",
|
| 361 |
+
" <td>Magnification</td>\n",
|
| 362 |
+
" <td>NaN</td>\n",
|
| 363 |
+
" <td>i have been with my fiancé for two years now ...</td>\n",
|
| 364 |
+
" </tr>\n",
|
| 365 |
+
" <tr>\n",
|
| 366 |
+
" <th>10</th>\n",
|
| 367 |
+
" <td>4511</td>\n",
|
| 368 |
+
" <td>My husband and I have been married for over a ...</td>\n",
|
| 369 |
+
" <td>I thought that he displayed traits of honor, l...</td>\n",
|
| 370 |
+
" <td>Labeling</td>\n",
|
| 371 |
+
" <td>NaN</td>\n",
|
| 372 |
+
" <td>my husband and i have been married for over a ...</td>\n",
|
| 373 |
+
" </tr>\n",
|
| 374 |
+
" </tbody>\n",
|
| 375 |
+
"</table>\n",
|
| 376 |
+
"</div>"
|
| 377 |
+
],
|
| 378 |
+
"text/plain": [
|
| 379 |
+
" Id_Number Patient Question \\\n",
|
| 380 |
+
"0 4500 Hello, I have a beautiful,smart,outgoing and a... \n",
|
| 381 |
+
"1 4501 Since I was about 16 years old I’ve had these ... \n",
|
| 382 |
+
"4 4504 I don’t really know how to explain the situati... \n",
|
| 383 |
+
"9 4510 I have been with my fiancé for two years now.... \n",
|
| 384 |
+
"10 4511 My husband and I have been married for over a ... \n",
|
| 385 |
+
"\n",
|
| 386 |
+
" Distorted part Dominant Distortion \\\n",
|
| 387 |
+
"0 The voice are always fimilar (someone she know... Personalization \n",
|
| 388 |
+
"1 I feel trapped inside my disgusting self and l... Labeling \n",
|
| 389 |
+
"4 I refused to go because I didn’t know if it wa... Fortune-telling \n",
|
| 390 |
+
"9 I felt like the response was totally irrationa... Magnification \n",
|
| 391 |
+
"10 I thought that he displayed traits of honor, l... Labeling \n",
|
| 392 |
+
"\n",
|
| 393 |
+
" Secondary Distortion (Optional) \\\n",
|
| 394 |
+
"0 NaN \n",
|
| 395 |
+
"1 Emotional Reasoning \n",
|
| 396 |
+
"4 Emotional Reasoning \n",
|
| 397 |
+
"9 NaN \n",
|
| 398 |
+
"10 NaN \n",
|
| 399 |
+
"\n",
|
| 400 |
+
" cleaned \n",
|
| 401 |
+
"0 hello i have a beautifulsmartoutgoing and amaz... \n",
|
| 402 |
+
"1 since i was about 16 years old i’ve had these ... \n",
|
| 403 |
+
"4 i don’t really know how to explain the situati... \n",
|
| 404 |
+
"9 i have been with my fiancé for two years now ... \n",
|
| 405 |
+
"10 my husband and i have been married for over a ... "
|
| 406 |
+
]
|
| 407 |
+
},
|
| 408 |
+
"execution_count": 5,
|
| 409 |
+
"metadata": {},
|
| 410 |
+
"output_type": "execute_result"
|
| 411 |
+
}
|
| 412 |
+
],
|
| 413 |
+
"source": [
|
| 414 |
+
"df_2021['cleaned'] = df_2021['Patient Question'].map(lambda text: preprocess_text(text))\n",
|
| 415 |
+
"df_2021.head()"
|
| 416 |
+
]
|
| 417 |
+
},
|
| 418 |
+
{
|
| 419 |
+
"cell_type": "code",
|
| 420 |
+
"execution_count": 6,
|
| 421 |
+
"id": "0c116e42",
|
| 422 |
+
"metadata": {},
|
| 423 |
+
"outputs": [],
|
| 424 |
+
"source": [
|
| 425 |
+
"from sklearn.model_selection import train_test_split\n",
|
| 426 |
+
"\n",
|
| 427 |
+
"X_train, X_test, y_train, y_test = train_test_split(df_2021['cleaned'].values,\n",
|
| 428 |
+
" df_2021['Dominant Distortion'].values,\n",
|
| 429 |
+
" test_size=0.2, random_state=42)"
|
| 430 |
+
]
|
| 431 |
+
},
|
| 432 |
+
{
|
| 433 |
+
"cell_type": "code",
|
| 434 |
+
"execution_count": 7,
|
| 435 |
+
"id": "c7bf8c80",
|
| 436 |
+
"metadata": {},
|
| 437 |
+
"outputs": [],
|
| 438 |
+
"source": [
|
| 439 |
+
"from sklearn.feature_extraction.text import TfidfVectorizer\n",
|
| 440 |
+
"\n",
|
| 441 |
+
"tfidf_vectorizer = TfidfVectorizer()\n",
|
| 442 |
+
"X_train_tfidf = tfidf_vectorizer.fit_transform(X_train)\n",
|
| 443 |
+
"X_test_tfidf = tfidf_vectorizer.transform(X_test)"
|
| 444 |
+
]
|
| 445 |
+
},
|
| 446 |
+
{
|
| 447 |
+
"cell_type": "code",
|
| 448 |
+
"execution_count": 8,
|
| 449 |
+
"id": "59a4d305",
|
| 450 |
+
"metadata": {},
|
| 451 |
+
"outputs": [],
|
| 452 |
+
"source": [
|
| 453 |
+
"from sklearn.linear_model import LogisticRegression\n",
|
| 454 |
+
"from sklearn.svm import LinearSVC\n",
|
| 455 |
+
"from sklearn.tree import DecisionTreeClassifier\n",
|
| 456 |
+
"from sklearn.neighbors import KNeighborsClassifier\n",
|
| 457 |
+
"from sklearn.neural_network import MLPClassifier\n",
|
| 458 |
+
"from sklearn.svm import SVC\n"
|
| 459 |
+
]
|
| 460 |
+
},
|
| 461 |
+
{
|
| 462 |
+
"cell_type": "code",
|
| 463 |
+
"execution_count": 9,
|
| 464 |
+
"id": "5fdc025f",
|
| 465 |
+
"metadata": {},
|
| 466 |
+
"outputs": [
|
| 467 |
+
{
|
| 468 |
+
"data": {
|
| 469 |
+
"text/html": [
|
| 470 |
+
"<style>#sk-container-id-1 {\n",
|
| 471 |
+
" /* Definition of color scheme common for light and dark mode */\n",
|
| 472 |
+
" --sklearn-color-text: #000;\n",
|
| 473 |
+
" --sklearn-color-text-muted: #666;\n",
|
| 474 |
+
" --sklearn-color-line: gray;\n",
|
| 475 |
+
" /* Definition of color scheme for unfitted estimators */\n",
|
| 476 |
+
" --sklearn-color-unfitted-level-0: #fff5e6;\n",
|
| 477 |
+
" --sklearn-color-unfitted-level-1: #f6e4d2;\n",
|
| 478 |
+
" --sklearn-color-unfitted-level-2: #ffe0b3;\n",
|
| 479 |
+
" --sklearn-color-unfitted-level-3: chocolate;\n",
|
| 480 |
+
" /* Definition of color scheme for fitted estimators */\n",
|
| 481 |
+
" --sklearn-color-fitted-level-0: #f0f8ff;\n",
|
| 482 |
+
" --sklearn-color-fitted-level-1: #d4ebff;\n",
|
| 483 |
+
" --sklearn-color-fitted-level-2: #b3dbfd;\n",
|
| 484 |
+
" --sklearn-color-fitted-level-3: cornflowerblue;\n",
|
| 485 |
+
"\n",
|
| 486 |
+
" /* Specific color for light theme */\n",
|
| 487 |
+
" --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
|
| 488 |
+
" --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, white)));\n",
|
| 489 |
+
" --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
|
| 490 |
+
" --sklearn-color-icon: #696969;\n",
|
| 491 |
+
"\n",
|
| 492 |
+
" @media (prefers-color-scheme: dark) {\n",
|
| 493 |
+
" /* Redefinition of color scheme for dark theme */\n",
|
| 494 |
+
" --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
|
| 495 |
+
" --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, #111)));\n",
|
| 496 |
+
" --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
|
| 497 |
+
" --sklearn-color-icon: #878787;\n",
|
| 498 |
+
" }\n",
|
| 499 |
+
"}\n",
|
| 500 |
+
"\n",
|
| 501 |
+
"#sk-container-id-1 {\n",
|
| 502 |
+
" color: var(--sklearn-color-text);\n",
|
| 503 |
+
"}\n",
|
| 504 |
+
"\n",
|
| 505 |
+
"#sk-container-id-1 pre {\n",
|
| 506 |
+
" padding: 0;\n",
|
| 507 |
+
"}\n",
|
| 508 |
+
"\n",
|
| 509 |
+
"#sk-container-id-1 input.sk-hidden--visually {\n",
|
| 510 |
+
" border: 0;\n",
|
| 511 |
+
" clip: rect(1px 1px 1px 1px);\n",
|
| 512 |
+
" clip: rect(1px, 1px, 1px, 1px);\n",
|
| 513 |
+
" height: 1px;\n",
|
| 514 |
+
" margin: -1px;\n",
|
| 515 |
+
" overflow: hidden;\n",
|
| 516 |
+
" padding: 0;\n",
|
| 517 |
+
" position: absolute;\n",
|
| 518 |
+
" width: 1px;\n",
|
| 519 |
+
"}\n",
|
| 520 |
+
"\n",
|
| 521 |
+
"#sk-container-id-1 div.sk-dashed-wrapped {\n",
|
| 522 |
+
" border: 1px dashed var(--sklearn-color-line);\n",
|
| 523 |
+
" margin: 0 0.4em 0.5em 0.4em;\n",
|
| 524 |
+
" box-sizing: border-box;\n",
|
| 525 |
+
" padding-bottom: 0.4em;\n",
|
| 526 |
+
" background-color: var(--sklearn-color-background);\n",
|
| 527 |
+
"}\n",
|
| 528 |
+
"\n",
|
| 529 |
+
"#sk-container-id-1 div.sk-container {\n",
|
| 530 |
+
" /* jupyter's `normalize.less` sets `[hidden] { display: none; }`\n",
|
| 531 |
+
" but bootstrap.min.css set `[hidden] { display: none !important; }`\n",
|
| 532 |
+
" so we also need the `!important` here to be able to override the\n",
|
| 533 |
+
" default hidden behavior on the sphinx rendered scikit-learn.org.\n",
|
| 534 |
+
" See: https://github.com/scikit-learn/scikit-learn/issues/21755 */\n",
|
| 535 |
+
" display: inline-block !important;\n",
|
| 536 |
+
" position: relative;\n",
|
| 537 |
+
"}\n",
|
| 538 |
+
"\n",
|
| 539 |
+
"#sk-container-id-1 div.sk-text-repr-fallback {\n",
|
| 540 |
+
" display: none;\n",
|
| 541 |
+
"}\n",
|
| 542 |
+
"\n",
|
| 543 |
+
"div.sk-parallel-item,\n",
|
| 544 |
+
"div.sk-serial,\n",
|
| 545 |
+
"div.sk-item {\n",
|
| 546 |
+
" /* draw centered vertical line to link estimators */\n",
|
| 547 |
+
" background-image: linear-gradient(var(--sklearn-color-text-on-default-background), var(--sklearn-color-text-on-default-background));\n",
|
| 548 |
+
" background-size: 2px 100%;\n",
|
| 549 |
+
" background-repeat: no-repeat;\n",
|
| 550 |
+
" background-position: center center;\n",
|
| 551 |
+
"}\n",
|
| 552 |
+
"\n",
|
| 553 |
+
"/* Parallel-specific style estimator block */\n",
|
| 554 |
+
"\n",
|
| 555 |
+
"#sk-container-id-1 div.sk-parallel-item::after {\n",
|
| 556 |
+
" content: \"\";\n",
|
| 557 |
+
" width: 100%;\n",
|
| 558 |
+
" border-bottom: 2px solid var(--sklearn-color-text-on-default-background);\n",
|
| 559 |
+
" flex-grow: 1;\n",
|
| 560 |
+
"}\n",
|
| 561 |
+
"\n",
|
| 562 |
+
"#sk-container-id-1 div.sk-parallel {\n",
|
| 563 |
+
" display: flex;\n",
|
| 564 |
+
" align-items: stretch;\n",
|
| 565 |
+
" justify-content: center;\n",
|
| 566 |
+
" background-color: var(--sklearn-color-background);\n",
|
| 567 |
+
" position: relative;\n",
|
| 568 |
+
"}\n",
|
| 569 |
+
"\n",
|
| 570 |
+
"#sk-container-id-1 div.sk-parallel-item {\n",
|
| 571 |
+
" display: flex;\n",
|
| 572 |
+
" flex-direction: column;\n",
|
| 573 |
+
"}\n",
|
| 574 |
+
"\n",
|
| 575 |
+
"#sk-container-id-1 div.sk-parallel-item:first-child::after {\n",
|
| 576 |
+
" align-self: flex-end;\n",
|
| 577 |
+
" width: 50%;\n",
|
| 578 |
+
"}\n",
|
| 579 |
+
"\n",
|
| 580 |
+
"#sk-container-id-1 div.sk-parallel-item:last-child::after {\n",
|
| 581 |
+
" align-self: flex-start;\n",
|
| 582 |
+
" width: 50%;\n",
|
| 583 |
+
"}\n",
|
| 584 |
+
"\n",
|
| 585 |
+
"#sk-container-id-1 div.sk-parallel-item:only-child::after {\n",
|
| 586 |
+
" width: 0;\n",
|
| 587 |
+
"}\n",
|
| 588 |
+
"\n",
|
| 589 |
+
"/* Serial-specific style estimator block */\n",
|
| 590 |
+
"\n",
|
| 591 |
+
"#sk-container-id-1 div.sk-serial {\n",
|
| 592 |
+
" display: flex;\n",
|
| 593 |
+
" flex-direction: column;\n",
|
| 594 |
+
" align-items: center;\n",
|
| 595 |
+
" background-color: var(--sklearn-color-background);\n",
|
| 596 |
+
" padding-right: 1em;\n",
|
| 597 |
+
" padding-left: 1em;\n",
|
| 598 |
+
"}\n",
|
| 599 |
+
"\n",
|
| 600 |
+
"\n",
|
| 601 |
+
"/* Toggleable style: style used for estimator/Pipeline/ColumnTransformer box that is\n",
|
| 602 |
+
"clickable and can be expanded/collapsed.\n",
|
| 603 |
+
"- Pipeline and ColumnTransformer use this feature and define the default style\n",
|
| 604 |
+
"- Estimators will overwrite some part of the style using the `sk-estimator` class\n",
|
| 605 |
+
"*/\n",
|
| 606 |
+
"\n",
|
| 607 |
+
"/* Pipeline and ColumnTransformer style (default) */\n",
|
| 608 |
+
"\n",
|
| 609 |
+
"#sk-container-id-1 div.sk-toggleable {\n",
|
| 610 |
+
" /* Default theme specific background. It is overwritten whether we have a\n",
|
| 611 |
+
" specific estimator or a Pipeline/ColumnTransformer */\n",
|
| 612 |
+
" background-color: var(--sklearn-color-background);\n",
|
| 613 |
+
"}\n",
|
| 614 |
+
"\n",
|
| 615 |
+
"/* Toggleable label */\n",
|
| 616 |
+
"#sk-container-id-1 label.sk-toggleable__label {\n",
|
| 617 |
+
" cursor: pointer;\n",
|
| 618 |
+
" display: flex;\n",
|
| 619 |
+
" width: 100%;\n",
|
| 620 |
+
" margin-bottom: 0;\n",
|
| 621 |
+
" padding: 0.5em;\n",
|
| 622 |
+
" box-sizing: border-box;\n",
|
| 623 |
+
" text-align: center;\n",
|
| 624 |
+
" align-items: start;\n",
|
| 625 |
+
" justify-content: space-between;\n",
|
| 626 |
+
" gap: 0.5em;\n",
|
| 627 |
+
"}\n",
|
| 628 |
+
"\n",
|
| 629 |
+
"#sk-container-id-1 label.sk-toggleable__label .caption {\n",
|
| 630 |
+
" font-size: 0.6rem;\n",
|
| 631 |
+
" font-weight: lighter;\n",
|
| 632 |
+
" color: var(--sklearn-color-text-muted);\n",
|
| 633 |
+
"}\n",
|
| 634 |
+
"\n",
|
| 635 |
+
"#sk-container-id-1 label.sk-toggleable__label-arrow:before {\n",
|
| 636 |
+
" /* Arrow on the left of the label */\n",
|
| 637 |
+
" content: \"▸\";\n",
|
| 638 |
+
" float: left;\n",
|
| 639 |
+
" margin-right: 0.25em;\n",
|
| 640 |
+
" color: var(--sklearn-color-icon);\n",
|
| 641 |
+
"}\n",
|
| 642 |
+
"\n",
|
| 643 |
+
"#sk-container-id-1 label.sk-toggleable__label-arrow:hover:before {\n",
|
| 644 |
+
" color: var(--sklearn-color-text);\n",
|
| 645 |
+
"}\n",
|
| 646 |
+
"\n",
|
| 647 |
+
"/* Toggleable content - dropdown */\n",
|
| 648 |
+
"\n",
|
| 649 |
+
"#sk-container-id-1 div.sk-toggleable__content {\n",
|
| 650 |
+
" max-height: 0;\n",
|
| 651 |
+
" max-width: 0;\n",
|
| 652 |
+
" overflow: hidden;\n",
|
| 653 |
+
" text-align: left;\n",
|
| 654 |
+
" /* unfitted */\n",
|
| 655 |
+
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
| 656 |
+
"}\n",
|
| 657 |
+
"\n",
|
| 658 |
+
"#sk-container-id-1 div.sk-toggleable__content.fitted {\n",
|
| 659 |
+
" /* fitted */\n",
|
| 660 |
+
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
| 661 |
+
"}\n",
|
| 662 |
+
"\n",
|
| 663 |
+
"#sk-container-id-1 div.sk-toggleable__content pre {\n",
|
| 664 |
+
" margin: 0.2em;\n",
|
| 665 |
+
" border-radius: 0.25em;\n",
|
| 666 |
+
" color: var(--sklearn-color-text);\n",
|
| 667 |
+
" /* unfitted */\n",
|
| 668 |
+
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
| 669 |
+
"}\n",
|
| 670 |
+
"\n",
|
| 671 |
+
"#sk-container-id-1 div.sk-toggleable__content.fitted pre {\n",
|
| 672 |
+
" /* unfitted */\n",
|
| 673 |
+
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
| 674 |
+
"}\n",
|
| 675 |
+
"\n",
|
| 676 |
+
"#sk-container-id-1 input.sk-toggleable__control:checked~div.sk-toggleable__content {\n",
|
| 677 |
+
" /* Expand drop-down */\n",
|
| 678 |
+
" max-height: 200px;\n",
|
| 679 |
+
" max-width: 100%;\n",
|
| 680 |
+
" overflow: auto;\n",
|
| 681 |
+
"}\n",
|
| 682 |
+
"\n",
|
| 683 |
+
"#sk-container-id-1 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {\n",
|
| 684 |
+
" content: \"▾\";\n",
|
| 685 |
+
"}\n",
|
| 686 |
+
"\n",
|
| 687 |
+
"/* Pipeline/ColumnTransformer-specific style */\n",
|
| 688 |
+
"\n",
|
| 689 |
+
"#sk-container-id-1 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
| 690 |
+
" color: var(--sklearn-color-text);\n",
|
| 691 |
+
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
| 692 |
+
"}\n",
|
| 693 |
+
"\n",
|
| 694 |
+
"#sk-container-id-1 div.sk-label.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
| 695 |
+
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
| 696 |
+
"}\n",
|
| 697 |
+
"\n",
|
| 698 |
+
"/* Estimator-specific style */\n",
|
| 699 |
+
"\n",
|
| 700 |
+
"/* Colorize estimator box */\n",
|
| 701 |
+
"#sk-container-id-1 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
| 702 |
+
" /* unfitted */\n",
|
| 703 |
+
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
| 704 |
+
"}\n",
|
| 705 |
+
"\n",
|
| 706 |
+
"#sk-container-id-1 div.sk-estimator.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
| 707 |
+
" /* fitted */\n",
|
| 708 |
+
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
| 709 |
+
"}\n",
|
| 710 |
+
"\n",
|
| 711 |
+
"#sk-container-id-1 div.sk-label label.sk-toggleable__label,\n",
|
| 712 |
+
"#sk-container-id-1 div.sk-label label {\n",
|
| 713 |
+
" /* The background is the default theme color */\n",
|
| 714 |
+
" color: var(--sklearn-color-text-on-default-background);\n",
|
| 715 |
+
"}\n",
|
| 716 |
+
"\n",
|
| 717 |
+
"/* On hover, darken the color of the background */\n",
|
| 718 |
+
"#sk-container-id-1 div.sk-label:hover label.sk-toggleable__label {\n",
|
| 719 |
+
" color: var(--sklearn-color-text);\n",
|
| 720 |
+
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
| 721 |
+
"}\n",
|
| 722 |
+
"\n",
|
| 723 |
+
"/* Label box, darken color on hover, fitted */\n",
|
| 724 |
+
"#sk-container-id-1 div.sk-label.fitted:hover label.sk-toggleable__label.fitted {\n",
|
| 725 |
+
" color: var(--sklearn-color-text);\n",
|
| 726 |
+
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
| 727 |
+
"}\n",
|
| 728 |
+
"\n",
|
| 729 |
+
"/* Estimator label */\n",
|
| 730 |
+
"\n",
|
| 731 |
+
"#sk-container-id-1 div.sk-label label {\n",
|
| 732 |
+
" font-family: monospace;\n",
|
| 733 |
+
" font-weight: bold;\n",
|
| 734 |
+
" display: inline-block;\n",
|
| 735 |
+
" line-height: 1.2em;\n",
|
| 736 |
+
"}\n",
|
| 737 |
+
"\n",
|
| 738 |
+
"#sk-container-id-1 div.sk-label-container {\n",
|
| 739 |
+
" text-align: center;\n",
|
| 740 |
+
"}\n",
|
| 741 |
+
"\n",
|
| 742 |
+
"/* Estimator-specific */\n",
|
| 743 |
+
"#sk-container-id-1 div.sk-estimator {\n",
|
| 744 |
+
" font-family: monospace;\n",
|
| 745 |
+
" border: 1px dotted var(--sklearn-color-border-box);\n",
|
| 746 |
+
" border-radius: 0.25em;\n",
|
| 747 |
+
" box-sizing: border-box;\n",
|
| 748 |
+
" margin-bottom: 0.5em;\n",
|
| 749 |
+
" /* unfitted */\n",
|
| 750 |
+
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
| 751 |
+
"}\n",
|
| 752 |
+
"\n",
|
| 753 |
+
"#sk-container-id-1 div.sk-estimator.fitted {\n",
|
| 754 |
+
" /* fitted */\n",
|
| 755 |
+
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
| 756 |
+
"}\n",
|
| 757 |
+
"\n",
|
| 758 |
+
"/* on hover */\n",
|
| 759 |
+
"#sk-container-id-1 div.sk-estimator:hover {\n",
|
| 760 |
+
" /* unfitted */\n",
|
| 761 |
+
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
| 762 |
+
"}\n",
|
| 763 |
+
"\n",
|
| 764 |
+
"#sk-container-id-1 div.sk-estimator.fitted:hover {\n",
|
| 765 |
+
" /* fitted */\n",
|
| 766 |
+
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
| 767 |
+
"}\n",
|
| 768 |
+
"\n",
|
| 769 |
+
"/* Specification for estimator info (e.g. \"i\" and \"?\") */\n",
|
| 770 |
+
"\n",
|
| 771 |
+
"/* Common style for \"i\" and \"?\" */\n",
|
| 772 |
+
"\n",
|
| 773 |
+
".sk-estimator-doc-link,\n",
|
| 774 |
+
"a:link.sk-estimator-doc-link,\n",
|
| 775 |
+
"a:visited.sk-estimator-doc-link {\n",
|
| 776 |
+
" float: right;\n",
|
| 777 |
+
" font-size: smaller;\n",
|
| 778 |
+
" line-height: 1em;\n",
|
| 779 |
+
" font-family: monospace;\n",
|
| 780 |
+
" background-color: var(--sklearn-color-background);\n",
|
| 781 |
+
" border-radius: 1em;\n",
|
| 782 |
+
" height: 1em;\n",
|
| 783 |
+
" width: 1em;\n",
|
| 784 |
+
" text-decoration: none !important;\n",
|
| 785 |
+
" margin-left: 0.5em;\n",
|
| 786 |
+
" text-align: center;\n",
|
| 787 |
+
" /* unfitted */\n",
|
| 788 |
+
" border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
|
| 789 |
+
" color: var(--sklearn-color-unfitted-level-1);\n",
|
| 790 |
+
"}\n",
|
| 791 |
+
"\n",
|
| 792 |
+
".sk-estimator-doc-link.fitted,\n",
|
| 793 |
+
"a:link.sk-estimator-doc-link.fitted,\n",
|
| 794 |
+
"a:visited.sk-estimator-doc-link.fitted {\n",
|
| 795 |
+
" /* fitted */\n",
|
| 796 |
+
" border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
|
| 797 |
+
" color: var(--sklearn-color-fitted-level-1);\n",
|
| 798 |
+
"}\n",
|
| 799 |
+
"\n",
|
| 800 |
+
"/* On hover */\n",
|
| 801 |
+
"div.sk-estimator:hover .sk-estimator-doc-link:hover,\n",
|
| 802 |
+
".sk-estimator-doc-link:hover,\n",
|
| 803 |
+
"div.sk-label-container:hover .sk-estimator-doc-link:hover,\n",
|
| 804 |
+
".sk-estimator-doc-link:hover {\n",
|
| 805 |
+
" /* unfitted */\n",
|
| 806 |
+
" background-color: var(--sklearn-color-unfitted-level-3);\n",
|
| 807 |
+
" color: var(--sklearn-color-background);\n",
|
| 808 |
+
" text-decoration: none;\n",
|
| 809 |
+
"}\n",
|
| 810 |
+
"\n",
|
| 811 |
+
"div.sk-estimator.fitted:hover .sk-estimator-doc-link.fitted:hover,\n",
|
| 812 |
+
".sk-estimator-doc-link.fitted:hover,\n",
|
| 813 |
+
"div.sk-label-container:hover .sk-estimator-doc-link.fitted:hover,\n",
|
| 814 |
+
".sk-estimator-doc-link.fitted:hover {\n",
|
| 815 |
+
" /* fitted */\n",
|
| 816 |
+
" background-color: var(--sklearn-color-fitted-level-3);\n",
|
| 817 |
+
" color: var(--sklearn-color-background);\n",
|
| 818 |
+
" text-decoration: none;\n",
|
| 819 |
+
"}\n",
|
| 820 |
+
"\n",
|
| 821 |
+
"/* Span, style for the box shown on hovering the info icon */\n",
|
| 822 |
+
".sk-estimator-doc-link span {\n",
|
| 823 |
+
" display: none;\n",
|
| 824 |
+
" z-index: 9999;\n",
|
| 825 |
+
" position: relative;\n",
|
| 826 |
+
" font-weight: normal;\n",
|
| 827 |
+
" right: .2ex;\n",
|
| 828 |
+
" padding: .5ex;\n",
|
| 829 |
+
" margin: .5ex;\n",
|
| 830 |
+
" width: min-content;\n",
|
| 831 |
+
" min-width: 20ex;\n",
|
| 832 |
+
" max-width: 50ex;\n",
|
| 833 |
+
" color: var(--sklearn-color-text);\n",
|
| 834 |
+
" box-shadow: 2pt 2pt 4pt #999;\n",
|
| 835 |
+
" /* unfitted */\n",
|
| 836 |
+
" background: var(--sklearn-color-unfitted-level-0);\n",
|
| 837 |
+
" border: .5pt solid var(--sklearn-color-unfitted-level-3);\n",
|
| 838 |
+
"}\n",
|
| 839 |
+
"\n",
|
| 840 |
+
".sk-estimator-doc-link.fitted span {\n",
|
| 841 |
+
" /* fitted */\n",
|
| 842 |
+
" background: var(--sklearn-color-fitted-level-0);\n",
|
| 843 |
+
" border: var(--sklearn-color-fitted-level-3);\n",
|
| 844 |
+
"}\n",
|
| 845 |
+
"\n",
|
| 846 |
+
".sk-estimator-doc-link:hover span {\n",
|
| 847 |
+
" display: block;\n",
|
| 848 |
+
"}\n",
|
| 849 |
+
"\n",
|
| 850 |
+
"/* \"?\"-specific style due to the `<a>` HTML tag */\n",
|
| 851 |
+
"\n",
|
| 852 |
+
"#sk-container-id-1 a.estimator_doc_link {\n",
|
| 853 |
+
" float: right;\n",
|
| 854 |
+
" font-size: 1rem;\n",
|
| 855 |
+
" line-height: 1em;\n",
|
| 856 |
+
" font-family: monospace;\n",
|
| 857 |
+
" background-color: var(--sklearn-color-background);\n",
|
| 858 |
+
" border-radius: 1rem;\n",
|
| 859 |
+
" height: 1rem;\n",
|
| 860 |
+
" width: 1rem;\n",
|
| 861 |
+
" text-decoration: none;\n",
|
| 862 |
+
" /* unfitted */\n",
|
| 863 |
+
" color: var(--sklearn-color-unfitted-level-1);\n",
|
| 864 |
+
" border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
|
| 865 |
+
"}\n",
|
| 866 |
+
"\n",
|
| 867 |
+
"#sk-container-id-1 a.estimator_doc_link.fitted {\n",
|
| 868 |
+
" /* fitted */\n",
|
| 869 |
+
" border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
|
| 870 |
+
" color: var(--sklearn-color-fitted-level-1);\n",
|
| 871 |
+
"}\n",
|
| 872 |
+
"\n",
|
| 873 |
+
"/* On hover */\n",
|
| 874 |
+
"#sk-container-id-1 a.estimator_doc_link:hover {\n",
|
| 875 |
+
" /* unfitted */\n",
|
| 876 |
+
" background-color: var(--sklearn-color-unfitted-level-3);\n",
|
| 877 |
+
" color: var(--sklearn-color-background);\n",
|
| 878 |
+
" text-decoration: none;\n",
|
| 879 |
+
"}\n",
|
| 880 |
+
"\n",
|
| 881 |
+
"#sk-container-id-1 a.estimator_doc_link.fitted:hover {\n",
|
| 882 |
+
" /* fitted */\n",
|
| 883 |
+
" background-color: var(--sklearn-color-fitted-level-3);\n",
|
| 884 |
+
"}\n",
|
| 885 |
+
"</style><div id=\"sk-container-id-1\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>LinearSVC()</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\"><div><div>LinearSVC</div></div><div><a class=\"sk-estimator-doc-link fitted\" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.6/modules/generated/sklearn.svm.LinearSVC.html\">?<span>Documentation for LinearSVC</span></a><span class=\"sk-estimator-doc-link fitted\">i<span>Fitted</span></span></div></label><div class=\"sk-toggleable__content fitted\"><pre>LinearSVC()</pre></div> </div></div></div></div>"
|
| 886 |
+
],
|
| 887 |
+
"text/plain": [
|
| 888 |
+
"LinearSVC()"
|
| 889 |
+
]
|
| 890 |
+
},
|
| 891 |
+
"execution_count": 9,
|
| 892 |
+
"metadata": {},
|
| 893 |
+
"output_type": "execute_result"
|
| 894 |
+
}
|
| 895 |
+
],
|
| 896 |
+
"source": [
|
| 897 |
+
"model = LinearSVC()\n",
|
| 898 |
+
"model.fit(X_train_tfidf,y_train)"
|
| 899 |
+
]
|
| 900 |
+
},
|
| 901 |
+
{
|
| 902 |
+
"cell_type": "code",
|
| 903 |
+
"execution_count": 10,
|
| 904 |
+
"id": "6bfc79e4",
|
| 905 |
+
"metadata": {},
|
| 906 |
+
"outputs": [],
|
| 907 |
+
"source": [
|
| 908 |
+
"from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, roc_auc_score, classification_report\n",
|
| 909 |
+
"def calculate_results(y_true, y_pred, y_pred_proba=None):\n",
|
| 910 |
+
" \"\"\"\n",
|
| 911 |
+
" Tính toán các chỉ số đánh giá, bao gồm accuracy, precision, recall, f1 và roc-auc.\n",
|
| 912 |
+
" Nếu `y_pred_proba` được cung cấp, tính thêm ROC-AUC cho từng nhãn trong bài toán đa nhãn.\n",
|
| 913 |
+
" \"\"\"\n",
|
| 914 |
+
" results = {\n",
|
| 915 |
+
" \"accuracy\": accuracy_score(y_true, y_pred) * 100,\n",
|
| 916 |
+
" \"precision\": precision_score(y_true, y_pred, average='weighted'),\n",
|
| 917 |
+
" \"recall\": recall_score(y_true, y_pred, average='weighted'),\n",
|
| 918 |
+
" \"f1\": f1_score(y_true, y_pred, average='weighted')\n",
|
| 919 |
+
" }\n",
|
| 920 |
+
" \n",
|
| 921 |
+
" return results"
|
| 922 |
+
]
|
| 923 |
+
},
|
| 924 |
+
{
|
| 925 |
+
"cell_type": "code",
|
| 926 |
+
"execution_count": 11,
|
| 927 |
+
"id": "f213c25e",
|
| 928 |
+
"metadata": {},
|
| 929 |
+
"outputs": [
|
| 930 |
+
{
|
| 931 |
+
"name": "stdout",
|
| 932 |
+
"output_type": "stream",
|
| 933 |
+
"text": [
|
| 934 |
+
"{'accuracy': 24.6875, 'precision': 0.23199561875314, 'recall': 0.246875, 'f1': 0.23512261720447172}\n",
|
| 935 |
+
" precision recall f1-score support\n",
|
| 936 |
+
"\n",
|
| 937 |
+
"All-or-nothing thinking 0.00 0.00 0.00 15\n",
|
| 938 |
+
" Emotional Reasoning 0.27 0.20 0.23 30\n",
|
| 939 |
+
" Fortune-telling 0.31 0.33 0.32 24\n",
|
| 940 |
+
" Labeling 0.14 0.10 0.12 40\n",
|
| 941 |
+
" Magnification 0.18 0.16 0.17 37\n",
|
| 942 |
+
" Mental filter 0.15 0.23 0.18 13\n",
|
| 943 |
+
" Mind Reading 0.39 0.52 0.45 54\n",
|
| 944 |
+
" Overgeneralization 0.25 0.32 0.28 50\n",
|
| 945 |
+
" Personalization 0.25 0.18 0.21 39\n",
|
| 946 |
+
" Should statements 0.06 0.06 0.06 18\n",
|
| 947 |
+
"\n",
|
| 948 |
+
" accuracy 0.25 320\n",
|
| 949 |
+
" macro avg 0.20 0.21 0.20 320\n",
|
| 950 |
+
" weighted avg 0.23 0.25 0.24 320\n",
|
| 951 |
+
"\n"
|
| 952 |
+
]
|
| 953 |
+
}
|
| 954 |
+
],
|
| 955 |
+
"source": [
|
| 956 |
+
"y_pred = model.predict(X_test_tfidf)\n",
|
| 957 |
+
"print(calculate_results(y_test, y_pred))\n",
|
| 958 |
+
"print(classification_report(y_test, y_pred))"
|
| 959 |
+
]
|
| 960 |
+
},
|
| 961 |
+
{
|
| 962 |
+
"cell_type": "markdown",
|
| 963 |
+
"id": "7664dae2",
|
| 964 |
+
"metadata": {},
|
| 965 |
+
"source": [
|
| 966 |
+
"# Our methods"
|
| 967 |
+
]
|
| 968 |
+
},
|
| 969 |
+
{
|
| 970 |
+
"cell_type": "code",
|
| 971 |
+
"execution_count": 12,
|
| 972 |
+
"id": "13ccfe1c",
|
| 973 |
+
"metadata": {},
|
| 974 |
+
"outputs": [
|
| 975 |
+
{
|
| 976 |
+
"data": {
|
| 977 |
+
"text/html": [
|
| 978 |
+
"<div>\n",
|
| 979 |
+
"<style scoped>\n",
|
| 980 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 981 |
+
" vertical-align: middle;\n",
|
| 982 |
+
" }\n",
|
| 983 |
+
"\n",
|
| 984 |
+
" .dataframe tbody tr th {\n",
|
| 985 |
+
" vertical-align: top;\n",
|
| 986 |
+
" }\n",
|
| 987 |
+
"\n",
|
| 988 |
+
" .dataframe thead th {\n",
|
| 989 |
+
" text-align: right;\n",
|
| 990 |
+
" }\n",
|
| 991 |
+
"</style>\n",
|
| 992 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 993 |
+
" <thead>\n",
|
| 994 |
+
" <tr style=\"text-align: right;\">\n",
|
| 995 |
+
" <th></th>\n",
|
| 996 |
+
" <th>Id_Number</th>\n",
|
| 997 |
+
" <th>Patient Question</th>\n",
|
| 998 |
+
" <th>Distorted part</th>\n",
|
| 999 |
+
" <th>Dominant Distortion</th>\n",
|
| 1000 |
+
" <th>Secondary Distortion (Optional)</th>\n",
|
| 1001 |
+
" </tr>\n",
|
| 1002 |
+
" </thead>\n",
|
| 1003 |
+
" <tbody>\n",
|
| 1004 |
+
" <tr>\n",
|
| 1005 |
+
" <th>0</th>\n",
|
| 1006 |
+
" <td>4500</td>\n",
|
| 1007 |
+
" <td>Hello, I have a beautiful,smart,outgoing and a...</td>\n",
|
| 1008 |
+
" <td>The voice are always fimilar (someone she know...</td>\n",
|
| 1009 |
+
" <td>Personalization</td>\n",
|
| 1010 |
+
" <td>NaN</td>\n",
|
| 1011 |
+
" </tr>\n",
|
| 1012 |
+
" <tr>\n",
|
| 1013 |
+
" <th>1</th>\n",
|
| 1014 |
+
" <td>4501</td>\n",
|
| 1015 |
+
" <td>Since I was about 16 years old I’ve had these ...</td>\n",
|
| 1016 |
+
" <td>I feel trapped inside my disgusting self and l...</td>\n",
|
| 1017 |
+
" <td>Labeling</td>\n",
|
| 1018 |
+
" <td>Emotional Reasoning</td>\n",
|
| 1019 |
+
" </tr>\n",
|
| 1020 |
+
" <tr>\n",
|
| 1021 |
+
" <th>2</th>\n",
|
| 1022 |
+
" <td>4502</td>\n",
|
| 1023 |
+
" <td>So I’ve been dating on and off this guy for a...</td>\n",
|
| 1024 |
+
" <td>NaN</td>\n",
|
| 1025 |
+
" <td>No Distortion</td>\n",
|
| 1026 |
+
" <td>NaN</td>\n",
|
| 1027 |
+
" </tr>\n",
|
| 1028 |
+
" <tr>\n",
|
| 1029 |
+
" <th>3</th>\n",
|
| 1030 |
+
" <td>4503</td>\n",
|
| 1031 |
+
" <td>My parents got divorced in 2004. My mother has...</td>\n",
|
| 1032 |
+
" <td>NaN</td>\n",
|
| 1033 |
+
" <td>No Distortion</td>\n",
|
| 1034 |
+
" <td>NaN</td>\n",
|
| 1035 |
+
" </tr>\n",
|
| 1036 |
+
" <tr>\n",
|
| 1037 |
+
" <th>4</th>\n",
|
| 1038 |
+
" <td>4504</td>\n",
|
| 1039 |
+
" <td>I don’t really know how to explain the situati...</td>\n",
|
| 1040 |
+
" <td>I refused to go because I didn’t know if it wa...</td>\n",
|
| 1041 |
+
" <td>Fortune-telling</td>\n",
|
| 1042 |
+
" <td>Emotional Reasoning</td>\n",
|
| 1043 |
+
" </tr>\n",
|
| 1044 |
+
" </tbody>\n",
|
| 1045 |
+
"</table>\n",
|
| 1046 |
+
"</div>"
|
| 1047 |
+
],
|
| 1048 |
+
"text/plain": [
|
| 1049 |
+
" Id_Number Patient Question \\\n",
|
| 1050 |
+
"0 4500 Hello, I have a beautiful,smart,outgoing and a... \n",
|
| 1051 |
+
"1 4501 Since I was about 16 years old I’ve had these ... \n",
|
| 1052 |
+
"2 4502 So I’ve been dating on and off this guy for a... \n",
|
| 1053 |
+
"3 4503 My parents got divorced in 2004. My mother has... \n",
|
| 1054 |
+
"4 4504 I don’t really know how to explain the situati... \n",
|
| 1055 |
+
"\n",
|
| 1056 |
+
" Distorted part Dominant Distortion \\\n",
|
| 1057 |
+
"0 The voice are always fimilar (someone she know... Personalization \n",
|
| 1058 |
+
"1 I feel trapped inside my disgusting self and l... Labeling \n",
|
| 1059 |
+
"2 NaN No Distortion \n",
|
| 1060 |
+
"3 NaN No Distortion \n",
|
| 1061 |
+
"4 I refused to go because I didn’t know if it wa... Fortune-telling \n",
|
| 1062 |
+
"\n",
|
| 1063 |
+
" Secondary Distortion (Optional) \n",
|
| 1064 |
+
"0 NaN \n",
|
| 1065 |
+
"1 Emotional Reasoning \n",
|
| 1066 |
+
"2 NaN \n",
|
| 1067 |
+
"3 NaN \n",
|
| 1068 |
+
"4 Emotional Reasoning "
|
| 1069 |
+
]
|
| 1070 |
+
},
|
| 1071 |
+
"execution_count": 12,
|
| 1072 |
+
"metadata": {},
|
| 1073 |
+
"output_type": "execute_result"
|
| 1074 |
+
}
|
| 1075 |
+
],
|
| 1076 |
+
"source": [
|
| 1077 |
+
"df_our = pd.read_csv('data/distortion.csv')\n",
|
| 1078 |
+
"df_our.head()"
|
| 1079 |
+
]
|
| 1080 |
+
},
|
| 1081 |
+
{
|
| 1082 |
+
"cell_type": "code",
|
| 1083 |
+
"execution_count": 13,
|
| 1084 |
+
"id": "6c37e38a",
|
| 1085 |
+
"metadata": {},
|
| 1086 |
+
"outputs": [
|
| 1087 |
+
{
|
| 1088 |
+
"data": {
|
| 1089 |
+
"text/html": [
|
| 1090 |
+
"<div>\n",
|
| 1091 |
+
"<style scoped>\n",
|
| 1092 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 1093 |
+
" vertical-align: middle;\n",
|
| 1094 |
+
" }\n",
|
| 1095 |
+
"\n",
|
| 1096 |
+
" .dataframe tbody tr th {\n",
|
| 1097 |
+
" vertical-align: top;\n",
|
| 1098 |
+
" }\n",
|
| 1099 |
+
"\n",
|
| 1100 |
+
" .dataframe thead th {\n",
|
| 1101 |
+
" text-align: right;\n",
|
| 1102 |
+
" }\n",
|
| 1103 |
+
"</style>\n",
|
| 1104 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 1105 |
+
" <thead>\n",
|
| 1106 |
+
" <tr style=\"text-align: right;\">\n",
|
| 1107 |
+
" <th></th>\n",
|
| 1108 |
+
" <th>Id_Number</th>\n",
|
| 1109 |
+
" <th>Patient Question</th>\n",
|
| 1110 |
+
" <th>Distorted part</th>\n",
|
| 1111 |
+
" <th>Dominant Distortion</th>\n",
|
| 1112 |
+
" <th>Secondary Distortion (Optional)</th>\n",
|
| 1113 |
+
" </tr>\n",
|
| 1114 |
+
" </thead>\n",
|
| 1115 |
+
" <tbody>\n",
|
| 1116 |
+
" <tr>\n",
|
| 1117 |
+
" <th>0</th>\n",
|
| 1118 |
+
" <td>4500</td>\n",
|
| 1119 |
+
" <td>Hello, I have a beautiful,smart,outgoing and a...</td>\n",
|
| 1120 |
+
" <td>The voice are always fimilar (someone she know...</td>\n",
|
| 1121 |
+
" <td>Personalization</td>\n",
|
| 1122 |
+
" <td>NaN</td>\n",
|
| 1123 |
+
" </tr>\n",
|
| 1124 |
+
" <tr>\n",
|
| 1125 |
+
" <th>1</th>\n",
|
| 1126 |
+
" <td>4501</td>\n",
|
| 1127 |
+
" <td>Since I was about 16 years old I’ve had these ...</td>\n",
|
| 1128 |
+
" <td>I feel trapped inside my disgusting self and l...</td>\n",
|
| 1129 |
+
" <td>Labeling</td>\n",
|
| 1130 |
+
" <td>Emotional Reasoning</td>\n",
|
| 1131 |
+
" </tr>\n",
|
| 1132 |
+
" <tr>\n",
|
| 1133 |
+
" <th>4</th>\n",
|
| 1134 |
+
" <td>4504</td>\n",
|
| 1135 |
+
" <td>I don’t really know how to explain the situati...</td>\n",
|
| 1136 |
+
" <td>I refused to go because I didn’t know if it wa...</td>\n",
|
| 1137 |
+
" <td>Fortune-telling</td>\n",
|
| 1138 |
+
" <td>Emotional Reasoning</td>\n",
|
| 1139 |
+
" </tr>\n",
|
| 1140 |
+
" <tr>\n",
|
| 1141 |
+
" <th>9</th>\n",
|
| 1142 |
+
" <td>4510</td>\n",
|
| 1143 |
+
" <td>I have been with my fiancé for two years now....</td>\n",
|
| 1144 |
+
" <td>I felt like the response was totally irrationa...</td>\n",
|
| 1145 |
+
" <td>Magnification</td>\n",
|
| 1146 |
+
" <td>NaN</td>\n",
|
| 1147 |
+
" </tr>\n",
|
| 1148 |
+
" <tr>\n",
|
| 1149 |
+
" <th>10</th>\n",
|
| 1150 |
+
" <td>4511</td>\n",
|
| 1151 |
+
" <td>My husband and I have been married for over a ...</td>\n",
|
| 1152 |
+
" <td>I thought that he displayed traits of honor, l...</td>\n",
|
| 1153 |
+
" <td>Labeling</td>\n",
|
| 1154 |
+
" <td>NaN</td>\n",
|
| 1155 |
+
" </tr>\n",
|
| 1156 |
+
" </tbody>\n",
|
| 1157 |
+
"</table>\n",
|
| 1158 |
+
"</div>"
|
| 1159 |
+
],
|
| 1160 |
+
"text/plain": [
|
| 1161 |
+
" Id_Number Patient Question \\\n",
|
| 1162 |
+
"0 4500 Hello, I have a beautiful,smart,outgoing and a... \n",
|
| 1163 |
+
"1 4501 Since I was about 16 years old I’ve had these ... \n",
|
| 1164 |
+
"4 4504 I don’t really know how to explain the situati... \n",
|
| 1165 |
+
"9 4510 I have been with my fiancé for two years now.... \n",
|
| 1166 |
+
"10 4511 My husband and I have been married for over a ... \n",
|
| 1167 |
+
"\n",
|
| 1168 |
+
" Distorted part Dominant Distortion \\\n",
|
| 1169 |
+
"0 The voice are always fimilar (someone she know... Personalization \n",
|
| 1170 |
+
"1 I feel trapped inside my disgusting self and l... Labeling \n",
|
| 1171 |
+
"4 I refused to go because I didn’t know if it wa... Fortune-telling \n",
|
| 1172 |
+
"9 I felt like the response was totally irrationa... Magnification \n",
|
| 1173 |
+
"10 I thought that he displayed traits of honor, l... Labeling \n",
|
| 1174 |
+
"\n",
|
| 1175 |
+
" Secondary Distortion (Optional) \n",
|
| 1176 |
+
"0 NaN \n",
|
| 1177 |
+
"1 Emotional Reasoning \n",
|
| 1178 |
+
"4 Emotional Reasoning \n",
|
| 1179 |
+
"9 NaN \n",
|
| 1180 |
+
"10 NaN "
|
| 1181 |
+
]
|
| 1182 |
+
},
|
| 1183 |
+
"execution_count": 13,
|
| 1184 |
+
"metadata": {},
|
| 1185 |
+
"output_type": "execute_result"
|
| 1186 |
+
}
|
| 1187 |
+
],
|
| 1188 |
+
"source": [
|
| 1189 |
+
"df_our = df_our[df_our['Dominant Distortion'] != 'No Distortion']\n",
|
| 1190 |
+
"df_our.head()"
|
| 1191 |
+
]
|
| 1192 |
+
},
|
| 1193 |
+
{
|
| 1194 |
+
"cell_type": "code",
|
| 1195 |
+
"execution_count": 14,
|
| 1196 |
+
"id": "1503580c",
|
| 1197 |
+
"metadata": {},
|
| 1198 |
+
"outputs": [],
|
| 1199 |
+
"source": [
|
| 1200 |
+
"# df_our = df_our.dropna()"
|
| 1201 |
+
]
|
| 1202 |
+
},
|
| 1203 |
+
{
|
| 1204 |
+
"cell_type": "code",
|
| 1205 |
+
"execution_count": 15,
|
| 1206 |
+
"id": "597bb4ca",
|
| 1207 |
+
"metadata": {},
|
| 1208 |
+
"outputs": [],
|
| 1209 |
+
"source": [
|
| 1210 |
+
"df_our['cleaned'] = df_our['Distorted part'].map(lambda text: preprocess_text(text))"
|
| 1211 |
+
]
|
| 1212 |
+
},
|
| 1213 |
+
{
|
| 1214 |
+
"cell_type": "code",
|
| 1215 |
+
"execution_count": 16,
|
| 1216 |
+
"id": "626adab6",
|
| 1217 |
+
"metadata": {},
|
| 1218 |
+
"outputs": [],
|
| 1219 |
+
"source": [
|
| 1220 |
+
"df_our['cleaned_full'] = df_our['Patient Question'].map(lambda text: preprocess_text(text))"
|
| 1221 |
+
]
|
| 1222 |
+
},
|
| 1223 |
+
{
|
| 1224 |
+
"cell_type": "code",
|
| 1225 |
+
"execution_count": 17,
|
| 1226 |
+
"id": "b573c357",
|
| 1227 |
+
"metadata": {},
|
| 1228 |
+
"outputs": [],
|
| 1229 |
+
"source": [
|
| 1230 |
+
"from sklearn.model_selection import train_test_split\n",
|
| 1231 |
+
"\n",
|
| 1232 |
+
"train_full, test_full, _, _ = train_test_split(df_our['cleaned_full'].values,\n",
|
| 1233 |
+
" df_our['Dominant Distortion'].values,\n",
|
| 1234 |
+
" test_size=0.2, random_state=42)\n",
|
| 1235 |
+
"\n",
|
| 1236 |
+
"X_train_our, X_test_our, y_train_our, y_test_our = train_test_split(df_our['cleaned'].values,\n",
|
| 1237 |
+
" df_our['Dominant Distortion'].values,\n",
|
| 1238 |
+
" test_size=0.2, random_state=42)"
|
| 1239 |
+
]
|
| 1240 |
+
},
|
| 1241 |
+
{
|
| 1242 |
+
"cell_type": "code",
|
| 1243 |
+
"execution_count": 18,
|
| 1244 |
+
"id": "2a3b3c97",
|
| 1245 |
+
"metadata": {},
|
| 1246 |
+
"outputs": [],
|
| 1247 |
+
"source": [
|
| 1248 |
+
"from sklearn.feature_extraction.text import TfidfVectorizer\n",
|
| 1249 |
+
"\n",
|
| 1250 |
+
"tfidf_vectorizer_our = TfidfVectorizer()\n",
|
| 1251 |
+
"X_train_tfidf_our = tfidf_vectorizer_our.fit_transform(X_train_our)\n",
|
| 1252 |
+
"X_test_tfidf_our = tfidf_vectorizer_our.transform(X_test_our)"
|
| 1253 |
+
]
|
| 1254 |
+
},
|
| 1255 |
+
{
|
| 1256 |
+
"cell_type": "code",
|
| 1257 |
+
"execution_count": 19,
|
| 1258 |
+
"id": "894cf240",
|
| 1259 |
+
"metadata": {},
|
| 1260 |
+
"outputs": [
|
| 1261 |
+
{
|
| 1262 |
+
"data": {
|
| 1263 |
+
"text/html": [
|
| 1264 |
+
"<style>#sk-container-id-2 {\n",
|
| 1265 |
+
" /* Definition of color scheme common for light and dark mode */\n",
|
| 1266 |
+
" --sklearn-color-text: #000;\n",
|
| 1267 |
+
" --sklearn-color-text-muted: #666;\n",
|
| 1268 |
+
" --sklearn-color-line: gray;\n",
|
| 1269 |
+
" /* Definition of color scheme for unfitted estimators */\n",
|
| 1270 |
+
" --sklearn-color-unfitted-level-0: #fff5e6;\n",
|
| 1271 |
+
" --sklearn-color-unfitted-level-1: #f6e4d2;\n",
|
| 1272 |
+
" --sklearn-color-unfitted-level-2: #ffe0b3;\n",
|
| 1273 |
+
" --sklearn-color-unfitted-level-3: chocolate;\n",
|
| 1274 |
+
" /* Definition of color scheme for fitted estimators */\n",
|
| 1275 |
+
" --sklearn-color-fitted-level-0: #f0f8ff;\n",
|
| 1276 |
+
" --sklearn-color-fitted-level-1: #d4ebff;\n",
|
| 1277 |
+
" --sklearn-color-fitted-level-2: #b3dbfd;\n",
|
| 1278 |
+
" --sklearn-color-fitted-level-3: cornflowerblue;\n",
|
| 1279 |
+
"\n",
|
| 1280 |
+
" /* Specific color for light theme */\n",
|
| 1281 |
+
" --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
|
| 1282 |
+
" --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, white)));\n",
|
| 1283 |
+
" --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, black)));\n",
|
| 1284 |
+
" --sklearn-color-icon: #696969;\n",
|
| 1285 |
+
"\n",
|
| 1286 |
+
" @media (prefers-color-scheme: dark) {\n",
|
| 1287 |
+
" /* Redefinition of color scheme for dark theme */\n",
|
| 1288 |
+
" --sklearn-color-text-on-default-background: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
|
| 1289 |
+
" --sklearn-color-background: var(--sg-background-color, var(--theme-background, var(--jp-layout-color0, #111)));\n",
|
| 1290 |
+
" --sklearn-color-border-box: var(--sg-text-color, var(--theme-code-foreground, var(--jp-content-font-color1, white)));\n",
|
| 1291 |
+
" --sklearn-color-icon: #878787;\n",
|
| 1292 |
+
" }\n",
|
| 1293 |
+
"}\n",
|
| 1294 |
+
"\n",
|
| 1295 |
+
"#sk-container-id-2 {\n",
|
| 1296 |
+
" color: var(--sklearn-color-text);\n",
|
| 1297 |
+
"}\n",
|
| 1298 |
+
"\n",
|
| 1299 |
+
"#sk-container-id-2 pre {\n",
|
| 1300 |
+
" padding: 0;\n",
|
| 1301 |
+
"}\n",
|
| 1302 |
+
"\n",
|
| 1303 |
+
"#sk-container-id-2 input.sk-hidden--visually {\n",
|
| 1304 |
+
" border: 0;\n",
|
| 1305 |
+
" clip: rect(1px 1px 1px 1px);\n",
|
| 1306 |
+
" clip: rect(1px, 1px, 1px, 1px);\n",
|
| 1307 |
+
" height: 1px;\n",
|
| 1308 |
+
" margin: -1px;\n",
|
| 1309 |
+
" overflow: hidden;\n",
|
| 1310 |
+
" padding: 0;\n",
|
| 1311 |
+
" position: absolute;\n",
|
| 1312 |
+
" width: 1px;\n",
|
| 1313 |
+
"}\n",
|
| 1314 |
+
"\n",
|
| 1315 |
+
"#sk-container-id-2 div.sk-dashed-wrapped {\n",
|
| 1316 |
+
" border: 1px dashed var(--sklearn-color-line);\n",
|
| 1317 |
+
" margin: 0 0.4em 0.5em 0.4em;\n",
|
| 1318 |
+
" box-sizing: border-box;\n",
|
| 1319 |
+
" padding-bottom: 0.4em;\n",
|
| 1320 |
+
" background-color: var(--sklearn-color-background);\n",
|
| 1321 |
+
"}\n",
|
| 1322 |
+
"\n",
|
| 1323 |
+
"#sk-container-id-2 div.sk-container {\n",
|
| 1324 |
+
" /* jupyter's `normalize.less` sets `[hidden] { display: none; }`\n",
|
| 1325 |
+
" but bootstrap.min.css set `[hidden] { display: none !important; }`\n",
|
| 1326 |
+
" so we also need the `!important` here to be able to override the\n",
|
| 1327 |
+
" default hidden behavior on the sphinx rendered scikit-learn.org.\n",
|
| 1328 |
+
" See: https://github.com/scikit-learn/scikit-learn/issues/21755 */\n",
|
| 1329 |
+
" display: inline-block !important;\n",
|
| 1330 |
+
" position: relative;\n",
|
| 1331 |
+
"}\n",
|
| 1332 |
+
"\n",
|
| 1333 |
+
"#sk-container-id-2 div.sk-text-repr-fallback {\n",
|
| 1334 |
+
" display: none;\n",
|
| 1335 |
+
"}\n",
|
| 1336 |
+
"\n",
|
| 1337 |
+
"div.sk-parallel-item,\n",
|
| 1338 |
+
"div.sk-serial,\n",
|
| 1339 |
+
"div.sk-item {\n",
|
| 1340 |
+
" /* draw centered vertical line to link estimators */\n",
|
| 1341 |
+
" background-image: linear-gradient(var(--sklearn-color-text-on-default-background), var(--sklearn-color-text-on-default-background));\n",
|
| 1342 |
+
" background-size: 2px 100%;\n",
|
| 1343 |
+
" background-repeat: no-repeat;\n",
|
| 1344 |
+
" background-position: center center;\n",
|
| 1345 |
+
"}\n",
|
| 1346 |
+
"\n",
|
| 1347 |
+
"/* Parallel-specific style estimator block */\n",
|
| 1348 |
+
"\n",
|
| 1349 |
+
"#sk-container-id-2 div.sk-parallel-item::after {\n",
|
| 1350 |
+
" content: \"\";\n",
|
| 1351 |
+
" width: 100%;\n",
|
| 1352 |
+
" border-bottom: 2px solid var(--sklearn-color-text-on-default-background);\n",
|
| 1353 |
+
" flex-grow: 1;\n",
|
| 1354 |
+
"}\n",
|
| 1355 |
+
"\n",
|
| 1356 |
+
"#sk-container-id-2 div.sk-parallel {\n",
|
| 1357 |
+
" display: flex;\n",
|
| 1358 |
+
" align-items: stretch;\n",
|
| 1359 |
+
" justify-content: center;\n",
|
| 1360 |
+
" background-color: var(--sklearn-color-background);\n",
|
| 1361 |
+
" position: relative;\n",
|
| 1362 |
+
"}\n",
|
| 1363 |
+
"\n",
|
| 1364 |
+
"#sk-container-id-2 div.sk-parallel-item {\n",
|
| 1365 |
+
" display: flex;\n",
|
| 1366 |
+
" flex-direction: column;\n",
|
| 1367 |
+
"}\n",
|
| 1368 |
+
"\n",
|
| 1369 |
+
"#sk-container-id-2 div.sk-parallel-item:first-child::after {\n",
|
| 1370 |
+
" align-self: flex-end;\n",
|
| 1371 |
+
" width: 50%;\n",
|
| 1372 |
+
"}\n",
|
| 1373 |
+
"\n",
|
| 1374 |
+
"#sk-container-id-2 div.sk-parallel-item:last-child::after {\n",
|
| 1375 |
+
" align-self: flex-start;\n",
|
| 1376 |
+
" width: 50%;\n",
|
| 1377 |
+
"}\n",
|
| 1378 |
+
"\n",
|
| 1379 |
+
"#sk-container-id-2 div.sk-parallel-item:only-child::after {\n",
|
| 1380 |
+
" width: 0;\n",
|
| 1381 |
+
"}\n",
|
| 1382 |
+
"\n",
|
| 1383 |
+
"/* Serial-specific style estimator block */\n",
|
| 1384 |
+
"\n",
|
| 1385 |
+
"#sk-container-id-2 div.sk-serial {\n",
|
| 1386 |
+
" display: flex;\n",
|
| 1387 |
+
" flex-direction: column;\n",
|
| 1388 |
+
" align-items: center;\n",
|
| 1389 |
+
" background-color: var(--sklearn-color-background);\n",
|
| 1390 |
+
" padding-right: 1em;\n",
|
| 1391 |
+
" padding-left: 1em;\n",
|
| 1392 |
+
"}\n",
|
| 1393 |
+
"\n",
|
| 1394 |
+
"\n",
|
| 1395 |
+
"/* Toggleable style: style used for estimator/Pipeline/ColumnTransformer box that is\n",
|
| 1396 |
+
"clickable and can be expanded/collapsed.\n",
|
| 1397 |
+
"- Pipeline and ColumnTransformer use this feature and define the default style\n",
|
| 1398 |
+
"- Estimators will overwrite some part of the style using the `sk-estimator` class\n",
|
| 1399 |
+
"*/\n",
|
| 1400 |
+
"\n",
|
| 1401 |
+
"/* Pipeline and ColumnTransformer style (default) */\n",
|
| 1402 |
+
"\n",
|
| 1403 |
+
"#sk-container-id-2 div.sk-toggleable {\n",
|
| 1404 |
+
" /* Default theme specific background. It is overwritten whether we have a\n",
|
| 1405 |
+
" specific estimator or a Pipeline/ColumnTransformer */\n",
|
| 1406 |
+
" background-color: var(--sklearn-color-background);\n",
|
| 1407 |
+
"}\n",
|
| 1408 |
+
"\n",
|
| 1409 |
+
"/* Toggleable label */\n",
|
| 1410 |
+
"#sk-container-id-2 label.sk-toggleable__label {\n",
|
| 1411 |
+
" cursor: pointer;\n",
|
| 1412 |
+
" display: flex;\n",
|
| 1413 |
+
" width: 100%;\n",
|
| 1414 |
+
" margin-bottom: 0;\n",
|
| 1415 |
+
" padding: 0.5em;\n",
|
| 1416 |
+
" box-sizing: border-box;\n",
|
| 1417 |
+
" text-align: center;\n",
|
| 1418 |
+
" align-items: start;\n",
|
| 1419 |
+
" justify-content: space-between;\n",
|
| 1420 |
+
" gap: 0.5em;\n",
|
| 1421 |
+
"}\n",
|
| 1422 |
+
"\n",
|
| 1423 |
+
"#sk-container-id-2 label.sk-toggleable__label .caption {\n",
|
| 1424 |
+
" font-size: 0.6rem;\n",
|
| 1425 |
+
" font-weight: lighter;\n",
|
| 1426 |
+
" color: var(--sklearn-color-text-muted);\n",
|
| 1427 |
+
"}\n",
|
| 1428 |
+
"\n",
|
| 1429 |
+
"#sk-container-id-2 label.sk-toggleable__label-arrow:before {\n",
|
| 1430 |
+
" /* Arrow on the left of the label */\n",
|
| 1431 |
+
" content: \"▸\";\n",
|
| 1432 |
+
" float: left;\n",
|
| 1433 |
+
" margin-right: 0.25em;\n",
|
| 1434 |
+
" color: var(--sklearn-color-icon);\n",
|
| 1435 |
+
"}\n",
|
| 1436 |
+
"\n",
|
| 1437 |
+
"#sk-container-id-2 label.sk-toggleable__label-arrow:hover:before {\n",
|
| 1438 |
+
" color: var(--sklearn-color-text);\n",
|
| 1439 |
+
"}\n",
|
| 1440 |
+
"\n",
|
| 1441 |
+
"/* Toggleable content - dropdown */\n",
|
| 1442 |
+
"\n",
|
| 1443 |
+
"#sk-container-id-2 div.sk-toggleable__content {\n",
|
| 1444 |
+
" max-height: 0;\n",
|
| 1445 |
+
" max-width: 0;\n",
|
| 1446 |
+
" overflow: hidden;\n",
|
| 1447 |
+
" text-align: left;\n",
|
| 1448 |
+
" /* unfitted */\n",
|
| 1449 |
+
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
| 1450 |
+
"}\n",
|
| 1451 |
+
"\n",
|
| 1452 |
+
"#sk-container-id-2 div.sk-toggleable__content.fitted {\n",
|
| 1453 |
+
" /* fitted */\n",
|
| 1454 |
+
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
| 1455 |
+
"}\n",
|
| 1456 |
+
"\n",
|
| 1457 |
+
"#sk-container-id-2 div.sk-toggleable__content pre {\n",
|
| 1458 |
+
" margin: 0.2em;\n",
|
| 1459 |
+
" border-radius: 0.25em;\n",
|
| 1460 |
+
" color: var(--sklearn-color-text);\n",
|
| 1461 |
+
" /* unfitted */\n",
|
| 1462 |
+
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
| 1463 |
+
"}\n",
|
| 1464 |
+
"\n",
|
| 1465 |
+
"#sk-container-id-2 div.sk-toggleable__content.fitted pre {\n",
|
| 1466 |
+
" /* unfitted */\n",
|
| 1467 |
+
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
| 1468 |
+
"}\n",
|
| 1469 |
+
"\n",
|
| 1470 |
+
"#sk-container-id-2 input.sk-toggleable__control:checked~div.sk-toggleable__content {\n",
|
| 1471 |
+
" /* Expand drop-down */\n",
|
| 1472 |
+
" max-height: 200px;\n",
|
| 1473 |
+
" max-width: 100%;\n",
|
| 1474 |
+
" overflow: auto;\n",
|
| 1475 |
+
"}\n",
|
| 1476 |
+
"\n",
|
| 1477 |
+
"#sk-container-id-2 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {\n",
|
| 1478 |
+
" content: \"▾\";\n",
|
| 1479 |
+
"}\n",
|
| 1480 |
+
"\n",
|
| 1481 |
+
"/* Pipeline/ColumnTransformer-specific style */\n",
|
| 1482 |
+
"\n",
|
| 1483 |
+
"#sk-container-id-2 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
| 1484 |
+
" color: var(--sklearn-color-text);\n",
|
| 1485 |
+
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
| 1486 |
+
"}\n",
|
| 1487 |
+
"\n",
|
| 1488 |
+
"#sk-container-id-2 div.sk-label.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
| 1489 |
+
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
| 1490 |
+
"}\n",
|
| 1491 |
+
"\n",
|
| 1492 |
+
"/* Estimator-specific style */\n",
|
| 1493 |
+
"\n",
|
| 1494 |
+
"/* Colorize estimator box */\n",
|
| 1495 |
+
"#sk-container-id-2 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
| 1496 |
+
" /* unfitted */\n",
|
| 1497 |
+
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
| 1498 |
+
"}\n",
|
| 1499 |
+
"\n",
|
| 1500 |
+
"#sk-container-id-2 div.sk-estimator.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
|
| 1501 |
+
" /* fitted */\n",
|
| 1502 |
+
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
| 1503 |
+
"}\n",
|
| 1504 |
+
"\n",
|
| 1505 |
+
"#sk-container-id-2 div.sk-label label.sk-toggleable__label,\n",
|
| 1506 |
+
"#sk-container-id-2 div.sk-label label {\n",
|
| 1507 |
+
" /* The background is the default theme color */\n",
|
| 1508 |
+
" color: var(--sklearn-color-text-on-default-background);\n",
|
| 1509 |
+
"}\n",
|
| 1510 |
+
"\n",
|
| 1511 |
+
"/* On hover, darken the color of the background */\n",
|
| 1512 |
+
"#sk-container-id-2 div.sk-label:hover label.sk-toggleable__label {\n",
|
| 1513 |
+
" color: var(--sklearn-color-text);\n",
|
| 1514 |
+
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
| 1515 |
+
"}\n",
|
| 1516 |
+
"\n",
|
| 1517 |
+
"/* Label box, darken color on hover, fitted */\n",
|
| 1518 |
+
"#sk-container-id-2 div.sk-label.fitted:hover label.sk-toggleable__label.fitted {\n",
|
| 1519 |
+
" color: var(--sklearn-color-text);\n",
|
| 1520 |
+
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
| 1521 |
+
"}\n",
|
| 1522 |
+
"\n",
|
| 1523 |
+
"/* Estimator label */\n",
|
| 1524 |
+
"\n",
|
| 1525 |
+
"#sk-container-id-2 div.sk-label label {\n",
|
| 1526 |
+
" font-family: monospace;\n",
|
| 1527 |
+
" font-weight: bold;\n",
|
| 1528 |
+
" display: inline-block;\n",
|
| 1529 |
+
" line-height: 1.2em;\n",
|
| 1530 |
+
"}\n",
|
| 1531 |
+
"\n",
|
| 1532 |
+
"#sk-container-id-2 div.sk-label-container {\n",
|
| 1533 |
+
" text-align: center;\n",
|
| 1534 |
+
"}\n",
|
| 1535 |
+
"\n",
|
| 1536 |
+
"/* Estimator-specific */\n",
|
| 1537 |
+
"#sk-container-id-2 div.sk-estimator {\n",
|
| 1538 |
+
" font-family: monospace;\n",
|
| 1539 |
+
" border: 1px dotted var(--sklearn-color-border-box);\n",
|
| 1540 |
+
" border-radius: 0.25em;\n",
|
| 1541 |
+
" box-sizing: border-box;\n",
|
| 1542 |
+
" margin-bottom: 0.5em;\n",
|
| 1543 |
+
" /* unfitted */\n",
|
| 1544 |
+
" background-color: var(--sklearn-color-unfitted-level-0);\n",
|
| 1545 |
+
"}\n",
|
| 1546 |
+
"\n",
|
| 1547 |
+
"#sk-container-id-2 div.sk-estimator.fitted {\n",
|
| 1548 |
+
" /* fitted */\n",
|
| 1549 |
+
" background-color: var(--sklearn-color-fitted-level-0);\n",
|
| 1550 |
+
"}\n",
|
| 1551 |
+
"\n",
|
| 1552 |
+
"/* on hover */\n",
|
| 1553 |
+
"#sk-container-id-2 div.sk-estimator:hover {\n",
|
| 1554 |
+
" /* unfitted */\n",
|
| 1555 |
+
" background-color: var(--sklearn-color-unfitted-level-2);\n",
|
| 1556 |
+
"}\n",
|
| 1557 |
+
"\n",
|
| 1558 |
+
"#sk-container-id-2 div.sk-estimator.fitted:hover {\n",
|
| 1559 |
+
" /* fitted */\n",
|
| 1560 |
+
" background-color: var(--sklearn-color-fitted-level-2);\n",
|
| 1561 |
+
"}\n",
|
| 1562 |
+
"\n",
|
| 1563 |
+
"/* Specification for estimator info (e.g. \"i\" and \"?\") */\n",
|
| 1564 |
+
"\n",
|
| 1565 |
+
"/* Common style for \"i\" and \"?\" */\n",
|
| 1566 |
+
"\n",
|
| 1567 |
+
".sk-estimator-doc-link,\n",
|
| 1568 |
+
"a:link.sk-estimator-doc-link,\n",
|
| 1569 |
+
"a:visited.sk-estimator-doc-link {\n",
|
| 1570 |
+
" float: right;\n",
|
| 1571 |
+
" font-size: smaller;\n",
|
| 1572 |
+
" line-height: 1em;\n",
|
| 1573 |
+
" font-family: monospace;\n",
|
| 1574 |
+
" background-color: var(--sklearn-color-background);\n",
|
| 1575 |
+
" border-radius: 1em;\n",
|
| 1576 |
+
" height: 1em;\n",
|
| 1577 |
+
" width: 1em;\n",
|
| 1578 |
+
" text-decoration: none !important;\n",
|
| 1579 |
+
" margin-left: 0.5em;\n",
|
| 1580 |
+
" text-align: center;\n",
|
| 1581 |
+
" /* unfitted */\n",
|
| 1582 |
+
" border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
|
| 1583 |
+
" color: var(--sklearn-color-unfitted-level-1);\n",
|
| 1584 |
+
"}\n",
|
| 1585 |
+
"\n",
|
| 1586 |
+
".sk-estimator-doc-link.fitted,\n",
|
| 1587 |
+
"a:link.sk-estimator-doc-link.fitted,\n",
|
| 1588 |
+
"a:visited.sk-estimator-doc-link.fitted {\n",
|
| 1589 |
+
" /* fitted */\n",
|
| 1590 |
+
" border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
|
| 1591 |
+
" color: var(--sklearn-color-fitted-level-1);\n",
|
| 1592 |
+
"}\n",
|
| 1593 |
+
"\n",
|
| 1594 |
+
"/* On hover */\n",
|
| 1595 |
+
"div.sk-estimator:hover .sk-estimator-doc-link:hover,\n",
|
| 1596 |
+
".sk-estimator-doc-link:hover,\n",
|
| 1597 |
+
"div.sk-label-container:hover .sk-estimator-doc-link:hover,\n",
|
| 1598 |
+
".sk-estimator-doc-link:hover {\n",
|
| 1599 |
+
" /* unfitted */\n",
|
| 1600 |
+
" background-color: var(--sklearn-color-unfitted-level-3);\n",
|
| 1601 |
+
" color: var(--sklearn-color-background);\n",
|
| 1602 |
+
" text-decoration: none;\n",
|
| 1603 |
+
"}\n",
|
| 1604 |
+
"\n",
|
| 1605 |
+
"div.sk-estimator.fitted:hover .sk-estimator-doc-link.fitted:hover,\n",
|
| 1606 |
+
".sk-estimator-doc-link.fitted:hover,\n",
|
| 1607 |
+
"div.sk-label-container:hover .sk-estimator-doc-link.fitted:hover,\n",
|
| 1608 |
+
".sk-estimator-doc-link.fitted:hover {\n",
|
| 1609 |
+
" /* fitted */\n",
|
| 1610 |
+
" background-color: var(--sklearn-color-fitted-level-3);\n",
|
| 1611 |
+
" color: var(--sklearn-color-background);\n",
|
| 1612 |
+
" text-decoration: none;\n",
|
| 1613 |
+
"}\n",
|
| 1614 |
+
"\n",
|
| 1615 |
+
"/* Span, style for the box shown on hovering the info icon */\n",
|
| 1616 |
+
".sk-estimator-doc-link span {\n",
|
| 1617 |
+
" display: none;\n",
|
| 1618 |
+
" z-index: 9999;\n",
|
| 1619 |
+
" position: relative;\n",
|
| 1620 |
+
" font-weight: normal;\n",
|
| 1621 |
+
" right: .2ex;\n",
|
| 1622 |
+
" padding: .5ex;\n",
|
| 1623 |
+
" margin: .5ex;\n",
|
| 1624 |
+
" width: min-content;\n",
|
| 1625 |
+
" min-width: 20ex;\n",
|
| 1626 |
+
" max-width: 50ex;\n",
|
| 1627 |
+
" color: var(--sklearn-color-text);\n",
|
| 1628 |
+
" box-shadow: 2pt 2pt 4pt #999;\n",
|
| 1629 |
+
" /* unfitted */\n",
|
| 1630 |
+
" background: var(--sklearn-color-unfitted-level-0);\n",
|
| 1631 |
+
" border: .5pt solid var(--sklearn-color-unfitted-level-3);\n",
|
| 1632 |
+
"}\n",
|
| 1633 |
+
"\n",
|
| 1634 |
+
".sk-estimator-doc-link.fitted span {\n",
|
| 1635 |
+
" /* fitted */\n",
|
| 1636 |
+
" background: var(--sklearn-color-fitted-level-0);\n",
|
| 1637 |
+
" border: var(--sklearn-color-fitted-level-3);\n",
|
| 1638 |
+
"}\n",
|
| 1639 |
+
"\n",
|
| 1640 |
+
".sk-estimator-doc-link:hover span {\n",
|
| 1641 |
+
" display: block;\n",
|
| 1642 |
+
"}\n",
|
| 1643 |
+
"\n",
|
| 1644 |
+
"/* \"?\"-specific style due to the `<a>` HTML tag */\n",
|
| 1645 |
+
"\n",
|
| 1646 |
+
"#sk-container-id-2 a.estimator_doc_link {\n",
|
| 1647 |
+
" float: right;\n",
|
| 1648 |
+
" font-size: 1rem;\n",
|
| 1649 |
+
" line-height: 1em;\n",
|
| 1650 |
+
" font-family: monospace;\n",
|
| 1651 |
+
" background-color: var(--sklearn-color-background);\n",
|
| 1652 |
+
" border-radius: 1rem;\n",
|
| 1653 |
+
" height: 1rem;\n",
|
| 1654 |
+
" width: 1rem;\n",
|
| 1655 |
+
" text-decoration: none;\n",
|
| 1656 |
+
" /* unfitted */\n",
|
| 1657 |
+
" color: var(--sklearn-color-unfitted-level-1);\n",
|
| 1658 |
+
" border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
|
| 1659 |
+
"}\n",
|
| 1660 |
+
"\n",
|
| 1661 |
+
"#sk-container-id-2 a.estimator_doc_link.fitted {\n",
|
| 1662 |
+
" /* fitted */\n",
|
| 1663 |
+
" border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
|
| 1664 |
+
" color: var(--sklearn-color-fitted-level-1);\n",
|
| 1665 |
+
"}\n",
|
| 1666 |
+
"\n",
|
| 1667 |
+
"/* On hover */\n",
|
| 1668 |
+
"#sk-container-id-2 a.estimator_doc_link:hover {\n",
|
| 1669 |
+
" /* unfitted */\n",
|
| 1670 |
+
" background-color: var(--sklearn-color-unfitted-level-3);\n",
|
| 1671 |
+
" color: var(--sklearn-color-background);\n",
|
| 1672 |
+
" text-decoration: none;\n",
|
| 1673 |
+
"}\n",
|
| 1674 |
+
"\n",
|
| 1675 |
+
"#sk-container-id-2 a.estimator_doc_link.fitted:hover {\n",
|
| 1676 |
+
" /* fitted */\n",
|
| 1677 |
+
" background-color: var(--sklearn-color-fitted-level-3);\n",
|
| 1678 |
+
"}\n",
|
| 1679 |
+
"</style><div id=\"sk-container-id-2\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>LinearSVC()</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-2\" type=\"checkbox\" checked><label for=\"sk-estimator-id-2\" class=\"sk-toggleable__label fitted sk-toggleable__label-arrow\"><div><div>LinearSVC</div></div><div><a class=\"sk-estimator-doc-link fitted\" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.6/modules/generated/sklearn.svm.LinearSVC.html\">?<span>Documentation for LinearSVC</span></a><span class=\"sk-estimator-doc-link fitted\">i<span>Fitted</span></span></div></label><div class=\"sk-toggleable__content fitted\"><pre>LinearSVC()</pre></div> </div></div></div></div>"
|
| 1680 |
+
],
|
| 1681 |
+
"text/plain": [
|
| 1682 |
+
"LinearSVC()"
|
| 1683 |
+
]
|
| 1684 |
+
},
|
| 1685 |
+
"execution_count": 19,
|
| 1686 |
+
"metadata": {},
|
| 1687 |
+
"output_type": "execute_result"
|
| 1688 |
+
}
|
| 1689 |
+
],
|
| 1690 |
+
"source": [
|
| 1691 |
+
"model = LinearSVC()\n",
|
| 1692 |
+
"model.fit(X_train_tfidf_our,y_train_our)"
|
| 1693 |
+
]
|
| 1694 |
+
},
|
| 1695 |
+
{
|
| 1696 |
+
"cell_type": "code",
|
| 1697 |
+
"execution_count": 20,
|
| 1698 |
+
"id": "c52c869e",
|
| 1699 |
+
"metadata": {},
|
| 1700 |
+
"outputs": [
|
| 1701 |
+
{
|
| 1702 |
+
"name": "stdout",
|
| 1703 |
+
"output_type": "stream",
|
| 1704 |
+
"text": [
|
| 1705 |
+
"{'accuracy': 34.6875, 'precision': 0.36036002269633405, 'recall': 0.346875, 'f1': 0.34796169864321225}\n",
|
| 1706 |
+
" precision recall f1-score support\n",
|
| 1707 |
+
"\n",
|
| 1708 |
+
"All-or-nothing thinking 0.15 0.13 0.14 15\n",
|
| 1709 |
+
" Emotional Reasoning 0.35 0.20 0.26 30\n",
|
| 1710 |
+
" Fortune-telling 0.54 0.58 0.56 24\n",
|
| 1711 |
+
" Labeling 0.44 0.35 0.39 40\n",
|
| 1712 |
+
" Magnification 0.30 0.24 0.27 37\n",
|
| 1713 |
+
" Mental filter 0.06 0.15 0.09 13\n",
|
| 1714 |
+
" Mind Reading 0.48 0.57 0.52 54\n",
|
| 1715 |
+
" Overgeneralization 0.29 0.34 0.31 50\n",
|
| 1716 |
+
" Personalization 0.33 0.28 0.31 39\n",
|
| 1717 |
+
" Should statements 0.38 0.28 0.32 18\n",
|
| 1718 |
+
"\n",
|
| 1719 |
+
" accuracy 0.35 320\n",
|
| 1720 |
+
" macro avg 0.33 0.31 0.32 320\n",
|
| 1721 |
+
" weighted avg 0.36 0.35 0.35 320\n",
|
| 1722 |
+
"\n"
|
| 1723 |
+
]
|
| 1724 |
+
}
|
| 1725 |
+
],
|
| 1726 |
+
"source": [
|
| 1727 |
+
"y_pred_our = model.predict(X_test_tfidf_our)\n",
|
| 1728 |
+
"print(calculate_results(y_test_our, y_pred_our))\n",
|
| 1729 |
+
"print(classification_report(y_test_our, y_pred_our))"
|
| 1730 |
+
]
|
| 1731 |
+
},
|
| 1732 |
+
{
|
| 1733 |
+
"cell_type": "code",
|
| 1734 |
+
"execution_count": 21,
|
| 1735 |
+
"id": "2f56b5fd",
|
| 1736 |
+
"metadata": {},
|
| 1737 |
+
"outputs": [],
|
| 1738 |
+
"source": [
|
| 1739 |
+
"results_our = pd.DataFrame({\n",
|
| 1740 |
+
" \"text\": X_test_our,\n",
|
| 1741 |
+
" \"full\": test_full,\n",
|
| 1742 |
+
" \"gold_label\": y_test_our,\n",
|
| 1743 |
+
" \"predicted_label\": y_pred_our\n",
|
| 1744 |
+
"})\n",
|
| 1745 |
+
"# df.to_csv(\"predictions.csv\", index=False, encoding='utf-8-sig')\n",
|
| 1746 |
+
"\n",
|
| 1747 |
+
"# print(\"Đã lưu file predictions.csv\")\n"
|
| 1748 |
+
]
|
| 1749 |
+
},
|
| 1750 |
+
{
|
| 1751 |
+
"cell_type": "code",
|
| 1752 |
+
"execution_count": 22,
|
| 1753 |
+
"id": "79f9a8e6",
|
| 1754 |
+
"metadata": {},
|
| 1755 |
+
"outputs": [
|
| 1756 |
+
{
|
| 1757 |
+
"data": {
|
| 1758 |
+
"text/html": [
|
| 1759 |
+
"<div>\n",
|
| 1760 |
+
"<style scoped>\n",
|
| 1761 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 1762 |
+
" vertical-align: middle;\n",
|
| 1763 |
+
" }\n",
|
| 1764 |
+
"\n",
|
| 1765 |
+
" .dataframe tbody tr th {\n",
|
| 1766 |
+
" vertical-align: top;\n",
|
| 1767 |
+
" }\n",
|
| 1768 |
+
"\n",
|
| 1769 |
+
" .dataframe thead th {\n",
|
| 1770 |
+
" text-align: right;\n",
|
| 1771 |
+
" }\n",
|
| 1772 |
+
"</style>\n",
|
| 1773 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 1774 |
+
" <thead>\n",
|
| 1775 |
+
" <tr style=\"text-align: right;\">\n",
|
| 1776 |
+
" <th></th>\n",
|
| 1777 |
+
" <th>text</th>\n",
|
| 1778 |
+
" <th>full</th>\n",
|
| 1779 |
+
" <th>gold_label</th>\n",
|
| 1780 |
+
" <th>predicted_label</th>\n",
|
| 1781 |
+
" </tr>\n",
|
| 1782 |
+
" </thead>\n",
|
| 1783 |
+
" <tbody>\n",
|
| 1784 |
+
" <tr>\n",
|
| 1785 |
+
" <th>0</th>\n",
|
| 1786 |
+
" <td>i had an extreme hate towards myself sabotagin...</td>\n",
|
| 1787 |
+
" <td>from lebanon it has been a long period that i’...</td>\n",
|
| 1788 |
+
" <td>Mental filter</td>\n",
|
| 1789 |
+
" <td>Overgeneralization</td>\n",
|
| 1790 |
+
" </tr>\n",
|
| 1791 |
+
" <tr>\n",
|
| 1792 |
+
" <th>1</th>\n",
|
| 1793 |
+
" <td>my husband was acting like he was having an af...</td>\n",
|
| 1794 |
+
" <td>last year my husband said he knew this girl wh...</td>\n",
|
| 1795 |
+
" <td>Emotional Reasoning</td>\n",
|
| 1796 |
+
" <td>Labeling</td>\n",
|
| 1797 |
+
" </tr>\n",
|
| 1798 |
+
" <tr>\n",
|
| 1799 |
+
" <th>2</th>\n",
|
| 1800 |
+
" <td>i feel as if moving on to higher education wil...</td>\n",
|
| 1801 |
+
" <td>i find myself increasingly disillusioned with ...</td>\n",
|
| 1802 |
+
" <td>Fortune-telling</td>\n",
|
| 1803 |
+
" <td>Fortune-telling</td>\n",
|
| 1804 |
+
" </tr>\n",
|
| 1805 |
+
" <tr>\n",
|
| 1806 |
+
" <th>3</th>\n",
|
| 1807 |
+
" <td>i’m really struggling with understanding how i...</td>\n",
|
| 1808 |
+
" <td>my husband left almost 3 years ago and lives w...</td>\n",
|
| 1809 |
+
" <td>Mind Reading</td>\n",
|
| 1810 |
+
" <td>Mind Reading</td>\n",
|
| 1811 |
+
" </tr>\n",
|
| 1812 |
+
" <tr>\n",
|
| 1813 |
+
" <th>4</th>\n",
|
| 1814 |
+
" <td>i’m 17 now and should be off to university nex...</td>\n",
|
| 1815 |
+
" <td>i’m 17 now and should be off to university nex...</td>\n",
|
| 1816 |
+
" <td>Should statements</td>\n",
|
| 1817 |
+
" <td>Magnification</td>\n",
|
| 1818 |
+
" </tr>\n",
|
| 1819 |
+
" <tr>\n",
|
| 1820 |
+
" <th>...</th>\n",
|
| 1821 |
+
" <td>...</td>\n",
|
| 1822 |
+
" <td>...</td>\n",
|
| 1823 |
+
" <td>...</td>\n",
|
| 1824 |
+
" <td>...</td>\n",
|
| 1825 |
+
" </tr>\n",
|
| 1826 |
+
" <tr>\n",
|
| 1827 |
+
" <th>315</th>\n",
|
| 1828 |
+
" <td>another thing is that my mother loves lecturin...</td>\n",
|
| 1829 |
+
" <td>my mother and father treat me quite differentl...</td>\n",
|
| 1830 |
+
" <td>Mind Reading</td>\n",
|
| 1831 |
+
" <td>Mind Reading</td>\n",
|
| 1832 |
+
" </tr>\n",
|
| 1833 |
+
" <tr>\n",
|
| 1834 |
+
" <th>316</th>\n",
|
| 1835 |
+
" <td>part of me thinks this is a routine and just d...</td>\n",
|
| 1836 |
+
" <td>my boyfriend of 2 years is a wonderful person ...</td>\n",
|
| 1837 |
+
" <td>Personalization</td>\n",
|
| 1838 |
+
" <td>Mind Reading</td>\n",
|
| 1839 |
+
" </tr>\n",
|
| 1840 |
+
" <tr>\n",
|
| 1841 |
+
" <th>317</th>\n",
|
| 1842 |
+
" <td>all my life i’ve tried to be different people ...</td>\n",
|
| 1843 |
+
" <td>from a 14 year old girl in the us all my life ...</td>\n",
|
| 1844 |
+
" <td>Personalization</td>\n",
|
| 1845 |
+
" <td>Overgeneralization</td>\n",
|
| 1846 |
+
" </tr>\n",
|
| 1847 |
+
" <tr>\n",
|
| 1848 |
+
" <th>318</th>\n",
|
| 1849 |
+
" <td>she knows she has memory problems and is not i...</td>\n",
|
| 1850 |
+
" <td>my wife has been seeing the same psychiatrist ...</td>\n",
|
| 1851 |
+
" <td>Mind Reading</td>\n",
|
| 1852 |
+
" <td>Mind Reading</td>\n",
|
| 1853 |
+
" </tr>\n",
|
| 1854 |
+
" <tr>\n",
|
| 1855 |
+
" <th>319</th>\n",
|
| 1856 |
+
" <td>i just feel like i’ve never been happy</td>\n",
|
| 1857 |
+
" <td>is lifetime depression a thing is there some o...</td>\n",
|
| 1858 |
+
" <td>Overgeneralization</td>\n",
|
| 1859 |
+
" <td>Emotional Reasoning</td>\n",
|
| 1860 |
+
" </tr>\n",
|
| 1861 |
+
" </tbody>\n",
|
| 1862 |
+
"</table>\n",
|
| 1863 |
+
"<p>320 rows × 4 columns</p>\n",
|
| 1864 |
+
"</div>"
|
| 1865 |
+
],
|
| 1866 |
+
"text/plain": [
|
| 1867 |
+
" text \\\n",
|
| 1868 |
+
"0 i had an extreme hate towards myself sabotagin... \n",
|
| 1869 |
+
"1 my husband was acting like he was having an af... \n",
|
| 1870 |
+
"2 i feel as if moving on to higher education wil... \n",
|
| 1871 |
+
"3 i’m really struggling with understanding how i... \n",
|
| 1872 |
+
"4 i’m 17 now and should be off to university nex... \n",
|
| 1873 |
+
".. ... \n",
|
| 1874 |
+
"315 another thing is that my mother loves lecturin... \n",
|
| 1875 |
+
"316 part of me thinks this is a routine and just d... \n",
|
| 1876 |
+
"317 all my life i’ve tried to be different people ... \n",
|
| 1877 |
+
"318 she knows she has memory problems and is not i... \n",
|
| 1878 |
+
"319 i just feel like i’ve never been happy \n",
|
| 1879 |
+
"\n",
|
| 1880 |
+
" full gold_label \\\n",
|
| 1881 |
+
"0 from lebanon it has been a long period that i’... Mental filter \n",
|
| 1882 |
+
"1 last year my husband said he knew this girl wh... Emotional Reasoning \n",
|
| 1883 |
+
"2 i find myself increasingly disillusioned with ... Fortune-telling \n",
|
| 1884 |
+
"3 my husband left almost 3 years ago and lives w... Mind Reading \n",
|
| 1885 |
+
"4 i’m 17 now and should be off to university nex... Should statements \n",
|
| 1886 |
+
".. ... ... \n",
|
| 1887 |
+
"315 my mother and father treat me quite differentl... Mind Reading \n",
|
| 1888 |
+
"316 my boyfriend of 2 years is a wonderful person ... Personalization \n",
|
| 1889 |
+
"317 from a 14 year old girl in the us all my life ... Personalization \n",
|
| 1890 |
+
"318 my wife has been seeing the same psychiatrist ... Mind Reading \n",
|
| 1891 |
+
"319 is lifetime depression a thing is there some o... Overgeneralization \n",
|
| 1892 |
+
"\n",
|
| 1893 |
+
" predicted_label \n",
|
| 1894 |
+
"0 Overgeneralization \n",
|
| 1895 |
+
"1 Labeling \n",
|
| 1896 |
+
"2 Fortune-telling \n",
|
| 1897 |
+
"3 Mind Reading \n",
|
| 1898 |
+
"4 Magnification \n",
|
| 1899 |
+
".. ... \n",
|
| 1900 |
+
"315 Mind Reading \n",
|
| 1901 |
+
"316 Mind Reading \n",
|
| 1902 |
+
"317 Overgeneralization \n",
|
| 1903 |
+
"318 Mind Reading \n",
|
| 1904 |
+
"319 Emotional Reasoning \n",
|
| 1905 |
+
"\n",
|
| 1906 |
+
"[320 rows x 4 columns]"
|
| 1907 |
+
]
|
| 1908 |
+
},
|
| 1909 |
+
"execution_count": 22,
|
| 1910 |
+
"metadata": {},
|
| 1911 |
+
"output_type": "execute_result"
|
| 1912 |
+
}
|
| 1913 |
+
],
|
| 1914 |
+
"source": [
|
| 1915 |
+
"results_our"
|
| 1916 |
+
]
|
| 1917 |
+
},
|
| 1918 |
+
{
|
| 1919 |
+
"cell_type": "code",
|
| 1920 |
+
"execution_count": 23,
|
| 1921 |
+
"id": "666e3ea7",
|
| 1922 |
+
"metadata": {},
|
| 1923 |
+
"outputs": [],
|
| 1924 |
+
"source": [
|
| 1925 |
+
"results = pd.DataFrame({\n",
|
| 1926 |
+
" \"text\": X_test,\n",
|
| 1927 |
+
" \"gold_label\": y_test,\n",
|
| 1928 |
+
" \"predicted_label\": y_pred\n",
|
| 1929 |
+
"})"
|
| 1930 |
+
]
|
| 1931 |
+
},
|
| 1932 |
+
{
|
| 1933 |
+
"cell_type": "code",
|
| 1934 |
+
"execution_count": 24,
|
| 1935 |
+
"id": "70529b00",
|
| 1936 |
+
"metadata": {},
|
| 1937 |
+
"outputs": [
|
| 1938 |
+
{
|
| 1939 |
+
"data": {
|
| 1940 |
+
"text/html": [
|
| 1941 |
+
"<div>\n",
|
| 1942 |
+
"<style scoped>\n",
|
| 1943 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 1944 |
+
" vertical-align: middle;\n",
|
| 1945 |
+
" }\n",
|
| 1946 |
+
"\n",
|
| 1947 |
+
" .dataframe tbody tr th {\n",
|
| 1948 |
+
" vertical-align: top;\n",
|
| 1949 |
+
" }\n",
|
| 1950 |
+
"\n",
|
| 1951 |
+
" .dataframe thead th {\n",
|
| 1952 |
+
" text-align: right;\n",
|
| 1953 |
+
" }\n",
|
| 1954 |
+
"</style>\n",
|
| 1955 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 1956 |
+
" <thead>\n",
|
| 1957 |
+
" <tr style=\"text-align: right;\">\n",
|
| 1958 |
+
" <th></th>\n",
|
| 1959 |
+
" <th>text</th>\n",
|
| 1960 |
+
" <th>gold_label</th>\n",
|
| 1961 |
+
" <th>predicted_label</th>\n",
|
| 1962 |
+
" </tr>\n",
|
| 1963 |
+
" </thead>\n",
|
| 1964 |
+
" <tbody>\n",
|
| 1965 |
+
" <tr>\n",
|
| 1966 |
+
" <th>0</th>\n",
|
| 1967 |
+
" <td>from lebanon it has been a long period that i’...</td>\n",
|
| 1968 |
+
" <td>Mental filter</td>\n",
|
| 1969 |
+
" <td>Overgeneralization</td>\n",
|
| 1970 |
+
" </tr>\n",
|
| 1971 |
+
" <tr>\n",
|
| 1972 |
+
" <th>1</th>\n",
|
| 1973 |
+
" <td>last year my husband said he knew this girl wh...</td>\n",
|
| 1974 |
+
" <td>Emotional Reasoning</td>\n",
|
| 1975 |
+
" <td>Overgeneralization</td>\n",
|
| 1976 |
+
" </tr>\n",
|
| 1977 |
+
" <tr>\n",
|
| 1978 |
+
" <th>2</th>\n",
|
| 1979 |
+
" <td>i find myself increasingly disillusioned with ...</td>\n",
|
| 1980 |
+
" <td>Fortune-telling</td>\n",
|
| 1981 |
+
" <td>Fortune-telling</td>\n",
|
| 1982 |
+
" </tr>\n",
|
| 1983 |
+
" <tr>\n",
|
| 1984 |
+
" <th>3</th>\n",
|
| 1985 |
+
" <td>my husband left almost 3 years ago and lives w...</td>\n",
|
| 1986 |
+
" <td>Mind Reading</td>\n",
|
| 1987 |
+
" <td>Mind Reading</td>\n",
|
| 1988 |
+
" </tr>\n",
|
| 1989 |
+
" <tr>\n",
|
| 1990 |
+
" <th>4</th>\n",
|
| 1991 |
+
" <td>i’m 17 now and should be off to university nex...</td>\n",
|
| 1992 |
+
" <td>Should statements</td>\n",
|
| 1993 |
+
" <td>Mental filter</td>\n",
|
| 1994 |
+
" </tr>\n",
|
| 1995 |
+
" <tr>\n",
|
| 1996 |
+
" <th>...</th>\n",
|
| 1997 |
+
" <td>...</td>\n",
|
| 1998 |
+
" <td>...</td>\n",
|
| 1999 |
+
" <td>...</td>\n",
|
| 2000 |
+
" </tr>\n",
|
| 2001 |
+
" <tr>\n",
|
| 2002 |
+
" <th>315</th>\n",
|
| 2003 |
+
" <td>my mother and father treat me quite differentl...</td>\n",
|
| 2004 |
+
" <td>Mind Reading</td>\n",
|
| 2005 |
+
" <td>Mind Reading</td>\n",
|
| 2006 |
+
" </tr>\n",
|
| 2007 |
+
" <tr>\n",
|
| 2008 |
+
" <th>316</th>\n",
|
| 2009 |
+
" <td>my boyfriend of 2 years is a wonderful person ...</td>\n",
|
| 2010 |
+
" <td>Personalization</td>\n",
|
| 2011 |
+
" <td>Mind Reading</td>\n",
|
| 2012 |
+
" </tr>\n",
|
| 2013 |
+
" <tr>\n",
|
| 2014 |
+
" <th>317</th>\n",
|
| 2015 |
+
" <td>from a 14 year old girl in the us all my life ...</td>\n",
|
| 2016 |
+
" <td>Personalization</td>\n",
|
| 2017 |
+
" <td>Magnification</td>\n",
|
| 2018 |
+
" </tr>\n",
|
| 2019 |
+
" <tr>\n",
|
| 2020 |
+
" <th>318</th>\n",
|
| 2021 |
+
" <td>my wife has been seeing the same psychiatrist ...</td>\n",
|
| 2022 |
+
" <td>Mind Reading</td>\n",
|
| 2023 |
+
" <td>Mind Reading</td>\n",
|
| 2024 |
+
" </tr>\n",
|
| 2025 |
+
" <tr>\n",
|
| 2026 |
+
" <th>319</th>\n",
|
| 2027 |
+
" <td>is lifetime depression a thing is there some o...</td>\n",
|
| 2028 |
+
" <td>Overgeneralization</td>\n",
|
| 2029 |
+
" <td>Should statements</td>\n",
|
| 2030 |
+
" </tr>\n",
|
| 2031 |
+
" </tbody>\n",
|
| 2032 |
+
"</table>\n",
|
| 2033 |
+
"<p>320 rows × 3 columns</p>\n",
|
| 2034 |
+
"</div>"
|
| 2035 |
+
],
|
| 2036 |
+
"text/plain": [
|
| 2037 |
+
" text gold_label \\\n",
|
| 2038 |
+
"0 from lebanon it has been a long period that i’... Mental filter \n",
|
| 2039 |
+
"1 last year my husband said he knew this girl wh... Emotional Reasoning \n",
|
| 2040 |
+
"2 i find myself increasingly disillusioned with ... Fortune-telling \n",
|
| 2041 |
+
"3 my husband left almost 3 years ago and lives w... Mind Reading \n",
|
| 2042 |
+
"4 i’m 17 now and should be off to university nex... Should statements \n",
|
| 2043 |
+
".. ... ... \n",
|
| 2044 |
+
"315 my mother and father treat me quite differentl... Mind Reading \n",
|
| 2045 |
+
"316 my boyfriend of 2 years is a wonderful person ... Personalization \n",
|
| 2046 |
+
"317 from a 14 year old girl in the us all my life ... Personalization \n",
|
| 2047 |
+
"318 my wife has been seeing the same psychiatrist ... Mind Reading \n",
|
| 2048 |
+
"319 is lifetime depression a thing is there some o... Overgeneralization \n",
|
| 2049 |
+
"\n",
|
| 2050 |
+
" predicted_label \n",
|
| 2051 |
+
"0 Overgeneralization \n",
|
| 2052 |
+
"1 Overgeneralization \n",
|
| 2053 |
+
"2 Fortune-telling \n",
|
| 2054 |
+
"3 Mind Reading \n",
|
| 2055 |
+
"4 Mental filter \n",
|
| 2056 |
+
".. ... \n",
|
| 2057 |
+
"315 Mind Reading \n",
|
| 2058 |
+
"316 Mind Reading \n",
|
| 2059 |
+
"317 Magnification \n",
|
| 2060 |
+
"318 Mind Reading \n",
|
| 2061 |
+
"319 Should statements \n",
|
| 2062 |
+
"\n",
|
| 2063 |
+
"[320 rows x 3 columns]"
|
| 2064 |
+
]
|
| 2065 |
+
},
|
| 2066 |
+
"execution_count": 24,
|
| 2067 |
+
"metadata": {},
|
| 2068 |
+
"output_type": "execute_result"
|
| 2069 |
+
}
|
| 2070 |
+
],
|
| 2071 |
+
"source": [
|
| 2072 |
+
"results"
|
| 2073 |
+
]
|
| 2074 |
+
},
|
| 2075 |
+
{
|
| 2076 |
+
"cell_type": "code",
|
| 2077 |
+
"execution_count": 25,
|
| 2078 |
+
"id": "ce61b9cd",
|
| 2079 |
+
"metadata": {},
|
| 2080 |
+
"outputs": [],
|
| 2081 |
+
"source": [
|
| 2082 |
+
"common_texts_df1 = results[results['text'].isin(results_our['full'])]\n",
|
| 2083 |
+
"\n",
|
| 2084 |
+
"common_texts_df2 = results_our[results_our['full'].isin(results['text'])]\n"
|
| 2085 |
+
]
|
| 2086 |
+
},
|
| 2087 |
+
{
|
| 2088 |
+
"cell_type": "code",
|
| 2089 |
+
"execution_count": 30,
|
| 2090 |
+
"id": "2e2fbb23",
|
| 2091 |
+
"metadata": {},
|
| 2092 |
+
"outputs": [
|
| 2093 |
+
{
|
| 2094 |
+
"name": "stdout",
|
| 2095 |
+
"output_type": "stream",
|
| 2096 |
+
"text": [
|
| 2097 |
+
"since may i haven’t been sleeping great i had a roommate before i came home and as soon as i slept in my own room i’ve been freaking out at night i see the light flickering by my window someone’s there i hear something under my desk someone’s there every little thing is making me terrified and unless i take benedryl i physically can’t sleep because i’m so afraid since i haven’t been sleeping great i’ve also started having minor hallucinations occasionally mostly auditory the microwave running and dishes breaking but i keep feeling like there’s bugs on me whenever i’m really paranoid how do i cope with thus fear\n",
|
| 2098 |
+
"Magnification\n",
|
| 2099 |
+
"Overgeneralization\n"
|
| 2100 |
+
]
|
| 2101 |
+
}
|
| 2102 |
+
],
|
| 2103 |
+
"source": [
|
| 2104 |
+
"i=14\n",
|
| 2105 |
+
"print(common_texts_df1['text'][i])\n",
|
| 2106 |
+
"print(common_texts_df1['gold_label'][i])\n",
|
| 2107 |
+
"print(common_texts_df1['predicted_label'][i])"
|
| 2108 |
+
]
|
| 2109 |
+
},
|
| 2110 |
+
{
|
| 2111 |
+
"cell_type": "code",
|
| 2112 |
+
"execution_count": 31,
|
| 2113 |
+
"id": "0dded9a0",
|
| 2114 |
+
"metadata": {},
|
| 2115 |
+
"outputs": [
|
| 2116 |
+
{
|
| 2117 |
+
"name": "stdout",
|
| 2118 |
+
"output_type": "stream",
|
| 2119 |
+
"text": [
|
| 2120 |
+
"since may i haven’t been sleeping great i had a roommate before i came home and as soon as i slept in my own room i’ve been freaking out at night i see the light flickering by my window someone’s there i hear something under my desk someone’s there every little thing is making me terrified and unless i take benedryl i physically can’t sleep because i’m so afraid since i haven’t been sleeping great i’ve also started having minor hallucinations occasionally mostly auditory the microwave running and dishes breaking but i keep feeling like there’s bugs on me whenever i’m really paranoid how do i cope with thus fear\n",
|
| 2121 |
+
"i see the light flickering by my window someone’s there i hear something under my desk someone’s there every little thing is making me terrified and unless i take benedryl i physically can’t sleep because i’m so afraid\n",
|
| 2122 |
+
"Magnification\n",
|
| 2123 |
+
"Personalization\n"
|
| 2124 |
+
]
|
| 2125 |
+
}
|
| 2126 |
+
],
|
| 2127 |
+
"source": [
|
| 2128 |
+
"print(common_texts_df2['full'][i])\n",
|
| 2129 |
+
"print(common_texts_df2['text'][i])\n",
|
| 2130 |
+
"print(common_texts_df2['gold_label'][i])\n",
|
| 2131 |
+
"print(common_texts_df2['predicted_label'][i])"
|
| 2132 |
+
]
|
| 2133 |
+
},
|
| 2134 |
+
{
|
| 2135 |
+
"cell_type": "code",
|
| 2136 |
+
"execution_count": 28,
|
| 2137 |
+
"id": "453506b2",
|
| 2138 |
+
"metadata": {},
|
| 2139 |
+
"outputs": [
|
| 2140 |
+
{
|
| 2141 |
+
"data": {
|
| 2142 |
+
"text/html": [
|
| 2143 |
+
"<div>\n",
|
| 2144 |
+
"<style scoped>\n",
|
| 2145 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 2146 |
+
" vertical-align: middle;\n",
|
| 2147 |
+
" }\n",
|
| 2148 |
+
"\n",
|
| 2149 |
+
" .dataframe tbody tr th {\n",
|
| 2150 |
+
" vertical-align: top;\n",
|
| 2151 |
+
" }\n",
|
| 2152 |
+
"\n",
|
| 2153 |
+
" .dataframe thead th {\n",
|
| 2154 |
+
" text-align: right;\n",
|
| 2155 |
+
" }\n",
|
| 2156 |
+
"</style>\n",
|
| 2157 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 2158 |
+
" <thead>\n",
|
| 2159 |
+
" <tr style=\"text-align: right;\">\n",
|
| 2160 |
+
" <th></th>\n",
|
| 2161 |
+
" <th>Id_Number</th>\n",
|
| 2162 |
+
" <th>Patient Question</th>\n",
|
| 2163 |
+
" <th>Distorted part</th>\n",
|
| 2164 |
+
" <th>Dominant Distortion</th>\n",
|
| 2165 |
+
" <th>Secondary Distortion (Optional)</th>\n",
|
| 2166 |
+
" <th>cleaned</th>\n",
|
| 2167 |
+
" <th>cleaned_full</th>\n",
|
| 2168 |
+
" </tr>\n",
|
| 2169 |
+
" </thead>\n",
|
| 2170 |
+
" <tbody>\n",
|
| 2171 |
+
" <tr>\n",
|
| 2172 |
+
" <th>2468</th>\n",
|
| 2173 |
+
" <td>2500</td>\n",
|
| 2174 |
+
" <td>I can’t get close to anyone, I can’t feel, I c...</td>\n",
|
| 2175 |
+
" <td>I’m not shy at all, I’m a very confident perso...</td>\n",
|
| 2176 |
+
" <td>Labeling</td>\n",
|
| 2177 |
+
" <td>NaN</td>\n",
|
| 2178 |
+
" <td>i’m not shy at all i’m a very confident person...</td>\n",
|
| 2179 |
+
" <td>i can’t get close to anyone i can’t feel i can...</td>\n",
|
| 2180 |
+
" </tr>\n",
|
| 2181 |
+
" </tbody>\n",
|
| 2182 |
+
"</table>\n",
|
| 2183 |
+
"</div>"
|
| 2184 |
+
],
|
| 2185 |
+
"text/plain": [
|
| 2186 |
+
" Id_Number Patient Question \\\n",
|
| 2187 |
+
"2468 2500 I can’t get close to anyone, I can’t feel, I c... \n",
|
| 2188 |
+
"\n",
|
| 2189 |
+
" Distorted part Dominant Distortion \\\n",
|
| 2190 |
+
"2468 I’m not shy at all, I’m a very confident perso... Labeling \n",
|
| 2191 |
+
"\n",
|
| 2192 |
+
" Secondary Distortion (Optional) \\\n",
|
| 2193 |
+
"2468 NaN \n",
|
| 2194 |
+
"\n",
|
| 2195 |
+
" cleaned \\\n",
|
| 2196 |
+
"2468 i’m not shy at all i’m a very confident person... \n",
|
| 2197 |
+
"\n",
|
| 2198 |
+
" cleaned_full \n",
|
| 2199 |
+
"2468 i can’t get close to anyone i can’t feel i can... "
|
| 2200 |
+
]
|
| 2201 |
+
},
|
| 2202 |
+
"execution_count": 28,
|
| 2203 |
+
"metadata": {},
|
| 2204 |
+
"output_type": "execute_result"
|
| 2205 |
+
}
|
| 2206 |
+
],
|
| 2207 |
+
"source": [
|
| 2208 |
+
"example = df_our[df_our['Id_Number'] == 2500]\n",
|
| 2209 |
+
"example"
|
| 2210 |
+
]
|
| 2211 |
+
},
|
| 2212 |
+
{
|
| 2213 |
+
"cell_type": "code",
|
| 2214 |
+
"execution_count": 29,
|
| 2215 |
+
"id": "3cb9c242",
|
| 2216 |
+
"metadata": {},
|
| 2217 |
+
"outputs": [
|
| 2218 |
+
{
|
| 2219 |
+
"name": "stdout",
|
| 2220 |
+
"output_type": "stream",
|
| 2221 |
+
"text": [
|
| 2222 |
+
"I can’t get close to anyone, I can’t feel, I can’t make friends or i just don’t want to, i feel the need to be alone. I’m not shy at all, I’m a very confident person I can talk to anyone in fact I don’t even hesitate to talk with strangers at all. and yes I’m a good person at heart i’m not selfish yet I can’t get close to anyone sometimes I feel like there’s an invisible wall around me that I can’t let anyone close. mostly people like me they are inspired by me they want to get close but each time I just push them away even sometimes when I really like them, but I don’t feel. What’s wrong with me?\n"
|
| 2223 |
+
]
|
| 2224 |
+
}
|
| 2225 |
+
],
|
| 2226 |
+
"source": [
|
| 2227 |
+
"print(example['Patient Question'][2468])"
|
| 2228 |
+
]
|
| 2229 |
+
},
|
| 2230 |
+
{
|
| 2231 |
+
"cell_type": "code",
|
| 2232 |
+
"execution_count": 50,
|
| 2233 |
+
"id": "879feb79",
|
| 2234 |
+
"metadata": {},
|
| 2235 |
+
"outputs": [
|
| 2236 |
+
{
|
| 2237 |
+
"name": "stdout",
|
| 2238 |
+
"output_type": "stream",
|
| 2239 |
+
"text": [
|
| 2240 |
+
"I’m not shy at all, I’m a very confident person I can talk to anyone in fact I don’t even hesitate to talk with strangers at all.\n"
|
| 2241 |
+
]
|
| 2242 |
+
}
|
| 2243 |
+
],
|
| 2244 |
+
"source": [
|
| 2245 |
+
"print(example['Distorted part'][2468])"
|
| 2246 |
+
]
|
| 2247 |
+
},
|
| 2248 |
+
{
|
| 2249 |
+
"cell_type": "code",
|
| 2250 |
+
"execution_count": null,
|
| 2251 |
+
"id": "962aaac3",
|
| 2252 |
+
"metadata": {},
|
| 2253 |
+
"outputs": [],
|
| 2254 |
+
"source": []
|
| 2255 |
+
}
|
| 2256 |
+
],
|
| 2257 |
+
"metadata": {
|
| 2258 |
+
"kernelspec": {
|
| 2259 |
+
"display_name": "base",
|
| 2260 |
+
"language": "python",
|
| 2261 |
+
"name": "python3"
|
| 2262 |
+
},
|
| 2263 |
+
"language_info": {
|
| 2264 |
+
"codemirror_mode": {
|
| 2265 |
+
"name": "ipython",
|
| 2266 |
+
"version": 3
|
| 2267 |
+
},
|
| 2268 |
+
"file_extension": ".py",
|
| 2269 |
+
"mimetype": "text/x-python",
|
| 2270 |
+
"name": "python",
|
| 2271 |
+
"nbconvert_exporter": "python",
|
| 2272 |
+
"pygments_lexer": "ipython3",
|
| 2273 |
+
"version": "3.12.9"
|
| 2274 |
+
}
|
| 2275 |
+
},
|
| 2276 |
+
"nbformat": 4,
|
| 2277 |
+
"nbformat_minor": 5
|
| 2278 |
+
}
|