~/talk

Vectorise all the things! How basic linear algebra can speed up your data science code

Talkat PyCon UK 2022 · 2022-09-16..09-18· at 16:00· Assembly Room· [data-science]
links:none on file
slides:none on file

Implements K‑nearest neighbors in pure Python, then replaces list loops with numpy arrays arithmetic, then swaps nested loops for a broadcasted 3D subtraction using broadcasting, and finally uses numpy’s argsort/array slicing instead of Python sorts and list comprehensions. Baseline runs ~15s (small), 12min (medium), 40min (large); final version hits ~13ms, 15s, 2min respectively — roughly 1,000×, 50× and 15× speedups, showing the concrete code changes and timings that actually work.

AI-written summary · about

  1. 0:00Intro
  2. 0:34Why vectorised operations
  3. 1:06Outline
  4. 2:08Vectors
  5. 2:57Vector spaces
  6. 4:05Matrix
  7. 4:33Numpy
  8. 6:05Vector neighbours
  9. 6:36Manhattan distance
  10. 7:44Canaras neighbors
  11. 8:36First implementation
  12. 12:15Arithmetic operations
  13. 13:29Input types
  14. 14:17Relative Improvement
  15. 14:38Nested for Loop
  16. 15:43Nested for Loop example
  17. 15:57Using matrices
  18. 16:29Using 3D arrays
  19. 17:44Broadcasting
  20. 18:44Vector Subtraction
  21. 19:45Vector Subtraction Implementation
  22. 21:06Baseline Implementation
  23. 21:22Kn Implementation
  24. 21:58Python Sorting
  25. 23:24Results
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.