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

Domo Arigato, Mr. Roboto: Machine Learning with...

Eric Weinstein
November 10, 2016

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
  2. About Me eric_weinstein = { employer: 'Hulu', github: 'ericqweinstein', twitter:

    'ericqweinstein', website: 'ericweinste.in' } 30% off with RUBYCONF30!
  3. Agenda • What is machine learning? • What is supervised

    learning? • What’s a neural network? • Machine learning with Ruby and the MNIST dataset
  4. Our Data • Images of handwritten digits, size-normalized and centered

    • Training: 60,000 examples, test: 10,000 • http://yann.lecun.com/exdb/mnist/
  5. How’d We Do? • Correct: 9328 / 10_000 • Incorrect:

    672 / 10_000 • Overall: 93.28% accuracy
  6. 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 }); }); }
  7. 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> ); }
  8. 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)
  9. Summary • Machine learning is generalization • Supervised learning is

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