Skip to content

Instantly share code, notes, and snippets.

@jnothman
Created January 10, 2018 02:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnothman/a88df72e8ec81d778c6a267751b45d7d to your computer and use it in GitHub Desktop.
Save jnothman/a88df72e8ec81d778c6a267751b45d7d to your computer and use it in GitHub Desktop.
elapsed n_features n_samples_Y working_memory
0 37.13675403594971 1000 100 1
1 36.132298946380615 1000 100 1
2 38.42840266227722 1000 100 1
3 37.29706525802612 1000 1000 1
4 34.58624744415283 1000 1000 1
5 36.96818971633911 1000 1000 1
6 38.077014684677124 1000 5000 1
7 36.49429655075073 1000 5000 1
8 39.22079372406006 1000 5000 1
9 41.040854930877686 1000 10000 1
10 37.470131397247314 1000 10000 1
11 35.889419078826904 1000 10000 1
12 36.777167558670044 1000 20000 1
13 38.31300902366638 1000 20000 1
14 39.52523994445801 1000 20000 1
15 35.60521388053894 1000 40000 1
16 35.17600703239441 1000 40000 1
17 37.92395853996277 1000 40000 1
18 7.945574998855591 1000 100 10
19 8.13128662109375 1000 100 10
20 9.617395162582397 1000 100 10
21 8.953482866287231 1000 1000 10
22 8.455490350723267 1000 1000 10
23 10.507353067398071 1000 1000 10
24 10.528460025787354 1000 5000 10
25 9.942165851593018 1000 5000 10
26 8.466912984848022 1000 5000 10
27 9.371960878372192 1000 10000 10
28 9.321511507034302 1000 10000 10
29 9.307451963424683 1000 10000 10
30 9.240359544754028 1000 20000 10
31 7.921821594238281 1000 20000 10
32 8.156615495681763 1000 20000 10
33 10.497743606567383 1000 40000 10
34 10.5108642578125 1000 40000 10
35 11.022602558135986 1000 40000 10
36 7.506581544876099 1000 100 22
37 6.865436553955078 1000 100 22
38 6.916350364685059 1000 100 22
39 6.938366651535034 1000 1000 22
40 6.860426664352417 1000 1000 22
41 6.985377073287964 1000 1000 22
42 8.665016412734985 1000 5000 22
43 7.976823806762695 1000 5000 22
44 7.934923410415649 1000 5000 22
45 8.197910070419312 1000 10000 22
46 9.538393497467041 1000 10000 22
47 7.691818475723267 1000 10000 22
48 10.371065855026245 1000 20000 22
49 10.30887484550476 1000 20000 22
50 7.055976629257202 1000 20000 22
51 7.345956802368164 1000 40000 22
52 6.864009380340576 1000 40000 22
53 7.503612041473389 1000 40000 22
54 9.26689100265503 1000 100 46
55 5.9832305908203125 1000 100 46
56 5.86765718460083 1000 100 46
57 6.2745442390441895 1000 1000 46
58 6.077730894088745 1000 1000 46
59 8.620609283447266 1000 1000 46
60 7.183454513549805 1000 5000 46
61 6.000822067260742 1000 5000 46
62 6.433218717575073 1000 5000 46
63 8.945240259170532 1000 10000 46
64 9.437402963638306 1000 10000 46
65 9.360684394836426 1000 10000 46
66 9.397956132888794 1000 20000 46
67 8.977484464645386 1000 20000 46
68 6.521108150482178 1000 20000 46
69 9.240561246871948 1000 40000 46
70 9.126695156097412 1000 40000 46
71 9.337595701217651 1000 40000 46
72 6.108522176742554 1000 100 100
73 6.190439939498901 1000 100 100
74 8.920239925384521 1000 100 100
75 6.22664213180542 1000 1000 100
76 6.2744362354278564 1000 1000 100
77 6.892057180404663 1000 1000 100
78 6.125212669372559 1000 5000 100
79 6.390931606292725 1000 5000 100
80 5.860802888870239 1000 5000 100
81 5.94787073135376 1000 10000 100
82 6.380070209503174 1000 10000 100
83 5.762305498123169 1000 10000 100
84 5.796365022659302 1000 20000 100
85 5.8977391719818115 1000 20000 100
86 6.982810735702515 1000 20000 100
87 6.763919830322266 1000 40000 100
88 6.436359405517578 1000 40000 100
89 6.668315172195435 1000 40000 100
90 7.984844446182251 1000 100 215
91 6.697038412094116 1000 100 215
92 6.3456385135650635 1000 100 215
93 6.373361110687256 1000 1000 215
94 6.670315265655518 1000 1000 215
95 5.827749013900757 1000 1000 215
96 6.127725839614868 1000 5000 215
97 5.916211366653442 1000 5000 215
98 5.870636701583862 1000 5000 215
99 6.006459951400757 1000 10000 215
100 6.053380012512207 1000 10000 215
101 6.321534633636475 1000 10000 215
102 6.3428239822387695 1000 20000 215
103 6.5883355140686035 1000 20000 215
104 6.867776393890381 1000 20000 215
105 7.768782377243042 1000 40000 215
106 7.494115829467773 1000 40000 215
107 5.967188596725464 1000 40000 215
108 5.748559474945068 1000 100 464
109 5.445612192153931 1000 100 464
110 5.374830007553101 1000 100 464
111 5.726091146469116 1000 1000 464
112 5.5843117237091064 1000 1000 464
113 7.309995412826538 1000 1000 464
114 7.610095262527466 1000 5000 464
115 5.567022323608398 1000 5000 464
116 7.20658540725708 1000 5000 464
117 8.398364782333374 1000 10000 464
118 5.3035101890563965 1000 10000 464
119 5.459115505218506 1000 10000 464
120 6.788848876953125 1000 20000 464
121 5.532287120819092 1000 20000 464
122 8.136994361877441 1000 20000 464
123 6.863664388656616 1000 40000 464
124 5.444483041763306 1000 40000 464
125 5.391214370727539 1000 40000 464
126 4.077996015548706 1000 100 1000
127 4.009350776672363 1000 100 1000
128 5.527165412902832 1000 100 1000
129 4.931031703948975 1000 1000 1000
130 4.086518049240112 1000 1000 1000
131 4.182145118713379 1000 1000 1000
132 4.249395847320557 1000 5000 1000
133 4.243336915969849 1000 5000 1000
134 5.00449275970459 1000 5000 1000
135 4.0042030811309814 1000 10000 1000
136 4.767882585525513 1000 10000 1000
137 4.200859546661377 1000 10000 1000
138 4.292890310287476 1000 20000 1000
139 3.946220636367798 1000 20000 1000
140 4.54971718788147 1000 20000 1000
141 4.067296981811523 1000 40000 1000
142 4.247687578201294 1000 40000 1000
143 4.53557014465332 1000 40000 1000
144 5.1056976318359375 1000 100 10000
145 3.9715845584869385 1000 100 10000
146 4.3140788078308105 1000 100 10000
147 4.355549573898315 1000 1000 10000
148 4.633264064788818 1000 1000 10000
149 4.367297649383545 1000 1000 10000
150 4.373786687850952 1000 5000 10000
151 4.207195043563843 1000 5000 10000
152 4.005875110626221 1000 5000 10000
153 4.240742921829224 1000 10000 10000
154 4.048830509185791 1000 10000 10000
155 4.360719442367554 1000 10000 10000
156 4.008803606033325 1000 20000 10000
157 4.147165775299072 1000 20000 10000
158 4.796399354934692 1000 20000 10000
159 4.445807933807373 1000 40000 10000
160 4.055687427520752 1000 40000 10000
161 3.985114812850952 1000 40000 10000
162 306.46002864837646 10000 100 1
163 321.0840425491333 10000 100 1
164 302.8335163593292 10000 100 1
165 303.10264897346497 10000 1000 1
166 324.8063907623291 10000 1000 1
167 316.22884249687195 10000 1000 1
168 306.8931243419647 10000 5000 1
169 303.36182403564453 10000 5000 1
170 312.9556851387024 10000 5000 1
171 323.3870460987091 10000 10000 1
172 312.6436986923218 10000 10000 1
173 315.99045276641846 10000 10000 1
174 315.6295053958893 10000 20000 1
175 317.34778022766113 10000 20000 1
176 317.77324295043945 10000 20000 1
177 313.41250562667847 10000 40000 1
178 314.2118170261383 10000 40000 1
179 310.26009130477905 10000 40000 1
180 61.520129442214966 10000 100 10
181 61.76245093345642 10000 100 10
182 58.02867031097412 10000 100 10
183 68.37717890739441 10000 1000 10
184 59.02645492553711 10000 1000 10
185 59.868505239486694 10000 1000 10
186 62.002349615097046 10000 5000 10
187 64.27063846588135 10000 5000 10
188 66.15986752510071 10000 5000 10
189 61.053319215774536 10000 10000 10
190 60.31051015853882 10000 10000 10
191 59.68027329444885 10000 10000 10
192 63.39004135131836 10000 20000 10
193 61.59121656417847 10000 20000 10
194 59.59076547622681 10000 20000 10
195 62.99620962142944 10000 40000 10
196 62.51299238204956 10000 40000 10
197 60.945109844207764 10000 40000 10
198 48.50593304634094 10000 100 22
199 51.57991313934326 10000 100 22
200 46.80163335800171 10000 100 22
201 45.49610996246338 10000 1000 22
202 46.35135889053345 10000 1000 22
203 51.30291795730591 10000 1000 22
204 51.415576219558716 10000 5000 22
205 45.00487279891968 10000 5000 22
206 53.82404160499573 10000 5000 22
207 50.860124349594116 10000 10000 22
208 48.36806344985962 10000 10000 22
209 51.329968214035034 10000 10000 22
210 45.61900973320007 10000 20000 22
211 47.86839532852173 10000 20000 22
212 49.94727110862732 10000 20000 22
213 52.49519109725952 10000 40000 22
214 45.58290958404541 10000 40000 22
215 48.57019877433777 10000 40000 22
216 46.89918875694275 10000 100 46
217 43.1262526512146 10000 100 46
218 51.516653060913086 10000 100 46
219 47.94166445732117 10000 1000 46
220 44.43951892852783 10000 1000 46
221 40.997456550598145 10000 1000 46
222 39.03707194328308 10000 5000 46
223 42.46465229988098 10000 5000 46
224 47.44142413139343 10000 5000 46
225 40.64868521690369 10000 10000 46
226 41.08204102516174 10000 10000 46
227 46.2605037689209 10000 10000 46
228 44.68387508392334 10000 20000 46
229 44.68542671203613 10000 20000 46
230 45.22680950164795 10000 20000 46
231 46.099387884140015 10000 40000 46
232 46.0346143245697 10000 40000 46
233 48.662638664245605 10000 40000 46
234 41.328455448150635 10000 100 100
235 41.84577488899231 10000 100 100
236 39.872676849365234 10000 100 100
237 37.70633339881897 10000 1000 100
238 43.21938180923462 10000 1000 100
239 39.3942596912384 10000 1000 100
240 43.587756633758545 10000 5000 100
241 40.60317802429199 10000 5000 100
242 45.55602169036865 10000 5000 100
243 41.68804883956909 10000 10000 100
244 42.29898524284363 10000 10000 100
245 38.85870027542114 10000 10000 100
246 39.575913190841675 10000 20000 100
247 39.88115382194519 10000 20000 100
248 44.03250598907471 10000 20000 100
249 45.344155073165894 10000 40000 100
250 38.09592580795288 10000 40000 100
251 36.68790102005005 10000 40000 100
252 33.263712882995605 10000 100 215
253 36.15194010734558 10000 100 215
254 48.276960611343384 10000 100 215
255 32.551597118377686 10000 1000 215
256 35.220256090164185 10000 1000 215
257 32.98057723045349 10000 1000 215
258 33.497384548187256 10000 5000 215
259 41.09240484237671 10000 5000 215
260 32.6600923538208 10000 5000 215
261 35.75971221923828 10000 10000 215
262 32.4881010055542 10000 10000 215
263 35.791629791259766 10000 10000 215
264 39.05692958831787 10000 20000 215
265 46.44854497909546 10000 20000 215
266 32.73133659362793 10000 20000 215
267 43.0353000164032 10000 40000 215
268 37.70524477958679 10000 40000 215
269 43.17614674568176 10000 40000 215
270 36.95804214477539 10000 100 464
271 43.488394260406494 10000 100 464
272 34.73945689201355 10000 100 464
273 43.659990310668945 10000 1000 464
274 36.53630018234253 10000 1000 464
275 33.356863498687744 10000 1000 464
276 48.65445303916931 10000 5000 464
277 43.346269607543945 10000 5000 464
278 37.21039652824402 10000 5000 464
279 33.41671919822693 10000 10000 464
280 41.36782932281494 10000 10000 464
281 36.9065363407135 10000 10000 464
282 39.528011322021484 10000 20000 464
283 51.37506699562073 10000 20000 464
284 44.0121431350708 10000 20000 464
285 44.26306390762329 10000 40000 464
286 34.22780466079712 10000 40000 464
287 33.51255655288696 10000 40000 464
288 17.29639768600464 10000 100 1000
289 17.580764055252075 10000 100 1000
290 18.114307641983032 10000 100 1000
291 17.72046971321106 10000 1000 1000
292 17.762829303741455 10000 1000 1000
293 21.40817403793335 10000 1000 1000
294 17.37412190437317 10000 5000 1000
295 19.391165018081665 10000 5000 1000
296 22.061135292053223 10000 5000 1000
297 22.434491872787476 10000 10000 1000
298 19.049959659576416 10000 10000 1000
299 24.277256727218628 10000 10000 1000
300 22.752324104309082 10000 20000 1000
301 17.428438901901245 10000 20000 1000
302 17.773022174835205 10000 20000 1000
303 17.54186224937439 10000 40000 1000
304 18.846614599227905 10000 40000 1000
305 17.285874605178833 10000 40000 1000
306 17.509512424468994 10000 100 10000
307 25.37671661376953 10000 100 10000
308 17.555604457855225 10000 100 10000
309 18.885108947753906 10000 1000 10000
310 19.830119132995605 10000 1000 10000
311 18.11059308052063 10000 1000 10000
312 18.379886627197266 10000 5000 10000
313 17.33135151863098 10000 5000 10000
314 25.125698566436768 10000 5000 10000
315 25.532158374786377 10000 10000 10000
316 18.11434817314148 10000 10000 10000
317 22.662693738937378 10000 10000 10000
318 24.404322385787964 10000 20000 10000
319 24.892298698425293 10000 20000 10000
320 23.493374586105347 10000 20000 10000
321 19.166558027267456 10000 40000 10000
322 21.00684690475464 10000 40000 10000
323 17.919042587280273 10000 40000 10000
import time
import numpy as np
import pandas as pd
import sklearn
from sklearn.metrics.pairwise import pairwise_distances_argmin_min
results = []
n_samples_X = 10000
for n_features in [1000, 10000]:
for working_memory in [1, 10, 22, 46, 100, 215, 464, 1000, 10000]:
with sklearn.config_context(working_memory=working_memory):
for n_samples_Y in [100, 1000, 5000, 10000, 20000, 40000]:
for i in range(3):
X = np.random.rand(n_samples_X, n_features)
Y = np.random.rand(n_samples_Y, n_features)
start = time.time()
pairwise_distances_argmin_min(X, X)
elapsed = time.time() - start
results.append({'n_samples_Y': n_samples_Y,
'n_features': n_features,
'working_memory': working_memory,
'elapsed': elapsed})
print(results[-1])
pd.DataFrame(results).to_csv('bench_working_memory.csv')
pd.DataFrame(results).to_json('bench_working_memory.json', orient='records')
import matplotlib.pyplot as plt
import pandas as pd
bench = pd.read_csv('bench_working_memory.csv')
fig, ax = plt.subplots(1)
for (n_features, df), linestyle in zip(bench.groupby('n_features', as_index=False), ['dotted', 'dashed', 'solid']):
piv = df.pivot_table('elapsed', ['working_memory'], ['n_samples_Y', 'n_features'])
piv.plot(logy=True, logx=True, marker='x', linestyle=linestyle, ax=ax)
plt.xlabel('working_memory')
plt.ylabel('time (s)')
plt.savefig('/tmp/bench_working_memory.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment