This is the connection to the Yhat API. If you'd like to read more, visit our docs.
Table of Contents:
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"}
Using pip
:
$ pip install --upgrade yhat
From source:
$ git clone git@github.com:yhat/yhat-client.git
$ cd yhat-client
$ python setup.py install
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)
# ...
# ...
// 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 ]
}
Data will come back with columns as keys and values as lists of values.
{
"output_column1": [ VALUE_1 ],
"output_column2": [ VALUE_1 ]
}
from yhat import preprocess
# ...
# ...
@preprocess(in_type=pd.DataFrame, out_type=dict)
def execute(self, data)
# ...
# ...
// 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 ]
}
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
}
}
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)
# ...
# ...
// this is valid
{
"pred": 1
"values": [1, 2, 3]
}
// this is also valid
{
"x": {
"y": 10
},
"z": 100
}
}
// this is valid
{
"pred": 1
"values": [1, 2, 3]
}
// this is also valid
{
"x": {
"y": 10
},
"z": 100
}
}
>>> yh.deploy("myExampleModel", MyExampleModel, globals())
yhat-cli config [--reset]
yhat-cli models [--admin]
yhat-cli model <modelname>
yhat-cli (-h | --help)
yhat-cli (-v | --version)
Configure the yhat client with your API credentials. The option --reset
will reset your credentials.
Return the models for your account. The option --admin
returns all models on the server, you must have admin access for this.
Returns details about the given model. You must own this model to view it.
Required
- doctopt
- progressbar
- pip
- Flask
- colorama
- websocket-client
- ElasticTabstops
- dill
Highly suggested
- pandas
- sklearn