features = [{"name": "x", "na_filler": 0}, {"name": "z", "na_filler": fill_z}] class MyOtherClass: def hello(self, x): return "hello: %s" % str(x) REQS = open("reqs.txt").read() ### <DEPLOYMENT START> ### # @preprocess(in_type=dict, out_type=pd.DataFrame, null_handler=features) class MyModel(YhatModel): REQUIREMENTS = REQS @preprocess(out_type=pd.DataFrame) def execute(self, data): return predict(data) # "push" to server would be here data = {"x": 1, "z": None} if __name__ == '__main__': creds = credentials.read() yh = Yhat(creds['username'], creds['apikey']) yh.deploy_to_file("mynewmodel", MyModel, globals())
{"name": "x", "na_filler": 0}, {"name": "z", "na_filler": fill_z} ] class MyOtherClass: def hello(self, x): return "hello: %s" % str(x) REQS = open("reqs.txt").read() ### <DEPLOYMENT START> ### # @preprocess(in_type=dict, out_type=pd.DataFrame, null_handler=features) class MyModel(YhatModel): REQUIREMENTS=REQS @preprocess(out_type=pd.DataFrame) def execute(self, data): return predict(data) # "push" to server would be here data = {"x": 1, "z": None} if __name__ == '__main__': creds = credentials.read() yh = Yhat(creds['username'], creds['apikey']) yh.deploy_to_file("mynewmodel", MyModel, globals())
from yhat import YhatModel, Yhat, preprocess # from first import hello as h2 import first as f2 from first import Support from another.testfile import bye def goodbye(y): bye() print y, "goodbye!" class Example(YhatModel): @preprocess(in_type=dict, out_type=dict) def execute(self, data): goodbye(x) return Support().hello(10) # return h2(data) from first import x yh = Yhat("greg", "fCVZiLJhS95cnxOrsp5e2VSkk0GfypZqeRCntTD1nHA", "http://api.yhathq.com/") yh.deploy_to_file("Example", Example, globals())