Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Algorithms to live by and why should we care

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

Algorithms to live by and why should we care

Presented at Full Stack Toronto Conference

Elle Meredith

October 23, 2017

Transcript

113 slides
  1. 10 STEPS 1000 -> 500 -> 250 -> 125 ->

    63 -> 32 -> 16 -> 8 -> 4 -> 2 -> 1
  2. 17 STEPS 100,000 -> 50,000 -> 25,000 -> 12,500 ->

    6,300 -> 3,150 -> 1,575 -> 788 -> 394 -> 197 -> 99 -> 50 -> 25 -> 13 -> 7 -> 4 -> 2 -> 1
  3. 22 = 4 23 = 8 24 = 16 25

    = 32 26 = 64 log2 4 = 2 log2 8 = 3 log2 100 => 6.643 log2 100000 => 16.609
  4. 37%

  5. * When we don’t know all the options, optimal stopping

    tells us when to stop and make a decision
  6. Make a pile of boxes while the pile is not

    empty Grab a box if you find a box, add it to the pile of boxes Go back to the pile if you find a diary, you’re done!
  7. Go through each item in the box if you find

    a box… if you find a diary, you’re done!
  8. def factorial(x) if x == 1 1 else x *

    factorial(x-1) end end
  9. def factorial(x) if x == 1 1 else x *

    factorial(x-1) end end
  10. def factorial(x) if x == 1 1 else x *

    factorial(x-1) end end
  11. factorial(4) = 4 * factorial(3) factorial(3) = 3 * factorial(2)

    factorial(2) = 2 * factorial(1) factorial(1) = 1
  12. factorial(4) = 4 * factorial(3) factorial(3) = 3 * factorial(2)

    factorial(2) = 2 * factorial(1) factorial(1) = 1 4 * 3 * 2 * 1 = 24
  13. * Recursion can be applied whenever a problem can be

    solved by dividing it into smaller problems
  14. Client 1: 4 days task = 4 days waiting Client

    2: 1 day task = 5 days waiting = 9 days of waiting
  15. Client 2: 1 day task = 1 days waiting Client

    1: 4 days task = 5 days waiting = 6 days of waiting
  16. Shortest processing time Client 2: 1 day task = 1

    days waiting Client 1: 4 days task = 5 days waiting = 6 days of waiting Metric: sum of completion times
  17. * Breadth first search works only we search in the

    same order in which the people (nodes) were added
  18. A (2,1) B (1,3) X Y (X1 -X2 )2 +

    (Y1 -Y2 )2 Distance between A to B C (5,5)
  19. (1-3)2 + (2- 1)2 A (2,1) C (5,5) B (1,3)

    X Y Distance between A to B
  20. (1-3)2 + (2- 1)2 A (2,1) C (5,5) B (1,3)

    X Y 22 + 12 Distance between A to B
  21. (1-3)2 + (2- 1)2 A (2,1) C (5,5) B (1,3)

    X Y 22 + 12 4 + 1 K = 2.236 Distance between A to B
  22. (5-3)2 + (5- 1)2 A (2,1) C (5,5) B (1,3)

    X Y Distance between C to B
  23. A (2,1) C (5,5) B (1,3) X Y 22 +

    42 Distance between C to B (5-3)2 + (5- 1)2
  24. A (2,1) C (5,5) B (1,3) X Y 22 +

    42 Distance between C to B (5-3)2 + (5- 1)2 4 + 16 K = 4. 472
  25. hannah => (4, 4, 5, 1, 1) caleb => (5,

    5, 3, 2, 1) lachlan => (2, 1, 5, 3, 5)
  26. (4-5)2 + (4-5)2 + (5-3)2 + (1-2)2 + (1- 1)2

    hannah => (4, 4, 5, 1, 1) caleb => (5, 5, 3, 2, 1)
  27. (4-2)2 + (4- 1)2 + (5-5)2 + (1-3)2 + (1-5)2

    hannah => (4, 4, 5, 1, 1) lachlan => (2, 1, 5, 3, 5)
  28. * K-Nearest Neighbours uses feature extraction, which means converting an

    item into a list of numbers that can be compared
  29. Strategies • Regularisation • Add weight to points • Early

    stopping • Stay clear from finer details
  30. It is intolerable to think of spending one’s whole life

    like a neuter bee, working, working, and nothing after all. Charles Darwin

More Decks by Elle Meredith

Other Decks in Programming