jstAnotherCapi commited on
Commit
2ca5a84
·
verified ·
1 Parent(s): ba3ecf1

Upload folder using huggingface_hub

Browse files
cleaning_data_semantic_model/.ipynb_checkpoints/data_cleaning-checkpoint.ipynb ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "id": "059fcee7-dbf9-46d9-a501-d744e48b5a9c",
7
+ "metadata": {},
8
+ "outputs": [],
9
+ "source": []
10
+ }
11
+ ],
12
+ "metadata": {
13
+ "kernelspec": {
14
+ "display_name": "Python 3 (ipykernel)",
15
+ "language": "python",
16
+ "name": "python3"
17
+ },
18
+ "language_info": {
19
+ "codemirror_mode": {
20
+ "name": "ipython",
21
+ "version": 3
22
+ },
23
+ "file_extension": ".py",
24
+ "mimetype": "text/x-python",
25
+ "name": "python",
26
+ "nbconvert_exporter": "python",
27
+ "pygments_lexer": "ipython3",
28
+ "version": "3.11.14"
29
+ }
30
+ },
31
+ "nbformat": 4,
32
+ "nbformat_minor": 5
33
+ }
cleaning_data_semantic_model/data_cleaning.ipynb ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 5,
6
+ "id": "34acba0a-8aab-46e7-a36a-12aff60da3d1",
7
+ "metadata": {},
8
+ "outputs": [
9
+ {
10
+ "name": "stdout",
11
+ "output_type": "stream",
12
+ "text": [
13
+ "/home/skiredj.abderrahman/khalil/cleaning_data_semantic_model\n"
14
+ ]
15
+ }
16
+ ],
17
+ "source": [
18
+ "!pwd"
19
+ ]
20
+ },
21
+ {
22
+ "cell_type": "code",
23
+ "execution_count": 9,
24
+ "id": "059fcee7-dbf9-46d9-a501-d744e48b5a9c",
25
+ "metadata": {},
26
+ "outputs": [
27
+ {
28
+ "ename": "UnicodeDecodeError",
29
+ "evalue": "'utf-8' codec can't decode byte 0xd9 in position 56: unexpected end of data",
30
+ "output_type": "error",
31
+ "traceback": [
32
+ "\u001b[31m---------------------------------------------------------------------------\u001b[39m",
33
+ "\u001b[31mUnicodeDecodeError\u001b[39m Traceback (most recent call last)",
34
+ "\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/parsers.pyx:1067\u001b[39m, in \u001b[36mpandas._libs.parsers.TextReader._convert_tokens\u001b[39m\u001b[34m()\u001b[39m\n",
35
+ "\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/parsers.pyx:1227\u001b[39m, in \u001b[36mpandas._libs.parsers.TextReader._convert_with_dtype\u001b[39m\u001b[34m()\u001b[39m\n",
36
+ "\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/parsers.pyx:1240\u001b[39m, in \u001b[36mpandas._libs.parsers.TextReader._string_convert\u001b[39m\u001b[34m()\u001b[39m\n",
37
+ "\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/parsers.pyx:1527\u001b[39m, in \u001b[36mpandas._libs.parsers._string_box_utf8\u001b[39m\u001b[34m()\u001b[39m\n",
38
+ "\u001b[31mUnicodeDecodeError\u001b[39m: 'utf-8' codec can't decode byte 0xd9 in position 56: unexpected end of data",
39
+ "\nDuring handling of the above exception, another exception occurred:\n",
40
+ "\u001b[31mUnicodeDecodeError\u001b[39m Traceback (most recent call last)",
41
+ "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[9]\u001b[39m\u001b[32m, line 3\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mpandas\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mas\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mpd\u001b[39;00m\n\u001b[32m 2\u001b[39m dataset28_train = \u001b[33m'\u001b[39m\u001b[33m/home/skiredj.abderrahman/khalil/cleaning_data_semantic_model/train.csv\u001b[39m\u001b[33m'\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m3\u001b[39m ds28_train = \u001b[43mpd\u001b[49m\u001b[43m.\u001b[49m\u001b[43mread_csv\u001b[49m\u001b[43m(\u001b[49m\u001b[43mdataset28_train\u001b[49m\u001b[43m,\u001b[49m\u001b[43mencoding\u001b[49m\u001b[43m=\u001b[49m\u001b[33;43m\"\u001b[39;49m\u001b[33;43mutf-8\u001b[39;49m\u001b[33;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[32m 4\u001b[39m ds28_train\n",
42
+ "\u001b[36mFile \u001b[39m\u001b[32m~/.conda/envs/fatnaoui_jupyter/lib/python3.11/site-packages/pandas/io/parsers/readers.py:873\u001b[39m, in \u001b[36mread_csv\u001b[39m\u001b[34m(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, skip_blank_lines, parse_dates, date_format, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, on_bad_lines, low_memory, memory_map, float_precision, storage_options, dtype_backend)\u001b[39m\n\u001b[32m 861\u001b[39m kwds_defaults = _refine_defaults_read(\n\u001b[32m 862\u001b[39m dialect,\n\u001b[32m 863\u001b[39m delimiter,\n\u001b[32m (...)\u001b[39m\u001b[32m 869\u001b[39m dtype_backend=dtype_backend,\n\u001b[32m 870\u001b[39m )\n\u001b[32m 871\u001b[39m kwds.update(kwds_defaults)\n\u001b[32m--> \u001b[39m\u001b[32m873\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43m_read\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfilepath_or_buffer\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkwds\u001b[49m\u001b[43m)\u001b[49m\n",
43
+ "\u001b[36mFile \u001b[39m\u001b[32m~/.conda/envs/fatnaoui_jupyter/lib/python3.11/site-packages/pandas/io/parsers/readers.py:306\u001b[39m, in \u001b[36m_read\u001b[39m\u001b[34m(filepath_or_buffer, kwds)\u001b[39m\n\u001b[32m 303\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m parser\n\u001b[32m 305\u001b[39m \u001b[38;5;28;01mwith\u001b[39;00m parser:\n\u001b[32m--> \u001b[39m\u001b[32m306\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mparser\u001b[49m\u001b[43m.\u001b[49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\u001b[43mnrows\u001b[49m\u001b[43m)\u001b[49m\n",
44
+ "\u001b[36mFile \u001b[39m\u001b[32m~/.conda/envs/fatnaoui_jupyter/lib/python3.11/site-packages/pandas/io/parsers/readers.py:1947\u001b[39m, in \u001b[36mTextFileReader.read\u001b[39m\u001b[34m(self, nrows)\u001b[39m\n\u001b[32m 1940\u001b[39m nrows = validate_integer(\u001b[33m\"\u001b[39m\u001b[33mnrows\u001b[39m\u001b[33m\"\u001b[39m, nrows)\n\u001b[32m 1941\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m 1942\u001b[39m \u001b[38;5;66;03m# error: \"ParserBase\" has no attribute \"read\"\u001b[39;00m\n\u001b[32m 1943\u001b[39m (\n\u001b[32m 1944\u001b[39m index,\n\u001b[32m 1945\u001b[39m columns,\n\u001b[32m 1946\u001b[39m col_dict,\n\u001b[32m-> \u001b[39m\u001b[32m1947\u001b[39m ) = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_engine\u001b[49m\u001b[43m.\u001b[49m\u001b[43mread\u001b[49m\u001b[43m(\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m# type: ignore[attr-defined]\u001b[39;49;00m\n\u001b[32m 1948\u001b[39m \u001b[43m \u001b[49m\u001b[43mnrows\u001b[49m\n\u001b[32m 1949\u001b[39m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 1950\u001b[39m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m:\n\u001b[32m 1951\u001b[39m \u001b[38;5;28mself\u001b[39m.close()\n",
45
+ "\u001b[36mFile \u001b[39m\u001b[32m~/.conda/envs/fatnaoui_jupyter/lib/python3.11/site-packages/pandas/io/parsers/c_parser_wrapper.py:215\u001b[39m, in \u001b[36mCParserWrapper.read\u001b[39m\u001b[34m(self, nrows)\u001b[39m\n\u001b[32m 213\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m 214\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m.low_memory:\n\u001b[32m--> \u001b[39m\u001b[32m215\u001b[39m chunks = \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m.\u001b[49m\u001b[43m_reader\u001b[49m\u001b[43m.\u001b[49m\u001b[43mread_low_memory\u001b[49m\u001b[43m(\u001b[49m\u001b[43mnrows\u001b[49m\u001b[43m)\u001b[49m\n\u001b[32m 216\u001b[39m \u001b[38;5;66;03m# destructive to chunks\u001b[39;00m\n\u001b[32m 217\u001b[39m data = _concatenate_chunks(chunks, \u001b[38;5;28mself\u001b[39m.names)\n",
46
+ "\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/parsers.pyx:832\u001b[39m, in \u001b[36mpandas._libs.parsers.TextReader.read_low_memory\u001b[39m\u001b[34m()\u001b[39m\n",
47
+ "\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/parsers.pyx:911\u001b[39m, in \u001b[36mpandas._libs.parsers.TextReader._read_rows\u001b[39m\u001b[34m()\u001b[39m\n",
48
+ "\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/parsers.pyx:1009\u001b[39m, in \u001b[36mpandas._libs.parsers.TextReader._convert_column_data\u001b[39m\u001b[34m()\u001b[39m\n",
49
+ "\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/parsers.pyx:1078\u001b[39m, in \u001b[36mpandas._libs.parsers.TextReader._convert_tokens\u001b[39m\u001b[34m()\u001b[39m\n",
50
+ "\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/parsers.pyx:1227\u001b[39m, in \u001b[36mpandas._libs.parsers.TextReader._convert_with_dtype\u001b[39m\u001b[34m()\u001b[39m\n",
51
+ "\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/parsers.pyx:1240\u001b[39m, in \u001b[36mpandas._libs.parsers.TextReader._string_convert\u001b[39m\u001b[34m()\u001b[39m\n",
52
+ "\u001b[36mFile \u001b[39m\u001b[32mpandas/_libs/parsers.pyx:1527\u001b[39m, in \u001b[36mpandas._libs.parsers._string_box_utf8\u001b[39m\u001b[34m()\u001b[39m\n",
53
+ "\u001b[31mUnicodeDecodeError\u001b[39m: 'utf-8' codec can't decode byte 0xd9 in position 56: unexpected end of data"
54
+ ]
55
+ }
56
+ ],
57
+ "source": [
58
+ "import pandas as pd\n",
59
+ "dataset28_train = '/home/skiredj.abderrahman/khalil/cleaning_data_semantic_model/train.csv'\n",
60
+ "ds28_train = pd.read_csv(dataset28_train,encoding=\"utf-8\")\n",
61
+ "ds28_train"
62
+ ]
63
+ },
64
+ {
65
+ "cell_type": "code",
66
+ "execution_count": null,
67
+ "id": "509e93c0-6e3e-4e95-a958-e6ae363582e3",
68
+ "metadata": {},
69
+ "outputs": [],
70
+ "source": [
71
+ "dataset28_val= dataset28_path/'dev.csv'\n",
72
+ "ds28_val = pd.read_csv(dataset28_val)\n",
73
+ "ds28_val"
74
+ ]
75
+ },
76
+ {
77
+ "cell_type": "code",
78
+ "execution_count": null,
79
+ "id": "4f4b5ea3-9968-4fda-a556-e5dff56069a7",
80
+ "metadata": {},
81
+ "outputs": [],
82
+ "source": [
83
+ "dataset28_test = dataset28_path/'test.csv'\n",
84
+ "ds28_test = pd.read_csv(dataset28_test)\n",
85
+ "ds28_test"
86
+ ]
87
+ },
88
+ {
89
+ "cell_type": "code",
90
+ "execution_count": null,
91
+ "id": "c4319545-d79a-42cf-a571-dbc5e77f3c79",
92
+ "metadata": {},
93
+ "outputs": [],
94
+ "source": [
95
+ "frames = [ds28_train,ds28_test, ds28_val]\n",
96
+ "ds28= pd.concat(frames)\n",
97
+ "\n"
98
+ ]
99
+ },
100
+ {
101
+ "cell_type": "code",
102
+ "execution_count": null,
103
+ "id": "ffc1f36b-5dcc-4e4a-9f52-25f61124c198",
104
+ "metadata": {},
105
+ "outputs": [],
106
+ "source": [
107
+ "ds28 = ds28[(ds28['label']==0)]"
108
+ ]
109
+ },
110
+ {
111
+ "cell_type": "code",
112
+ "execution_count": null,
113
+ "id": "b9e7708b-08e6-41d8-9234-7ce1a606ab06",
114
+ "metadata": {},
115
+ "outputs": [],
116
+ "source": []
117
+ },
118
+ {
119
+ "cell_type": "code",
120
+ "execution_count": null,
121
+ "id": "448b55fc-99ef-45ff-95f9-bf71b41b4142",
122
+ "metadata": {},
123
+ "outputs": [],
124
+ "source": []
125
+ },
126
+ {
127
+ "cell_type": "code",
128
+ "execution_count": null,
129
+ "id": "29396884-3b3c-409f-8dda-2a600c16a83b",
130
+ "metadata": {},
131
+ "outputs": [],
132
+ "source": []
133
+ },
134
+ {
135
+ "cell_type": "code",
136
+ "execution_count": null,
137
+ "id": "d27f0e50-0e88-4121-add5-d70cc11a5afc",
138
+ "metadata": {},
139
+ "outputs": [],
140
+ "source": []
141
+ },
142
+ {
143
+ "cell_type": "code",
144
+ "execution_count": null,
145
+ "id": "e20139b4-7ccc-48c4-bd95-26e483d9d4ee",
146
+ "metadata": {},
147
+ "outputs": [],
148
+ "source": []
149
+ },
150
+ {
151
+ "cell_type": "code",
152
+ "execution_count": null,
153
+ "id": "d19a5b00-23d3-49e7-bfc5-0d959ef87965",
154
+ "metadata": {},
155
+ "outputs": [],
156
+ "source": []
157
+ },
158
+ {
159
+ "cell_type": "code",
160
+ "execution_count": null,
161
+ "id": "7d9c2e1d-3c02-450f-bc00-08019e3a6c6c",
162
+ "metadata": {},
163
+ "outputs": [],
164
+ "source": []
165
+ },
166
+ {
167
+ "cell_type": "code",
168
+ "execution_count": null,
169
+ "id": "ce6734b0-0599-46ee-97d5-42b1c6840473",
170
+ "metadata": {},
171
+ "outputs": [],
172
+ "source": []
173
+ },
174
+ {
175
+ "cell_type": "code",
176
+ "execution_count": null,
177
+ "id": "9546364c-110f-4d6b-bbf9-881a2080ed51",
178
+ "metadata": {},
179
+ "outputs": [],
180
+ "source": []
181
+ },
182
+ {
183
+ "cell_type": "code",
184
+ "execution_count": null,
185
+ "id": "a6e04d90-6932-4dd6-8cd2-82618d41b23d",
186
+ "metadata": {},
187
+ "outputs": [],
188
+ "source": []
189
+ }
190
+ ],
191
+ "metadata": {
192
+ "kernelspec": {
193
+ "display_name": "Python 3 (ipykernel)",
194
+ "language": "python",
195
+ "name": "python3"
196
+ },
197
+ "language_info": {
198
+ "codemirror_mode": {
199
+ "name": "ipython",
200
+ "version": 3
201
+ },
202
+ "file_extension": ".py",
203
+ "mimetype": "text/x-python",
204
+ "name": "python",
205
+ "nbconvert_exporter": "python",
206
+ "pygments_lexer": "ipython3",
207
+ "version": "3.11.14"
208
+ }
209
+ },
210
+ "nbformat": 4,
211
+ "nbformat_minor": 5
212
+ }