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

Domo Arigato, Mr. Roboto: Machine Learning with Ruby

Domo Arigato, Mr. Roboto: Machine Learning with Ruby

Slides for my RubyConf 2016 talk on machine learning.

Eric Weinstein

November 10, 2016
Tweet

More Decks by Eric Weinstein

Other Decks in Technology

Transcript

  1. Dōmo arigatō, Mr. Roboto:
    Machine Learning with Ruby
    # Eric Weinstein
    # RubyConf 2016
    # Cincinnati, Ohio
    # 10 November 2016

    View Slide

  2. for Joshua

    View Slide

  3. Part 0: Hello!

    View Slide

  4. About Me
    eric_weinstein = {
    employer: 'Hulu',
    github: 'ericqweinstein',
    twitter: 'ericqweinstein',
    website: 'ericweinste.in'
    }
    30% off with RUBYCONF30!

    View Slide

  5. Agenda
    • What is machine learning?
    • What is supervised learning?
    • What’s a neural network?
    • Machine learning with Ruby and the MNIST
    dataset

    View Slide

  6. Part 1: Machine Learning

    View Slide

  7. View Slide

  8. What’s machine learning?

    View Slide

  9. In a word:

    View Slide

  10. Generalization

    View Slide

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

    View Slide

  12. Features && Labels
    • Raw pixel features (vectors of intensities)
    • Digit (0..9)

    View Slide

  13. Features && Labels
    • Raw pixel features (vectors of intensities)
    • Digit (0..9)

    View Slide

  14. Image credit: https://www.tensorflow.org/versions/r0.9/tutorials/mnist/
    beginners/index.html

    View Slide

  15. What’s a neural network?

    View Slide

  16. Image credit: https://github.com/cdipaolo/goml/tree/master/perceptron

    View Slide

  17. Image credit: https://en.wikipedia.org/wiki/Artificial_neural_network

    View Slide

  18. Part 2: The MNIST Dataset

    View Slide

  19. Our Data
    • Images of handwritten digits, size-normalized
    and centered
    • Training: 60,000 examples, test: 10,000
    • http://yann.lecun.com/exdb/mnist/

    View Slide

  20. Image credit: https://www.researchgate.net/

    View Slide

  21. How’d We Do?
    • Correct: 9328 / 10_000
    • Incorrect: 672 / 10_000
    • Overall: 93.28% accuracy

    View Slide

  22. Developing the App

    View Slide

  23. Front End
    submit() {
    fetch('/submit', {
    method: 'POST',
    body: this.state.canvas.toDataURL('image/png')
    }).then(response => {
    return response.json();
    }).then(j => {
    this.setState({
    prediction: j.prediction
    });
    });
    }

    View Slide

  24. Front End
    render() {
    return(








    );
    }

    View Slide

  25. Back End
    train = RubyFann::TrainData.new(inputs:
    features, desired_outputs: labels)
    fann = RubyFann::Standard.new(num_inputs: 576,
    hidden_neurons: [300], num_outputs: 10)
    fann.train_on_data(train, 1000, 10, 0.01)

    View Slide

  26. STOP
    #demotime

    View Slide

  27. Summary
    • Machine learning is generalization
    • Supervised learning is labeled data ->
    unlabeled data
    • Neural networks are awesome
    • You can do all this with Ruby!

    View Slide

  28. Takeaways (TL;DPA)
    • We can do machine learning with Ruby
    • Contribute to tools like Ruby FANN
    (github.com/tangledpath/ruby-fann) and sciruby
    (http://sciruby.com/)
    • Check it out: http://ruby-mnist.herokuapp.com/
    • PRs welcome! github.com/ericqweinstein/ruby-
    mnist

    View Slide

  29. Thank You!

    View Slide

  30. Questions?
    eric_weinstein = {
    employer: 'Hulu',
    github: 'ericqweinstein',
    twitter: 'ericqweinstein',
    website: 'ericweinste.in'
    }
    30% off with RUBYCONF30!

    View Slide