H2O merging of scores with original data set
<p>I'm using H2O to generate predictions on a large data set with user ID as one of the columns. However, once I score the data set the predictions data set does not contain the ID... The only thing that keeps things working is the order of the scores matches the order of the input data set, which is pretty sloppy IMO.</p>

<p>Is there a way to instruct H2O to either retain the ID column in the predictions data set or alternatively to add it post-scoring but still in H2O?</p>

<p>I'm less excited about bringing the scores to python or R along with the data set with the IDs and using cbind and the likes but please chime in if this is the only option.</p>

<p>Yes, you simply need to cbind the information from the frames that you want as your final output. Here is a full example: I'm doing a regression to predict a patient's height based on their age and risk category. (!)</p>

<pre><code>import h2o
h2o.init()

patients = {
  'age':[29, 33, 65],
  'height':[188, 157, 175.1],
  'name':["Tom", "Dick", "Harry"],
  'risk':['A', 'B', 'B']
  }

train = h2o.H2OFrame.from_python(
  patients,
  destination_frame="patients"
  )

m = h2o.estimators.H2ODeepLearningEstimator()
m.train(["age","risk"], "height", train)
p = m.predict(train)

train["name"].cbind(p["predict"])
</code></pre>

<p>As I don't have any test data, for the sake of an example I predict on the training data. The final step is to take the columns from <code>train</code> and combine with the columns from <code>p</code>. (With a categorization, you'll get additional columns, which you may or may not want to include.)</p>

<p><strong>NOTE:</strong> The cbind operation takes place in your H2O cluster, not on the client. So it works perfectly well if this is 100 million rows of data spread across multiple machines.</p>

<p>P.S. Do <code>m.train(["age","height"], "risk", train)</code> to do a categorization instead.</p>

python h2o