Edward J. Schwartz commited on
Commit
aa9fb06
·
1 Parent(s): 9b556fe

Add data import notebook

Browse files
Files changed (1) hide show
  1. scripts/import_data.ipynb +211 -0
scripts/import_data.ipynb ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 3,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "data": {
10
+ "text/plain": [
11
+ "0"
12
+ ]
13
+ },
14
+ "execution_count": 3,
15
+ "metadata": {},
16
+ "output_type": "execute_result"
17
+ }
18
+ ],
19
+ "source": [
20
+ "import datasets\n",
21
+ "import subprocess\n",
22
+ "subprocess.check_call(\"rm -rf /tmp/somewhere\", shell=True)\n",
23
+ "subprocess.check_call(\"mkdir -p /tmp/somewhere\", shell=True)\n",
24
+ "subprocess.check_call(\"find /home/eschwartz/ooanalyzer-tests/code/testcases/BuildExes -name '*.csv' | tar -T - -c | tar -C /tmp/somewhere -x\", shell=True)"
25
+ ]
26
+ },
27
+ {
28
+ "cell_type": "code",
29
+ "execution_count": 4,
30
+ "metadata": {},
31
+ "outputs": [
32
+ {
33
+ "data": {
34
+ "application/vnd.jupyter.widget-view+json": {
35
+ "model_id": "f5fcd73fed67440fb58577b26fc3605b",
36
+ "version_major": 2,
37
+ "version_minor": 0
38
+ },
39
+ "text/plain": [
40
+ "Resolving data files: 0%| | 0/3600 [00:00<?, ?it/s]"
41
+ ]
42
+ },
43
+ "metadata": {},
44
+ "output_type": "display_data"
45
+ },
46
+ {
47
+ "name": "stderr",
48
+ "output_type": "stream",
49
+ "text": [
50
+ "Using custom data configuration default-d4ff6d0a10e1667b\n"
51
+ ]
52
+ },
53
+ {
54
+ "name": "stdout",
55
+ "output_type": "stream",
56
+ "text": [
57
+ "Downloading and preparing dataset csv/default to /home/eschwartz/.cache/huggingface/datasets/csv/default-d4ff6d0a10e1667b/0.0.0/652c3096f041ee27b04d2232d41f10547a8fecda3e284a79a0ec4053c916ef7a...\n"
58
+ ]
59
+ },
60
+ {
61
+ "data": {
62
+ "application/vnd.jupyter.widget-view+json": {
63
+ "model_id": "1053b5ee5bf248ff8dd5dccc8d3f3dca",
64
+ "version_major": 2,
65
+ "version_minor": 0
66
+ },
67
+ "text/plain": [
68
+ "Downloading data files: 0%| | 0/1 [00:00<?, ?it/s]"
69
+ ]
70
+ },
71
+ "metadata": {},
72
+ "output_type": "display_data"
73
+ },
74
+ {
75
+ "data": {
76
+ "application/vnd.jupyter.widget-view+json": {
77
+ "model_id": "506e7a9d89ad4947a83bea2adbe52058",
78
+ "version_major": 2,
79
+ "version_minor": 0
80
+ },
81
+ "text/plain": [
82
+ "Extracting data files: 0%| | 0/1 [00:00<?, ?it/s]"
83
+ ]
84
+ },
85
+ "metadata": {},
86
+ "output_type": "display_data"
87
+ },
88
+ {
89
+ "data": {
90
+ "application/vnd.jupyter.widget-view+json": {
91
+ "model_id": "5caaf14e723e48c0aa67859e8bcb9767",
92
+ "version_major": 2,
93
+ "version_minor": 0
94
+ },
95
+ "text/plain": [
96
+ "0 tables [00:00, ? tables/s]"
97
+ ]
98
+ },
99
+ "metadata": {},
100
+ "output_type": "display_data"
101
+ },
102
+ {
103
+ "name": "stdout",
104
+ "output_type": "stream",
105
+ "text": [
106
+ "Dataset csv downloaded and prepared to /home/eschwartz/.cache/huggingface/datasets/csv/default-d4ff6d0a10e1667b/0.0.0/652c3096f041ee27b04d2232d41f10547a8fecda3e284a79a0ec4053c916ef7a. Subsequent calls will reuse this data.\n"
107
+ ]
108
+ },
109
+ {
110
+ "data": {
111
+ "application/vnd.jupyter.widget-view+json": {
112
+ "model_id": "8efb31f928ed4c8fa3cd4fb65e0c5916",
113
+ "version_major": 2,
114
+ "version_minor": 0
115
+ },
116
+ "text/plain": [
117
+ " 0%| | 0/1 [00:00<?, ?it/s]"
118
+ ]
119
+ },
120
+ "metadata": {},
121
+ "output_type": "display_data"
122
+ },
123
+ {
124
+ "data": {
125
+ "application/vnd.jupyter.widget-view+json": {
126
+ "model_id": "d85b42c7cc8a4421a9669d01ea4bd220",
127
+ "version_major": 2,
128
+ "version_minor": 0
129
+ },
130
+ "text/plain": [
131
+ "Casting to class labels: 0%| | 0/2970 [00:00<?, ?ba/s]"
132
+ ]
133
+ },
134
+ "metadata": {},
135
+ "output_type": "display_data"
136
+ },
137
+ {
138
+ "data": {
139
+ "application/vnd.jupyter.widget-view+json": {
140
+ "model_id": "51a1d48faae14bbe9a9701f26961c6a5",
141
+ "version_major": 2,
142
+ "version_minor": 0
143
+ },
144
+ "text/plain": [
145
+ "Casting the dataset: 0%| | 0/297 [00:00<?, ?ba/s]"
146
+ ]
147
+ },
148
+ "metadata": {},
149
+ "output_type": "display_data"
150
+ }
151
+ ],
152
+ "source": [
153
+ "ds = datasets.load_dataset(\"csv\", data_dir=\"/tmp/somewhere\")\n",
154
+ "ds = ds.class_encode_column('Type')\n",
155
+ "ds['combined'] = ds['train']\n",
156
+ "del ds['train']"
157
+ ]
158
+ },
159
+ {
160
+ "cell_type": "code",
161
+ "execution_count": 7,
162
+ "metadata": {},
163
+ "outputs": [
164
+ {
165
+ "data": {
166
+ "text/plain": [
167
+ "2969790"
168
+ ]
169
+ },
170
+ "execution_count": 7,
171
+ "metadata": {},
172
+ "output_type": "execute_result"
173
+ }
174
+ ],
175
+ "source": [
176
+ "len(ds['combined'])"
177
+ ]
178
+ },
179
+ {
180
+ "cell_type": "code",
181
+ "execution_count": null,
182
+ "metadata": {},
183
+ "outputs": [],
184
+ "source": [
185
+ "ds.push_to_hub('ejschwartz/oo-model-test')"
186
+ ]
187
+ }
188
+ ],
189
+ "metadata": {
190
+ "kernelspec": {
191
+ "display_name": "Python 3",
192
+ "language": "python",
193
+ "name": "python3"
194
+ },
195
+ "language_info": {
196
+ "codemirror_mode": {
197
+ "name": "ipython",
198
+ "version": 3
199
+ },
200
+ "file_extension": ".py",
201
+ "mimetype": "text/x-python",
202
+ "name": "python",
203
+ "nbconvert_exporter": "python",
204
+ "pygments_lexer": "ipython3",
205
+ "version": "3.6.8"
206
+ },
207
+ "orig_nbformat": 4
208
+ },
209
+ "nbformat": 4,
210
+ "nbformat_minor": 2
211
+ }