Getting Started with ScienceOps

This page will help you get started with ScienceOps. You'll be up and running in no time.

All of these examples assume you have access to a Yhat instance (either through the public sandbox or enterprise), a Yhat username, and an API key.

Install the Yhat client

You'll also need to add the Yhat client library for either R or Python:

! pip install -U yhat
install.packages("yhatr")

Deployment

Below is a simple HelloWorld model. To deploy it, simply copy the script below, paste it in your R or Python session, edit the USERNAME and APIKEY fields, and run the script!

from yhat import Yhat, YhatModel , preprocess

class HelloWorld(YhatModel):
    @preprocess(in_type=dict, out_type=dict)
    def execute(self, data):
        me = data['name']
        greeting = "Hello " + str(me) + "!"
        return { "greeting": greeting }

yh = Yhat("YOUR_USERNAME", "YOUR_APIKEY", "https://sandbox.yhathq.com/")
yh.deploy("HelloWorld", HelloWorld, globals())
library(yhatr)

model.predict <- function(request) {
  me <- request$name
  greeting<-paste ("Hello", me, "!")
  greeting
}

yhat.config  <- c(
  username="YOUR_USERNAME",
  apikey="YOUR_APIKEY",
  env="https://sandbox.yhathq.com/"
)
yhat.deploy("HelloWorld")

Great! You just deployed your first model. Now let's actually use it.

Get a prediction from your model

Call the model from your local machine:

yh = Yhat("YOUR_USERNAME", "YOUR_APIKEY", "https://sandbox.yhathq.com/")
yh.predict("HelloWorld", {"name": "Hank"})
testdata <- rjson::fromJSON('{"name":"hank"}')

yhat.predict("HelloWorld", testdata)
#     greeting
#1 Hello hank!
curl -X POST -H "Content-Type: application/json" \
    --user YOUR_USERNAME:YOUR_APIKEY \
    --data '{"name": "Hank"}' \
    https://sandbox.yhathq.com/YOUR_USERNAME/models/HelloWorld/

results matching ""

    No results matching ""