Skip to main content
Version: v1.3.0

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

Overview

This tutorial explores one of the options available in H2O Hydrogen Torch to deploy a built model. In particular, this tutorial explores how to deploy a built model through the H2O Hydrogen Torch (HHT) user interface (UI). This tutorial also explores downloading the generated predictions (in HHT) and how we 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.

Prerequisites

Step 1: Import dataset

For this tutorial, we are using the preprocessed Coins image regression 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 S3 file name list, select coins_image_regression.zip.
  3. Click Continue.
  4. Again, click Continue.
  5. Again, click Continue.

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

Note

As a requirement, H2O Hydrogen Torch requires the dataset for an experiment to be preprocessed to follow a certain dataset format for the problem type the experiment aims to solve. The Coins image regression dataset was preprocessed to follow a dataset format for an image regression model. To learn more, see Dataset formats.

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 use 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.
Note

After starting your experiment, H2O Hydrogen Torch takes you to the experiments table, where you can view running and completed experiments.

Step 3: Deploy built model

After a few minutes, you can utilize (observe) the completed experiment (model).

Now that our model (experiment) is complete, let's deploy our image regression model through the H2O Hydrogen Torch UI.

Note

In the experiments table, H2O Hydrogen Torch marks an experiment as completed when its status changes to finished.

  1. In the H2O Hydrogen Torch navigation menu, click Predict data.

Before using our built model to generate predictions for a test dataset, observe the settings in the Predict data card, organized in 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 run 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. In this case, the coins_image_regression.csv was utilized to create the model, and for purposes of this tutorial, it is utilized to generate predictions through the H2O Hydrogen Torch UI. This .csv file can be replaced by any other file stored (imported) in the dataset folder specified in the Dataset setting. To learn more, see Dataset formats: Image regression.

Note

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

  1. In the Experiment list, select tutorial-1b (*).
  2. In the Prediction name box, enter tutorial-1b.
  3. 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:

  1. 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.
    Note

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

  2. Click Download predictions.
    Note
    • Downloaded predictions come in a .zip file with the following naming convention: preds_tutorial-1b_*.
    • The .zip file contains the following files:
      • A test_predictions.csv file
        • The .csv file is a structured dataframe with final predictions for the provided test dataframe. In particular to our downloaded predictions, the .csv file contains:
          • All the N columns in the test dataframe
          • A column name pred_{label_column_name} that contains probabilities for the label column, label_column_name refers to the label column name found in the train (test) dataframe
      • A test_raw_predictions.pkl file
        • The .pkl file is a pickled Python dictionary with raw predictions for the provided test dataframe. In particular to our downloaded predictions, its .pkl file contains:
          • predictions
            • A 2-dimensional NumPy array that contains label predictions. The shape of the array is (n, m), where n represents the number of observations, while m represents the number of labels.
          • labels
            • A 1-dimensional NumPy array that contains label names.
          • {image_column}
            • A 1-dimensional NumPy array that contains input image names. The name of the key is {image_column}, where image_column refers to the name of the image column in the train (test) dataframe.
    • The structure of the files in the .zip file is different among all supported problem types. To learn more, see Predictions: File formats.

Step 5: View predictions

By using Python, we can view the downloaded .csv and .pkl files as follows; 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 through the H2O Hydrogen Torch (HT) user interface (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 through the H2O Hydrogen Torch (HT) user interface (UI), consider the following two tutorials to learn how to deploy a built model using an external Python scoring pipeline or an H2O MLOps pipeline:

To learn how to improve a built model, consider the following tutorial:


Feedback