Skip to content

Commit 43e1bc1

Browse files
committed
updated benchmark notebooks for refactored code
1 parent 1c2e0e6 commit 43e1bc1

File tree

2 files changed

+104
-42
lines changed

2 files changed

+104
-42
lines changed

extras/ClusteringJL & ParallelKMeans Benchmarks.ipynb

Lines changed: 103 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,54 @@
222222
}
223223
],
224224
"source": [
225-
"@benchmark [ParallelKMeans.kmeans(X, i, ParallelKMeans.SingleThread(),\n",
226-
" tol=1e-4, max_iters=300, verbose=false).totalcost \n",
227-
" for i = 2:10] samples=7 seconds=300"
225+
"@benchmark [ParallelKMeans.kmeans(LightElkan(), X, i, n_threads=1,\n",
226+
" tol=1e-6, max_iters=300, verbose=false).totalcost \n",
227+
" for i = 2:10] samples=7 seconds=600"
228228
]
229229
},
230+
{
231+
"cell_type": "code",
232+
"execution_count": null,
233+
"metadata": {},
234+
"outputs": [],
235+
"source": []
236+
},
237+
{
238+
"cell_type": "code",
239+
"execution_count": null,
240+
"metadata": {},
241+
"outputs": [],
242+
"source": [
243+
"@benchmark [ParallelKMeans.kmeans(Lloyd(), X, i, n_threads=1,\n",
244+
" tol=1e-6, max_iters=300, verbose=false).totalcost \n",
245+
" for i = 2:10] samples=7 seconds=600"
246+
]
247+
},
248+
{
249+
"cell_type": "code",
250+
"execution_count": null,
251+
"metadata": {},
252+
"outputs": [],
253+
"source": [
254+
"d = [ParallelKMeans.kmeans(Lloyd(), X, i, n_threads=1,\n",
255+
" tol=1e-6, max_iters=300, verbose=false).totalcost \n",
256+
" for i = 2:10] samples=7 seconds=600"
257+
]
258+
},
259+
{
260+
"cell_type": "code",
261+
"execution_count": null,
262+
"metadata": {},
263+
"outputs": [],
264+
"source": []
265+
},
266+
{
267+
"cell_type": "code",
268+
"execution_count": null,
269+
"metadata": {},
270+
"outputs": [],
271+
"source": []
272+
},
230273
{
231274
"cell_type": "code",
232275
"execution_count": 19,
@@ -253,8 +296,9 @@
253296
}
254297
],
255298
"source": [
256-
"b = [ParallelKMeans.kmeans(X, i, ParallelKMeans.SingleThread(),\n",
257-
" tol=1e-4, max_iters=300, verbose=false).totalcost for i = 2:10]"
299+
"b = [ParallelKMeans.kmeans(LightElkan(), X, i, n_threads=1,\n",
300+
" tol=1e-6, max_iters=300, verbose=false).totalcost \n",
301+
" for i = 2:10] samples=7 seconds=600"
258302
]
259303
},
260304
{
@@ -305,9 +349,9 @@
305349
}
306350
],
307351
"source": [
308-
"@benchmark [ParallelKMeans.kmeans(X, i, ParallelKMeans.MultiThread(),\n",
309-
" tol=1e-4, max_iters=300, verbose=false).totalcost \n",
310-
" for i = 2:10] samples=7 seconds=300"
352+
"@benchmark [ParallelKMeans.kmeans(LightElkan(), X, i, n_threads=6,\n",
353+
" tol=1e-6, max_iters=300, verbose=false).totalcost \n",
354+
" for i = 2:10] samples=7 seconds=600"
311355
]
312356
},
313357
{
@@ -336,10 +380,54 @@
336380
}
337381
],
338382
"source": [
339-
"c = [ParallelKMeans.kmeans(X, i, ParallelKMeans.MultiThread(), \n",
340-
" tol=1e-4, max_iters=300, verbose=false).totalcost for i = 2:10]"
383+
"c = [ParallelKMeans.kmeans(LightElkan(), X, i, n_threads=6,\n",
384+
" tol=1e-6, max_iters=300, verbose=false).totalcost \n",
385+
" for i = 2:10] samples=7 seconds=600"
341386
]
342387
},
388+
{
389+
"cell_type": "code",
390+
"execution_count": null,
391+
"metadata": {},
392+
"outputs": [],
393+
"source": []
394+
},
395+
{
396+
"cell_type": "code",
397+
"execution_count": null,
398+
"metadata": {},
399+
"outputs": [],
400+
"source": [
401+
"@benchmark [ParallelKMeans.kmeans(Lloyd(), X, i, n_threads=6,\n",
402+
" tol=1e-6, max_iters=300, verbose=false).totalcost \n",
403+
" for i = 2:10] samples=7 seconds=600"
404+
]
405+
},
406+
{
407+
"cell_type": "code",
408+
"execution_count": null,
409+
"metadata": {},
410+
"outputs": [],
411+
"source": [
412+
"e = [ParallelKMeans.kmeans(Lloyd(), X, i, n_threads=6,\n",
413+
" tol=1e-6, max_iters=300, verbose=false).totalcost \n",
414+
" for i = 2:10] samples=7 seconds=600"
415+
]
416+
},
417+
{
418+
"cell_type": "code",
419+
"execution_count": null,
420+
"metadata": {},
421+
"outputs": [],
422+
"source": []
423+
},
424+
{
425+
"cell_type": "code",
426+
"execution_count": null,
427+
"metadata": {},
428+
"outputs": [],
429+
"source": []
430+
},
343431
{
344432
"cell_type": "code",
345433
"execution_count": 17,
@@ -504,8 +592,10 @@
504592
],
505593
"source": [
506594
"plot(a, label=\"Clustering.jl\")\n",
507-
"plot!(b, label=\"Single Thread\")\n",
508-
"plot!(c, label=\"Multi Thread\")"
595+
"plot!(b, label=\"Elkan Single Thread Implementation\")\n",
596+
"plot!(c, label=\"Elkan Multi Thread Implementation\")\n",
597+
"plot!(d, label=\"Lloyd Single Thread Implementation\")\n",
598+
"plot!(e, label=\"Lloyd Multi Thread Implementation\")"
509599
]
510600
},
511601
{
@@ -587,4 +677,4 @@
587677
},
588678
"nbformat": 4,
589679
"nbformat_minor": 4
590-
}
680+
}

extras/Sklearn Benchmark.ipynb

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -180,34 +180,6 @@
180180
"X"
181181
]
182182
},
183-
{
184-
"cell_type": "code",
185-
"execution_count": 3,
186-
"metadata": {
187-
"ExecuteTime": {
188-
"end_time": "2020-03-13T08:58:58.668475Z",
189-
"start_time": "2020-03-13T08:58:58.666387Z"
190-
}
191-
},
192-
"outputs": [],
193-
"source": [
194-
"#X_small = np.random.rand(100_000, 30)"
195-
]
196-
},
197-
{
198-
"cell_type": "code",
199-
"execution_count": 4,
200-
"metadata": {
201-
"ExecuteTime": {
202-
"end_time": "2020-03-13T08:58:59.343126Z",
203-
"start_time": "2020-03-13T08:58:59.341184Z"
204-
}
205-
},
206-
"outputs": [],
207-
"source": [
208-
"#np.savetxt('data_small.csv', X_small, delimiter=',')"
209-
]
210-
},
211183
{
212184
"cell_type": "code",
213185
"execution_count": null,
@@ -642,4 +614,4 @@
642614
},
643615
"nbformat": 4,
644616
"nbformat_minor": 4
645-
}
617+
}

0 commit comments

Comments
 (0)