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

In the Name of Whiskey

In the Name of Whiskey

Using Machine Learning and TensorFlow to make sense of scotches. Presented at Ruby on Ales 2016.

juliaferraioli

April 05, 2016
Tweet

More Decks by juliaferraioli

Other Decks in Technology

Transcript

  1. 1
    @juliaferraioli
    In the Name of Whiskey
    Julia Ferraioli
    Software Engineer
    @juliaferraioli

    View full-size slide

  2. 2
    @juliaferraioli
    @juliaferraioli
    Engineer @ Google
    I’ve done some stuff
    in another life…

    View full-size slide

  3. 3
    no PhD ⇒
    no more machine learning for me

    View full-size slide

  4. 4
    wait...
    what build rule checks for a PhD?

    View full-size slide

  5. 5
    → ⚙ → ❓
    data algorithm answer

    View full-size slide

  6. 6
    E_TOO_FEW_HUGS

    View full-size slide

  7. 7
    can I hug that?

    View full-size slide

  8. 8
    @juliaferraioli
    Can I hug that?

    View full-size slide

  9. 9
    @juliaferraioli
    Can I hug that?

    View full-size slide

  10. 10
    but what about the whiskey?

    View full-size slide

  11. 11
    ● A deep, abiding love for whiskey
    ● Some manageable, objective
    data
    ● Enthusiasm for math…
    ● ...or making computers do math
    What do we have?

    View full-size slide

  12. 12
    let’s talk about data

    View full-size slide

  13. 13
    @juliaferraioli
    (x,y)
    Feature vectors

    View full-size slide

  14. 14
    @juliaferraioli
    (x,y,z)
    Feature vectors

    View full-size slide

  15. 15
    @juliaferraioli
    (x,y,z,?,?,?,?,...)
    Feature vectors

    View full-size slide

  16. 17
    @juliaferraioli
    Distillery → Balvenie
    Body → 3
    Notes → Honey:3, Floral:2, ...
    Region → Speyside
    Lat / Lon → Lat:57.4527074, Lon:-3.1237258
    Data example

    View full-size slide

  17. 18
    @juliaferraioli
    [Name, Region, Body, Notes
    0
    ,...,Notes
    n
    , Lat, Lng]
    Our potential feature vector

    View full-size slide

  18. 19
    @juliaferraioli
    [5,3,2,1,0,0,3,2,1,0,2,2,2,57.4527074,-3.1237258]
    Our potential feature vector

    View full-size slide

  19. 20
    Operates over tensors: n-dimensional arrays
    Using a flow graph: data flow computation framework
    A quick look at TensorFlow
    ● Intuitive construction
    ● Fast execution
    ● Train on CPUs, GPUs
    ● Run wherever you like

    View full-size slide

  20. 21
    @juliaferraioli
    import tensorflow as tf
    sess = tf.InteractiveSession() # don’t mess with passing around a session
    whiskey_is_fun = tf.constant([6.2, 12.0, 5.9], shape = [1, 3])
    beer_is_ok_too = tf.constant([9.3, 1.7, 8.8], shape = [3, 1])
    matrices_omg = tf.matmul(whiskey_is_fun, beer_is_ok_too)
    print(matrices_omg.eval()) # => [[ 129.97999573]]
    sess.close() # let’s be responsible about this
    What does TensorFlow code look like?

    View full-size slide

  21. 23
    k-means clustering

    View full-size slide

  22. 24
    @juliaferraioli
    k = # of clusters

    View full-size slide

  23. 25
    @juliaferraioli
    pick k random n-dimensional cluster centers
    while not converged and num_steps < max_steps:
    assign points to nearest cluster center
    update cluster centers to be the mean of the points assigned to it
    return cluster centers, memberships
    The algorithm

    View full-size slide

  24. to the container!

    View full-size slide

  25. 28
    feed forward neural networks [with hidden layer(s)]

    View full-size slide

  26. 29
    @juliaferraioli
    ["this", "movie", "was", "great"]
    [" "]
    Input →
    Output →
    ????? →

    View full-size slide

  27. 30
    @juliaferraioli
    ["this", "movie", "was", "great"]
    ["POS"]
    Input →
    Hidden →
    Output →

    View full-size slide

  28. 31
    @juliaferraioli
    initialize hidden, output layers (weights and biases)
    define the training step (optimization)
    while num_steps > limit:
    grab next set of training data and labels
    perform training step
    evaluate on test data
    The algorithm (simplified)

    View full-size slide

  29. to the container!

    View full-size slide

  30. I’ve been pronouncing all of
    my scotch incorrectly

    View full-size slide

  31. data collection is the hard part

    View full-size slide

  32. common sense is not my strong suit

    View full-size slide

  33. thinking in n-dimensions makes my
    brain hurt

    View full-size slide

  34. NEED MOAR WHISKEY!

    View full-size slide

  35. NEED MOAR DATA!

    View full-size slide

  36. 41
    @juliaferraioli
    Resources
    ● TensorFlow: http://bit.ly/tensorflow-oss
    ● k-means Clustering Single Malts: http://bit.ly/k-means-scotch
    ● k-means in TensorFlow: http://bit.ly/k-means-tensorflow
    ● Feed forward neural networks in TensorFlow: http://bit.ly/ff-nn
    ● Learning TensorFlow: http://bit.ly/learn-tensorflow
    ● Gentle Introduction to ML: http://bit.ly/gentle-intro-ml

    View full-size slide

  37. Octopus: image by Feans
    thanks!
    Toolbox: image by Tanemori

    View full-size slide