Skip to content

Instantly share code, notes, and snippets.

@sbalnojan
Created May 22, 2019 12:02
Show Gist options
  • Save sbalnojan/633fe7242c908bd5a278c8b84a22a032 to your computer and use it in GitHub Desktop.
Save sbalnojan/633fe7242c908bd5a278c8b84a22a032 to your computer and use it in GitHub Desktop.
Fit model, dump to S3 via s3fs
import s3fs
import pickle
import json
import numpy as np
BUCKET_NAME = "my-bucket"
# definitions, keras/tf/... imports...
if __name__ == "__main__":
s3 = s3fs.S3FileSystem(anon=False) # mount
model_options = { "name": "",
"comment": "trained on half the dataset",
"params": {
"n_trees": 4
}}
json.dump(model_options, s3.open(f"{BUCKET_NAME}/options_{model_options['name'] + str(np.random.randint(10000))}.json",'w'))
model = generate_baseline(model_options["params"]) # generate some base line model with whatever option we want to use.
model.fit(X,y)
pickle.dump(model, s3.open(f"{BUCKET_NAME}/model_{model_options['name'] + str(np.random.randint(10000))}.pkl",'w'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment