Skip to content

Instantly share code, notes, and snippets.

@rajshah4
Last active June 7, 2021 20:09
Show Gist options
  • Save rajshah4/512913cd5a8b8184ccbbcd33c532b11f to your computer and use it in GitHub Desktop.
Save rajshah4/512913cd5a8b8184ccbbcd33c532b11f to your computer and use it in GitHub Desktop.
from pprint import pprint
def score(data, port = "6789"):
b_buf = BytesIO()
b_buf.write(data.to_csv(index=False).encode("utf-8"))
b_buf.seek(0)
url = "http://localhost:{}/predict/".format(port)
files = [
('X', b_buf)
]
response = requests.request("POST", url, files = files, timeout=None, verify=False)
return response
scoring_data = pd.read_csv("/content/mlops-examples/MLOps_DRUM/data/boston_housing_test.csv")
predictions = score(scoring_data).json() ## score entire dataset but only show first 5 records
pprint(predictions)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment