-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregdata.py
295 lines (289 loc) · 9.18 KB
/
regdata.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
import numpy as np
import pandas as pd
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
def vec(*args):
if len(args) == 1:
return np.array(args[0], dtype=np.float64)
else:
return np.array(args, dtype=np.float64)
concrete_df = pd.read_csv('http://raw.githubusercontent.com/jcostacurta11/ssea/main/concrete_data_ssea.csv')
diabetes_df = pd.read_csv('http://raw.githubusercontent.com/jcostacurta11/ssea/main/diabetes_data_ssea.csv')
nyse_df = pd.read_csv('http://raw.githubusercontent.com/jcostacurta11/ssea/main/nyse_data_ssea.csv')
spotify_df = pd.read_csv('http://raw.githubusercontent.com/jcostacurta11/ssea/main/spotify_data_ssea.csv')
nba_df = pd.read_csv('http://raw.githubusercontent.com/jcostacurta11/ssea/main/nba_data_ssea.csv')
quartet = np.loadtxt("quartet.txt")
datasets = {
"ice_cream": # Dataset id, shown in the selection menu
{
"text": "Ice Cream example", # Description, shown when selected, LaTeX not supported
"axes":
{
"temperature": # Axis id, shown in the selection menu
{
"text": "temperature", # Axis title, shown in the graph, LaTeX supported
"vec": vec(60, 72, 67, 80), # Data in numpy.array
"range": (50, 90) # Plotting range; there are problems in Matplotlib automations
},
"cones sold":
{
"text": "cones sold",
"vec": vec(63, 76, 70, 80),
"range": (55, 90)
}
}
},
"book1": # Dataset id, shown in the selection menu
{
"text": "Example 7.3.2 on the MATH 51 textbook", # Description, shown when selected, LaTeX not supported
"axes":
{
"x": # Axis id, shown in the selection menu
{
"text": "x axis", # Axis title, shown in the graph, LaTeX supported
"vec": vec(-5.0, -4.0, -3.0, -2.0, -1.0), # Data in numpy.array
"range": (-5.5, -0.5) # Plotting range; there are problems in Matplotlib automations
},
"y":
{
"text": "y axis",
"vec": vec(-5.0, 3.0, 1.0, -3.0, 4.0),
"range": (-6.0, 5.0)
}
}
},
"book2":
{
"text": "Example 7.3.3 on the MATH 51 textbook",
"axes":
{
"x":
{
"text": "x axis",
"vec": vec(-1.0, 0.0, 2.0, 7.0),
"range": (-2.0, 8.0)
},
"y":
{
"text": "y axis",
"vec": vec(5.0, 1.0, -3.0, -4.0),
"range": (-5.0, 6.0)
},
}
},
"concrete": # Dataset id, shown in the selection menu
{
"text": "Concrete dataset", # Description, shown when selected, LaTeX not supported
"axes":
{
"cement": # Axis id, shown in the selection menu
{
"text": "cement", # Axis title, shown in the graph, LaTeX supported
"vec": concrete_df['cement'].values, # Data in numpy.array
"range": (80, 600) # Plotting range; there are problems in Matplotlib automations
},
"water":
{
"text": "water",
"vec": concrete_df['water'].values,
"range": (110, 260)
},
"strength":
{
"text": "strength",
"vec": concrete_df['strength'].values,
"range": (0, 90)
}
}
},
"diabetes": # Dataset id, shown in the selection menu
{
"text": "Diabetes dataset", # Description, shown when selected, LaTeX not supported
"axes":
{
"ltg": # Axis id, shown in the selection menu
{
"text": "ltg", # Axis title, shown in the graph, LaTeX supported
"vec": diabetes_df['ltg'].values, # Data in numpy.array
"range": (3.4, 6.2) # Plotting range; there are problems in Matplotlib automations
},
"glu":
{
"text": "glu",
"vec": diabetes_df['glu'].values,
"range": (68, 125)
},
"y":
{
"text": "y",
"vec": diabetes_df['y'].values,
"range": (0, 350)
}
}
},
"nyse": # Dataset id, shown in the selection menu
{
"text": "New York Stock Exchange dataset", # Description, shown when selected, LaTeX not supported
"axes":
{
"PYPL": # Axis id, shown in the selection menu
{
"text": "PYPL", # Axis title, shown in the graph, LaTeX supported
"vec": nyse_df[nyse_df.symbol=="PYPL"].close.values,
#"vec": nyse_df['PYPL'].values, # Data in numpy.array
"range": (36, 45) # Plotting range; there are problems in Matplotlib automations
},
"MSFT":
{
"text": "MSFT",
"vec": nyse_df[nyse_df.symbol=="MSFT"].close.values,
"range": (56, 64)
},
"AAPL":
{
"text": "AAPL",
"vec": nyse_df[nyse_df.symbol=="AAPL"].close.values,
"range": (102, 120)
}
}
},
"nba": # Dataset id, shown in the selection menu
{
"text": "NBA dataset", # Description, shown when selected, LaTeX not supported
"axes":
{
"TOV": # Axis id, shown in the selection menu
{
"text": "TOV", # Axis title, shown in the graph, LaTeX supported
"vec": nba_df['TOV'].values, # Data in numpy.array
"range": (0, 3.5) # Plotting range; there are problems in Matplotlib automations
},
"TRB":
{
"text": "TRB",
"vec": nba_df['TRB'].values,
"range": (0, 13)
},
"PTS":
{
"text": "PTS",
"vec": nba_df['PTS'].values,
"range": (0, 30)
}
}
},
"spotify": # Dataset id, shown in the selection menu
{
"text": "Spotify Top 100 Songs dataset", # Description, shown when selected, LaTeX not supported
"axes":
{
"loudness": # Axis id, shown in the selection menu
{
"text": "loudness", # Axis title, shown in the graph, LaTeX supported
"vec": spotify_df['loudness'].values, # Data in numpy.array
"range": (-14, -2) # Plotting range; there are problems in Matplotlib automations
},
"acousticness":
{
"text": "acousticness",
"vec": spotify_df['acousticness'].values,
"range": (0, 1)
},
"energy":
{
"text": "energy",
"vec": spotify_df['energy'].values,
"range": (0, 1)
}
}
},
"Quartet I":
{
"text": "First panel of Anscombe's quartet",
"axes":
{
"x":
{
"text": "$x$ axis",
"vec": quartet[0, :],
"range": "auto"
},
"y":
{
"text": "$y$ axis",
"vec": quartet[1, :],
"range": "auto"
},
}
},
"Quartet II":
{
"text": "Second panel of Anscombe's quartet",
"axes":
{
"x":
{
"text": "$x$ axis",
"vec": quartet[2, :],
"range": "auto"
},
"y":
{
"text": "$y$ axis",
"vec": quartet[3, :],
"range": "auto"
},
}
},
"Quartet III":
{
"text": "Third panel of Anscombe's quartet",
"axes":
{
"x":
{
"text": "$x$ axis",
"vec": quartet[4, :],
"range": "auto"
},
"y":
{
"text": "$y$ axis",
"vec": quartet[5, :],
"range": "auto"
},
}
},
"Quartet IV":
{
"text": "Fourth panel of Anscombe's quartet",
"axes":
{
"x":
{
"text": "$x$ axis",
"vec": quartet[6, :],
"range": "auto"
},
"y":
{
"text": "$y$ axis",
"vec": quartet[7, :],
"range": "auto"
},
}
}
}
# Regularize
for ds_name in datasets:
ds = datasets[ds_name]
for ax_name in ds["axes"]:
ax = ds["axes"][ax_name]
vec = ax["vec"]
ax["vec"] = np.array(vec)
range = ax["range"]
if isinstance(range, str) and range == "auto":
delta = 0.1
vmin, vmax = np.min(vec), np.max(vec)
range = ((1.0+delta)*vmin - delta*vmax, (1.0+delta)*vmax - delta*vmin)
ax["range"] = range