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.

Facce030b679bda34eb7c64885a741fc?s=128

Eric Weinstein

November 10, 2016
Tweet

Transcript

  1. 1.

    Dōmo arigatō, Mr. Roboto: Machine Learning with Ruby # Eric

    Weinstein # RubyConf 2016 # Cincinnati, Ohio # 10 November 2016
  2. 4.

    About Me eric_weinstein = { employer: 'Hulu', github: 'ericqweinstein', twitter:

    'ericqweinstein', website: 'ericweinste.in' } 30% off with RUBYCONF30!
  3. 5.

    Agenda • What is machine learning? • What is supervised

    learning? • What’s a neural network? • Machine learning with Ruby and the MNIST dataset
  4. 7.
  5. 19.

    Our Data • Images of handwritten digits, size-normalized and centered

    • Training: 60,000 examples, test: 10,000 • http://yann.lecun.com/exdb/mnist/
  6. 21.

    How’d We Do? • Correct: 9328 / 10_000 • Incorrect:

    672 / 10_000 • Overall: 93.28% accuracy
  7. 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 }); }); }
  8. 24.

    Front End render() { return( <div> <EditableCanvas canvas={this.state.canvas} ctx={this.state.ctx} ref='editableCanvas'

    /> <Prediction number={this.state.prediction} /> <div> <Button onClick={this.submit} value='Submit' /> <Button onClick={this.clear} value='Clear' /> </div> </div> ); }
  9. 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)
  10. 27.

    Summary • Machine learning is generalization • Supervised learning is

    labeled data -> unlabeled data • Neural networks are awesome • You can do all this with Ruby!
  11. 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