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

Machine Learning with Elixir and Phoenix

Machine Learning with Elixir and Phoenix

Slides for my ElixirConf EU 2017 talk on machine learning.

Eric Weinstein

May 04, 2017
Tweet

More Decks by Eric Weinstein

Other Decks in Technology

Transcript

  1. def talk(struct) do
    struct
    |> title("Machine Learning with Elixir and Phoenix")
    |> speaker("Eric Weinstein")
    |> conf("ElixirConf EU")
    |> city("Barcelona, España")
    |> date("4 May 2017")
    end

    View Slide

  2. for Joshua
    |##...........................................| 4%

    View Slide

  3. Part 0: Hello!
    |###..........................................| 7%

    View Slide

  4. May the 4th Be With You
    |#####........................................| 11%

    View Slide

  5. About Me
    eric_weinstein =
    %{employer: "Hulu",
    github: "ericqweinstein",
    twitter: "ericqweinstein",
    website: "ericweinste.in"}
    30% off with EURORUBY30!
    |#######......................................| 16%

    View Slide

  6. Agenda
    • Machine learning and neural networks
    • A wee bit o’ finance
    • The Phoenix application
    |#########....................................| 20%

    View Slide

  7. Part 1: Machine Learning
    |###########..................................| 24%

    View Slide

  8. What is it?
    |############.................................| 27%

    View Slide

  9. In a word:
    |#############................................| 29%

    View Slide

  10. Generalization
    |###############..............................| 33%

    View Slide

  11. What’s Supervised Learning?
    Classification or regression, generalizing from
    labeled data to unlabeled data
    |#################............................| 37%

    View Slide

  12. Our Data
    • Data from the S&P 500 from 2015 and 2016
    • 3 features, 252 instances
    • https://finance.yahoo.com/quote/SPY/history?
    p=SPY
    |##################...........................| 40%

    View Slide

  13. Features && Labels
    • Bollinger Bands®
    • Simple moving average (SMA)
    • Relative strength index (RSI)
    • 20-day return
    |####################.........................| 44%

    View Slide

  14. Features && Labels
    • Bollinger Bands®
    • Simple moving average (SMA)
    • Relative strength index (RSI)
    • 20-day return
    |#####################........................| 47%

    View Slide

  15. Neural Networks
    • Computational model based on biological brains
    • Can model any continuous function (with at
    least two layers), relatively fast to query,
    and can model interaction among inputs
    • However, they are also finicky (often requiring
    lots of tuning and are prone to overfitting),
    expensive to train, and black boxes
    |#######################......................| 50%

    View Slide

  16. |########################.....................| 53%
    Visualization
    Image credit: https://en.wikipedia.org/wiki/Artificial_neural_network

    View Slide

  17. Training Rules
    • Buy when predicted 20-day return is positive
    • Sell when predicted 20-day return is negative
    • Do nothing when predicted 20-day return is
    zero (or very close to it)
    |##########################...................| 57%

    View Slide

  18. Part 2: Finan¢e
    |###########################..................| 60%

    View Slide

  19. Caveat Emptor
    • I am not a financial professional
    • No guarantees or warrantees, express or
    implied, about the completeness or correctness
    of my experiments
    • If you repeat them, you can (and probably
    will) lose money at some point
    |#############################................| 64%

    View Slide

  20. Some Jargon
    S&P 500: American index comprising 500 large companies
    Adjusted close: closing price adjusted for historical
    events (such as stock splits)
    Stock split: Event where a company splits each
    existing share into multiple shares (e.g. 2:1)
    Lookahead bias: Bias introduced by using data that
    wouldn’t have yet been available in a simulation
    |##############################...............| 67%

    View Slide

  21. Our Indicators
    Simple moving average: Arithmetic moving average
    over a specific window
    Bollinger Bands®: N standard deviations above
    and below the SMA (oftentimes N = 2)
    RSI: Momentum indicator that measures speed and
    change of price movements
    |################################.............| 71%

    View Slide

  22. Part 3:
    |#################################............| 74%

    View Slide

  23. |###################################..........| 77%

    View Slide

  24. |####################################.........| 80%

    View Slide

  25. |#####################################........| 83%

    View Slide

  26. |#######################################......| 87%

    View Slide

  27. How’d We Do?
    • S&P 500 2015 return: -0.73%
    • Our return (training): 2.9%
    • S&P 500 2016 return: 9.84%
    • Our return (testing): 16.0%
    |########################################.....| 90%

    View Slide

  28. Summary
    • Machine learning is fun and practical
    • It’s super doable with Elixir + BEAM
    • Library support is what we really need
    |##########################################...| 93%

    View Slide

  29. Takeaways (TL;DPA)
    • Be the change you want to see in the
    community!
    • https://github.com/ericqweinstein/elixirconfeu
    • http://quantsoftware.gatech.edu
    |############################################.| 98%

    View Slide

  30. IO.puts("Thanks!")
    |#############################################| 100%

    View Slide