Created
September 13, 2016 14:26
-
-
Save glamp/a51c76e9c2a341140a1cf183e2344204 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from yhat import Yhat, YhatModel | |
import numpy as np | |
class SplitTestExample(YhatModel): | |
def execute(self, data): | |
# randomly select model to use. `p` defines the split percentage | |
endpoints = ["ModelA", "ModelB"] | |
endpoint = np.random.choice(endpoints, p=[0.2, 0.8]) | |
# make prediction to a "sub-model". this will give you back the full API response | |
response = yh.predict(endpoint, data) | |
# format the results and return. we're only going to grab the 'result' value | |
# from the API response | |
output = response['result'] | |
# assign a label for which endpoint/variant was used, and then return the output | |
output['variant'] = endpoint | |
return output | |
yh = Yhat(USERNAME, APIKEY, URL) | |
yh.deploy("SplitTestSuperModel", SplitTestExample, globals()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment