Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sidravic/3cdcfa6f2f3a42423163955d86f57ddc to your computer and use it in GitHub Desktop.
Save sidravic/3cdcfa6f2f3a42423163955d86f57ddc 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