Skip to main content
Version: v1.4.0

Tutorial 1B: Model deployment in the H2O Hydrogen Torch UI

Overview

This tutorial explores one of the options available to deploy a built model. In particular, this tutorial explores how to deploy a built model in the H2O Hydrogen Torch UI. This tutorial also explores downloading the generated predictions and how you can view the downloaded predictions using Python. At a high level, we first create a model that you will later deploy to score on new data.

Objectives

  1. Learn how to deploy a built model in the H2O Hydrogen Torch UI, including exploring the available settings to score new data on the UI and downloading the generated predictions.
  2. Understand how to view the downloaded predictions using Python, specifically by utilizing Pandas and Pickle libraries to read and display the prediction data.

Prerequisites

Step 1: Import dataset

For this tutorial, let's utilize the demo out-of-the-box preprocessed coins_image_regression.zip dataset. The dataset contains a collection of 6,028 images with one or more coins. Each image has been labeled to indicate the sum of its coins. The currency of the coins is the Brazilian Real (R$). Let's import the dataset:

  1. In the H2O Hydrogen Torch navigation menu, click Import dataset.
  2. In the File name list, select coins_image_regression.zip.
  3. Click Continue.
  4. Click Continue.
  5. Click Continue.

Image of multiple sized and colored coins called 105_1479344562.jpg

Step 2: Build model

Let's quickly build an image regression model capable of predicting the sum of Brazilian Real (R$) coins in images. After creating the model, we will utilize the H2O Hydrogen Torch UI to generate predictions (deploy the model).

  1. In the H2O Hydrogen Torch navigation menu, click Create experiment.
  2. In the Dataset list, select coins_image_regression.
  3. In the Experiment name box, enter tutorial-1b.
  4. Click Run experiment.

Step 3: Deploy built model

After a few minutes, you can utilize the completed experiment (model). Let's deploy the image regression model in the H2O Hydrogen Torch UI.

  1. In the H2O Hydrogen Torch navigation menu, click Predict data.
  2. In the Experiment list, select tutorial-1b....
  3. In the Prediction name box, enter tutorial-1b.

Before using our built model to generate predictions for a test dataset, observe the settings in the Predict data card, organized into the following sections: General, Dataset, Prediction, and Environment. These settings control the dataset to use for the prediction, aspects of the prediction, and the environment H2O Hydrogen Torch utilizes to generate predictions.

For this tutorial, H2O Hydrogen Torch has autoselected a value for the settings in the Predict data card. In particular, H2O Hydrogen Torch has selected coins_image_regression.csv as the value for the following setting: Test dataframe.

For purposes of this tutorial, we will not change the selected test dataframe. In other words, H2O Hydrogen Torch will generate predictions for the coins_image_regression.csv dataset. The dataset, which is utilized as a test dataset, already contains a label column. Do not worry; H2O Hydrogen Torch will not utilize this column when generating predictions for the test dataset. If you were to utilize your own test dataset, note that the test dataset (CSV) needs to follow the same format as a train CSV file but does not require a label column(s). To learn more, see Dataset formats: Image regression.

Note

To learn more about the prediction settings, see Prediction settings.

  1. Click Run predictions.
    Note

    After running your predictions, H2O Hydrogen Torch takes you to the Predictions table, where you can view running and completed predictions. As the predictions are completed, refresh the Predictions table. To refresh the table: Click Refresh.

Step 4: Download predictions

After a few minutes, H2O Hydrogen Torch completes the predictions. Let's download the predictions.

  1. In the Predictions table, click tutorial-1b....predict.
    Note

    In the Predictions table, H2O Hydrogen Torch marks a prediction as completed when its status changes to Finished.

  2. Click Download predictions.
    Note
    • When you download predictions in H2O Hydrogen Torch, which comes in a zip file, the format and content of the file first depends on the problem type of the predictions, and then it depends on how you generate them. On the point of "how you generate them," there are two scenarios. To learn more, see Predictions download formats.
    • The downloaded zip file contains the following files: test_predictions.csv and test_raw_predictions.pkl. To learn about the structure of files, see Predictions download formats: Image regression.

Step 5: View predictions

By using Python, we can view the downloaded CSV and Pickle files as follows (which come inside the downloaded zip file); in particular, let's observe the first prediction stored in both files:

import pickle
import pandas as pd

df = pd.read_csv('test_predictions.csv')

with open('test_raw_predictions.pkl', 'rb') as f:
out = pickle.load(f)

print(df.head(1))
           image_path  label  fold  pred_label
0 105_1479344562.jpg 105 1 104.038216
print(out.keys())
dict_keys(['predictions', 'labels', 'image_path'])
print(f'Prediction: {out["predictions"][0]}')
print(f'image_path: {out["image_path"][0]}')
Prediction: [104.038216]
image_path: 105_1479344562.jpg

Image of multiple sized and colored coins called 105_1479344562.jpg

105_1479344562.jpg

Summary

In this tutorial, we learned how to deploy a built model in the H2O Hydrogen Torch UI. Mainly we explored the collection of settings available to you to score new data on the UI. Right after, we downloaded the generated predictions to view them using Python.

Next

Now that you know how to deploy a built model in the H2O Hydrogen Torch UI, consider the following tutorials to learn about the other options to deploy a built model:


Feedback