skip to navigation
skip to content

Not Logged In

yhat 0.6.8

Python client for Yhat (http://yhathq.com/)

Latest Version: 0.7.4

This is the connection to the Yhat API. If you'd like to read more, visit our docs.

Quickstart

You can download the example here , or clone the git repo.

$ git clone git@github.com:yhat/yhat-examples.git
$ cd beer-recommender

Insert your APIKEY and USERNAME and run the script.

$ python recommender.py
Deploy? (y/N): y
# {"status": "success"}

Overview

Usage

Installation

Using pip:

$ pip install --upgrade yhat

From source:

$ git clone git@github.com:yhat/yhat-client.git
$ cd yhat-client
$ python setup.py install

Setting up your model

Handling Input and Output

df to df

Specify df to df by decorating execute with the following:

from yhat import preprocess
# ...
# ...
@preprocess(in_type=pd.DataFrame, out_type=pd.DataFrame)
def execute(self, data)
# ...
# ...

Input

// making 1 prediction with an API call
{
  "column1": VALUE,
  "column2": VALUE
}
// making multiple predictions with 1 API call
{
  "column1": [ VALUE_1, VALUE_2 ]
  "column2": [ VALUE_1, VALUE_2 ]
}

Output

Data will come back with columns as keys and values as lists of values.

{
  "output_column1": [ VALUE_1 ],
  "output_column2": [ VALUE_1 ]
}

df to dict

from yhat import preprocess
# ...
# ...
@preprocess(in_type=pd.DataFrame, out_type=dict)
def execute(self, data)
# ...
# ...

Input

// making 1 prediction with an API call
{
  "column1": VALUE,
  "column2": VALUE
}
// making multiple predictions with 1 API call
{
  "column1": [ VALUE_1, VALUE_2 ]
  "column2": [ VALUE_1, VALUE_2 ]
}

Output

Selecting the dict output gives the user the ability to define their own output format (so long as it is a valid Python dictionary.

// this is valid
{
  "pred": 1
  "values": [1, 2, 3]
}
// this is also valid
{
  "x": {
    "y": 10
  "z": 100
  }
}

dict to dict

This is the most "free form" means of input and output. The user can send in any valid dictionary, process it how they like, and then return any valid dictionary .

from yhat import preprocess
# ...
# ...
@preprocess(in_type=dict, out_type=dict)
def execute(self, data)
# ...
# ...

Input

// this is valid
{
  "pred": 1
  "values": [1, 2, 3]
}
// this is also valid
{
  "x": {
    "y": 10
  },
    "z": 100
  }
}

Output

// this is valid
{
  "pred": 1
  "values": [1, 2, 3]
}
// this is also valid
{
  "x": {
    "y": 10
  },
    "z": 100
  }
}

Deploying

>>> yh.deploy("myExampleModel", MyExampleModel, globals())

Misc

Dependencies

Required

  • progressbar
  • pip
  • Flask
  • colorama
  • websocket-client
  • prettytable
  • dill

Highly suggested

  • pandas
  • sklearn

Analytics

 
File Type Py Version Uploaded on Size
yhat-0.6.8-py2.7.egg (md5) Python Egg 2.7 2014-02-28 40KB
yhat-0.6.8.tar.gz (md5) Source 2014-02-28 15KB
  • Downloads (All Versions):
  • 165 downloads in the last day
  • 6176 downloads in the last week
  • 30967 downloads in the last month