Run Your First Model

Learn to use Modzy to run an ML model with this introductory tutorial

In this tutorial you will learn how to search for a model, take it for a test drive, run your first inference using Modzy's API, and view the results. All of this should take less than half-an-hour, so grab a fresh cup of coffee and follow-along :coffee:

:lock: Create your account

The first thing you'll need to do is get a Modzy account. If your company already has a license to Modzy, just ask your admin to send you an invitation.

:department-store: Find a model

Once you log into Modzy, click on the Models tab in the menu at the top of the page. This will take you to the Model Library.

Begin typing “Sentiment Analysis” into the search box and then click on the top result (it should show the number "ed542963de" beneath the title).

31043104

Searching for a sentiment analysis model in Modzy's model library

:car: Take your model for a test drive

After clicking on "Sentiment Analysis" in the previous step, you'll find yourself on the Overview page for this model. To try using this model yourself, click on the Test Drive tab on the left side of the screen.

In the 'Input' section, you can type in any English text that you'd like, such as the first line from your favorite novel or a funny tweet.

Once you've added some text, click the 'Start Job' button.

After a few seconds, this Sentiment Analysis model's results should appear on the right side of the screen under the 'Output' section. You should see a JSON object with a bunch of different numbers. These numbers describe the sentiment of the text you sent as being positive, neutral, or negative (usually a combination of all three).

31043104

Sending text to a sentiment analysis model using Modzy's "Test Drive" feature

📘

For a quick interpretation of your result, compare the "class": "positive" and "class": "negative" scores. If the positive score is larger, the text is seen as more positive, if the negative score is larger, then the text is seen as more negative.

:crystal-ball: View model results

Once you’ve completed your first Sentiment Analysis inference using the Test Drive feature, you can look at the raw results on the Jobs page. Modzy uses to word Job to describe when one or more data inputs are passed through a model. Click on the Operations tab in the menu at the top of the page and then click on Jobs in the menu that appears right beneath it.

31043104

View of all previous model predictions, also known as "Jobs"

You can find the job you just submitted at the top of the jobs list. Click on the Job ID of the inference you just submitted to see more information. The Job Details page provides access that job’s predictions, inference times, and other metadata.

31043104

Viewing the results for a single submission to a sentiment analysis model

:key: Download your API key

Next, we'll use Modzy's API to send data to the same sentiment analysis model. Before you can start using it you will need an API Key. You can find and manage all of your API keys in your profile. Click on your name in the menu at the top left of the screen and then click API Keys.

31043104

Link to API Keys

You should see an API key listed for each of the teams to which you belong. If you belong to multiple teams, then you’ll see multiple keys. Find the API key for the applicable team and click on “Get Key” to download your API key.

31043104

List of API Keys

Next, open the text file downloaded from Modzy to view the full-length key. Modzy’s API keys have a 2-part format, a public portion (the characters to the left of the period) and a private portion (the characters to the right of the period). To work with Modzy’s APIs, you need the full string (including the period in the middle) for authentication. Store this file somewhere safe as you can only download it once.

745745

An example of a Modzy API Key

:computer: Run a prediction from your terminal

Now that you have an API Key, you can directly interact with Modzy’s API. An easy way to do so is to copy the cURL example below, which will send your input to the Sentiment Analysis model we tested out earlier. You will just need to make the following substitution:

  • Replace ***<MODZY_URL> in the sample code below with the URL of your instance of Modzy
  • Replace API_KEY in the sample code below with the API key string you just downloaded

An easy way to do this is to paste the example below into a text editor, make your replacements, then copy the whole thing again before pasting it into your terminal or command prompt.

curl <MODZY_URL>/api/jobs -X POST \
 -H 'Content-Type: application/json' \
 -H 'Authorization: ApiKey API_KEY' \
 -d '{
      "model": {
        "identifier": "ed542963de",
        "version": "1.0.1"
      },
      "input": {
        "type": "text",
        "sources": {
          "first-phone-call": {
            "input.txt": "Mr Watson, come here. I want to see you."
          }
        }
      }
    }'
curl <MODZY_URL>/api/jobs -X POST ^
 -H "Content-Type: application/json" ^
 -H "Authorization: ApiKey API_KEY" ^
 -d "{\"model\":{\"identifier\": \"ed542963de\",\"version\":\"1.0.1\"},\"input\":{\"type\":\"text\",\"sources\":{\"first-phone-call\":{\"input.txt\":\"Mr Watson, come here. I want to see you.\"}}}}"

Once you’ve made those substitutions, open a terminal (MacOS, Linux) or command prompt (Windows), paste in this cURL command, and hit enter. When Modzy receives your request, you will receive a confirmation message with details about your job submission that includes a jobIdentifier number, the accessKey (the public portion of your API Key) used for the request, and much more. Modzy runs inferences asynchronously, so you can either request your results via an API request (with the /api/results/ endpoint), or you can view them again on the Jobs page.

{
   "model":{
      "identifier":"ed542963de",
      "version":"1.0.1",
      "name":"Sentiment Analysis"
   },
   "status":"SUBMITTED",
   "totalInputs":1,
   "jobIdentifier":"b532ca06-7732-4ba5-9138-6d99aa8e67e7",
   "accessKey":"syXs1jd1hQY1FdMTnCjM",
   "explain":false,
   "jobType":"batch",
   "accountIdentifier":"modzy-account",
   "team":{
      "identifier":"559b3h00-3f49-442f-ac23-94314daj8acc"
   },
   "user":{
      "identifier":"7344h933-0ab4-4e90-a3c0-20b8e4e1fcbc",
      "externalIdentifier":"[email protected]",
      "firstName":"Thomas",
      "lastName":"Edison",
      "email":"[email protected]",
      "status":"active"
   },
   "jobInputs":{
      "identifier":[
         "first-phone-call"
      ]
   },
   "submittedAt":"2022-06-08T16:41:26.680+00:00",
   "hoursDeleteInput":24,
   "imageClassificationModel":false
}

:loop: Get results via API

Lastly, you can retrieve model results from Modzy's API too. Everything in Modzy accessible via API! An easy way to do so is to copy the cURL example below after you make the following substitutions:

  • Replace ***<MODZY_URL> in the sample code below with the URL of your instance of Modzy
  • Replace {jobIdentifier} with the jobIdentifier you received in the previous step
  • Replace API_KEY in the sample code below with the API key string you just downloaded
curl <MODZY_URL>/api/results/{jobIdentifier} -X GET \
 -H 'Content-Type: application/json' \
 -H 'Authorization: ApiKey API_KEY'
curl <MODZY_URL>/api/results/{jobIdentifier} -X GET ^
 -H "Content-Type: application/json" ^
 -H "Authorization: ApiKey API_KEY"

After running this script in your terminal, Modzy will return your results in a JSON object that should look similar to the following example.

{
   "jobIdentifier":"b1e4477b-2361-421b-9095-a9b4edde447b",
   "accountIdentifier":"modzy-account",
   "team":{
      "identifier":"559b3f00-3f39-442f-ac23-94314daa8acc"
   },
   "total":1,
   "completed":1,
   "failed":0,
   "finished":true,
   "submittedByKey":"syXs1jd1hQY1FdMTnCjM",
   "explained":false,
   "submittedAt":"2022-04-28T01:36:32.346+00:00",
   "initialQueueTime":662,
   "totalQueueTime":662,
   "averageModelLatency":94.0,
   "totalModelLatency":94.0,
   "elapsedTime":1654,
   "startingResultSummarizing":"2022-04-28T01:36:33.421+00:00",
   "resultSummarizing":579,
   "inputSize":174,
   "results":{
      "first-phone-call":{
         "status":"SUCCESSFUL",
         "engine":"model-batch-ed542963de-1-0-1-5694d8f46b-8jjrz",
         "inputFetching":89,
         "outputUploading":null,
         "modelLatency":94.0,
         "queueTime":662,
         "startTime":"2022-04-28T01:36:33.003+0000",
         "updateTime":"2022-04-28T01:36:33.274+0000",
         "endTime":"2022-04-28T01:36:33.274+0000",
         "results.json":{
            "data":{
               "result":{
                  "classPredictions":[
                     {
                        "class":"neutral",
                        "score":0.86
                     },
                     {
                        "class":"positive",
                        "score":0.14
                     },
                     {
                        "class":"negative",
                        "score":0.0
                     }
                  ]
               },
               "explanation":null,
               "drift":null
            }
         },
         "voting":{
            "up":0,
            "down":0
         }
      }
   }
}

You've now successfully built a script that can analyze the sentiment of any text!

If you're a developer you might want to take this model and use it to build your own custom web app. Here's another tutorial that does just that: Sentiment Analysis App Tutorial

If you're a data scientist, you might be interested in learning how Deploying Models works or how to use model drift Model Drift.

We can't wait to see what you build with Modzy! :wrench:


What’s Next

Once you've gotten a feel for Modzy, try building your first AI-powered app in Python, or packaging and deploying your first model

Did this page help you?