Testing PMML Execution with Openscoring REST Service on Amazon EC2

Last time I wrote about how to install Openscoring web service to your own computer. This has several major dependencies like installing Maven, GitHub Desktop and possibly messing with Java versions and environment variables. While not too complex, its still requires some error-prone steps, depends on operting system versions and so on.

Today we want to lower the entry barrier even further - we've prepared and Amazon AMI (Amazon Machine Image) for you with preinstalled Openscoring service. This post will walk you through the steps required to get things up and running.

Preconditions

This time, you're going to need:

Amazon EC2 Setup

The part with steps related to AWS is a bit long, but that's also due to the amount of images included. Bear with me, it's all web browsing and no command line at all :-)

Assuming you have AWS account or have signed up during the previous step, this is what you need to do:

  • On the very first screen that pops up, you need to choose EC2 (or "Launch a virtual machine with EC2").
  • This will lead you to EC2 management screen. Take a look at the upper right corner of the screen where the AWS region is displayed:
region.jpg

I've created the images for following regions:

  1. EU (Frankfurt) - ami-0856fb979732e0016
  2. EU (Ireland) - ami-0aa76e5c2adbaf682
  3. US West (N. California) - ami-0c6ac011f918947e1
  4. US East (N. Virginia) - ami-07f1b7187e58af6b4
  5. Asia Pacific (Singapore) - ami-0ddae89443be18b52

If you cannot use any of these regions (I really don't know if Texas is US West or US East; at least from EU, I couldn't access the EC2 instance I created to US East region), please let me know and I'll make the image available in your region too.

  • From the left menu, choose Images->AMIs, choose Public Images and search according to you region for either the respective AMI ID directly or for "openscoring":
  • From the right-click menu choose Launch.
  • Next up is Launch process. Choose Free Tier (if you haven't been using AWS for more than 12 months) and now Next: Configure Instance Details
  • Click through the steps always choosing Next:... (the default conf here is just fine), until you reach the security part:
  • What you need to do here is Add Rule and choose Custom TCP, port 8080, Anywhere (this will allow you to access Openscoring web service running on port 8080 from anywhere in the world).
  • It will briefly complain about leaving the instance open to the world, but we don't care as this is for testing anyway, so go ahead and Review and Launch the instance.
  • You can launch the instance without configuring any keys (of course if you want you can do it, but for our purposes no command line access will be needed; you'll also be able to launch more instances based on the same AMI later with keys if you want to dig around there).
  • Now navigate to the Instances screen and wait until the status is running:
  • From here, copy the Public DNS.

Executing the Model

Openscoring service is already running on your EC2 instance on port 8080. You copied the public DNS name in previous step, now you can open Postman and paste the name into URL field, add port 8080 and you can do everything our REST API allows (scroll down to API spec).

For more details how to use Postman, check out the last chapters of our post Deploying PMML Model to Openscoring REST Evaluation Service.

The EC2 instace comes with DecisionTreeIris PMML predeployed, so you can easily assemble the following request for first test:

http://<public DNS>:8080/openscoring/model/DecisionTreeIris

Set the request body to the following value:

{
    "id" : "record-001",
    "arguments" : {
        "Sepal_Length" : 5.1,
        "Sepal_Width" : 3.5,
        "Petal_Length" : 1.4,
        "Petal_Width" : 0.2
    }
}

The Content-Type header to: application/json and you're good to Send the request.

And there you go again - based on the DecisionTreeIris model, your iris is of 'setosa' type with the probability score of 1.

If any of the steps don't work out for you, feel free to let me know either in the comments or by email: karel@openscoring.io and I'll try to help.