Build Hello World in 5 minutes

In this chapter, you will build a "hello world" equivalent in machine learning on RocketML. For the HelloWorld example, we have picked a multi-class text classification problem using scikit-learn.

You will do the following in this example,

Pre-requisites

  1. RocketML account

    1. If you are subscribed to RocketML Managed Deployment, please ask your admin for login instructions.

    2. If you are using RocketML Community Edition, please email contact@rocketml.net for an account. Once you get a login/password, you will be able to start with Step 1 below.

  2. Basic experience with

    1. Python programming

    2. Navigating Jupyter Lab

    3. Data-science libraries like Pandas, Numpy and Scikit-learn

Step 1: Login to Community edition of RocketML

Login to RocketML using the email address linked to your deployment described in Pre-requisites.

Step 2: Create a Project VM

Once in the Home page, click on “Projects” on the left sidebar and then on “Create Project”.

Create Project

Enter a project name as "Hello World", add (optional) description, and click on “Create”. The project will go to “Creating” state and then transition to “On” state.

Enter Project Name and Description

It usually takes about 3-4 minutes for Project VM to boot up. You are now being charged for the compute per second basis.

Project in "creating" state
Project in "ON" state

Once Project VM is started, click on the project card “HelloWorld”. You will on the "project details" page. In this page, you can see all the developer environments ready for use. Clicking on the floating power button on the right edge will open a floating window that has details on the compute resources used by this project. For example, the “HelloWorld” project is using 2 CPUs and 4GB of memory. In addition to allocating compute resources, RocketML also creates a tracking server and database for experiment, code, and model management.

Click on “JupyterLab” and open a terminal. At this time you will be in the “Build” tab of the project.

Project Details Page
Build page with Terminal window

Step 3: Pull Code from public Git

Clone the rml-notebooks repository from github to /home/ubuntu/efs.

Connect and pull code from Public Git

Step 4: Run Code in Notebook

This repository contains examples on how to get started with RocketML. Open the notebook named “nlp_classification_pipeline.ipynb”, which contains a solution to solve a multi-class text classification problem using scikit-learn. It also contains mlflow code snippets to keep track of machine learning parameters, metrics, and artifacts related to the model. In this example, the experiment name in the notebook is nlp_demo.

Run all the cells from the menu Jupyter Lab → Run → Run All Cells

Run All Cells of the Notebook!

Step 5: Convert a run into a Model

A new experiment named nlp_demo will appear in the Experiments tab. A single experiment is a collection of runs with its own set of parameters, metrics, and artifacts.

Experiments Page

By clicking on nlp_demo you will see a run with its own parameters and metrics. Clicking on the experiment’s date will open a sliding window with a vertical bar for “artifacts” and a “Convert to Model” button. Artifacts show all model related files - conda environment file (conda.yaml), pickle file, and ML model file - stored in object storage.

Now click on “Convert to Model”, provide a name for the model to be deployed on a container, and click on “Deploy Model”. This model will appear on a list in the “Models” tab, initially with status “Creating”.

Give name

Your model will appear on the Models Tab

Step 5: Test the model REST API Endpoint

Model deployment will be complete once its state transitions to “On”. When this happens, copy the REST API endpoint by clicking on the “copy url” button next to the URL at the “END POINT” column.

Note: URL in the image will not match the URL you will see in your UI.

Go to the Build tab and open “inference_notebook.ipynb” from the rml-notebooks directory. Replace the URL in the notebook with the URL from the model tab and run all cells. We are using the Python “requests” library to perform a POST operation on the deployed model. We are predicting classes of two texts [“hello world”, “hello”]. The response from the model shows that the classes are [1,1] for these two inputs.

Step 6: Turn off the project and model compute

Once your tests on a given model are complete, you can turn off the project compute resources by clicking on the Off button at the top bar or from the sliding window on the right by clicking on the floating power button. Go to the Model tab, click on the project name “nlpmodel1” and you will see model details. Click on the Stop button to turn off the container. Clicking on the All Projects icon will take you to the projects list page and you can turn off the project from the list page.

In the project details page Hello World tab you will see both project compute and model compute in “Stopping” state.

Project compute and model compute are successfully turned off.

Last updated

Was this helpful?