<h2><img data-orig-file="https://longhowlam.files.wordpress.com/2017/08/forest.jpg?w=456" data-orig-size="980,551" data-medium-file="https://longhowlam.files.wordpress.com/2017/08/forest.jpg?w=456?w=300" data-attachment-id="2532" data-image-meta="{" data-image-description="" src="https://longhowlam.files.wordpress.com/2017/08/forest.jpg?w=456" data-permalink="https://longhowlam.wordpress.com/2017/08/30/the-one-function-call-you-need-to-know-as-a-data-scientist-h2o-automl/forest/" data-large-file="https://longhowlam.files.wordpress.com/2017/08/forest.jpg?w=456?w=440" alt="forest" data-image-title="forest" sizes="(max-width: 440px) 100vw, 440px" data-comments-opened="1" class="wp-image-2532" data-recalc-dims="1"></h2>
<h2>Introduction</h2>
<p>Two things that recently came to my attention were <a rel="nofollow" href="https://blog.h2o.ai/2017/06/automatic-machine-learning/" target="_blank"><strong>AutoML</strong> </a>(Automatic Machine Learning) by h2o.ai and the<strong> <a rel="nofollow" href="https://github.com/zalandoresearch/fashion-mnist" target="_blank">fashion MNIST</a></strong> by Zalando Research. So as a test, I ran AutoML on the fashion mnist data set.</p>
<h2>H2o AutoML</h2>
<p>As you all know a large part of the work in predictive modeling is in preparing the data. But once you have done that, ideally you don’t want to spend too much work in trying many different machine learning models.  That’s were AutoML from h2o.ai comes in. With <strong>one function call</strong> you automate the process of training a large, diverse, selection of candidate models.</p>
<p>AutoML trains and cross-validates a Random Forest, an Extremely-Randomized Forest, GLM’s, Gradient Boosting Machines (GBMs) and Neural Nets. And then as “bonus” it trains a <a rel="nofollow" href="https://h2o-release.s3.amazonaws.com/h2o/rel-ueno/2/docs-website/h2o-docs/data-science/stacked-ensembles.html" target="_blank">Stacked Ensemble</a> using all of the models. The function to use in the h2o R interface is: <span>h2o.automl</span>. (There is also a python interface)</p>
<pre>
FashionMNIST_Benchmark = h2o.automl(
  x = 1:784,
  y = 785,
  training_frame = fashionmnist_train,
  validation_frame = fashionmninst_test
)
</pre>
<p>So the first 784 columns in the data set are used as inputs and column 785 is the column with labels. There are more input arguments that you can use. For example, maximum running time or maximum number of models to use, a stopping metric.</p>
<p>It can take some time to run all these models, so I have spun up a so-called <em>high CPU droplet</em> on Digital Ocean: 32 dedicated cores ($0.92 /h).</p>
<div data-shortcode="caption" class="wp-caption"><img data-orig-file="https://longhowlam.files.wordpress.com/2017/08/h2o_perf.png?w=262&amp;h=273&amp;fit=262%2C273&amp;resize=262%2C273" data-orig-size="450,468" data-medium-file="https://longhowlam.files.wordpress.com/2017/08/h2o_perf.png?w=262&amp;h=273&amp;fit=262%2C273&amp;resize=262%2C273?w=288" data-attachment-id="2443" data-image-meta="{" data-image-description="" src="https://longhowlam.files.wordpress.com/2017/08/h2o_perf.png?w=262&h=273&fit=262%2C273&resize=262%2C273" data-permalink="https://longhowlam.wordpress.com/2017/08/30/the-one-function-call-you-need-to-know-as-a-data-scientist-h2o-automl/h2o_perf/" data-large-file="https://longhowlam.files.wordpress.com/2017/08/h2o_perf.png?w=262&amp;h=273&amp;fit=262%2C273&amp;resize=262%2C273?w=440" alt="h2o_perf" data-image-title="h2o_perf" sizes="(max-width: 262px) 100vw, 262px" data-comments-opened="1" class="wp-image-2443" data-recalc-dims="1">
<p class="wp-caption-text">h2o utilizing all 32 cores to create models</p>
</div>
<p>The output in R is an object containing the models and a ‘<strong>leaderboard</strong>‘ ranking the different models. I have the following accuracies on the fashion mnist test set.</p>
<ol>
<li>Gradient Boosting (0.90)</li>
<li>Deep learning (0.89)</li>
<li>Random forests (0.89)</li>
<li>Extremely randomized forests (0.88)</li>
<li>GLM (0.86)</li>
</ol>
<p>There is no ensemble model, because it’s not supported yet for multi label classifiers. The deeplearning in h2o are fully connected hidden layers, for this specific Zalando images data set, you’re better of pursuing more fancy convolutional neural networks. As a comparison I just ran a <a rel="nofollow" href="https://keras.rstudio.com/articles/examples/mnist_cnn.html" target="_blank">simple 2 layer CNN</a> with keras, resulting in an <strong>test accuracy of 0.92</strong>. It outperforms all the models here!</p>
<h2>Conclusion</h2>
<p>If you have prepared your modeling data set, the first thing you can always do now is to run <span>h2o.automl</span>.</p>
<p>Cheers, Longhow.</p>
<p> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/longhowlam.wordpress.com/2326/" target="_blank"><img border="0" alt="" src="http://feeds.wordpress.com/1.0/comments/longhowlam.wordpress.com/2326/"></a> <img border="0" alt="" src="https://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" data-recalc-dims="1"></p>
	<img alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/bnCw-pr96bg" height="1">