Skip to content
This repository was archived by the owner on Nov 5, 2022. It is now read-only.

Commit 0998953

Browse files
committed
Add online prediction example for TF
Change-Id: I508aaca04576b3bda500fae3350351ef7b251747
1 parent 8782c77 commit 0998953

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

examples/tf/demo.py

+19-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,27 @@
1818

1919
def main():
2020
config = "examples/tf/config.yaml"
21-
model = TFModel(config)
21+
pred_input = [{"age": 25,
22+
"workclass": " Private",
23+
"education": " 11th",
24+
"education_num": 7,
25+
"marital_status":" Never-married",
26+
"occupation": " Machine-op-inspct",
27+
"relationship": " Own-child",
28+
"race": " Black",
29+
"gender": " Male",
30+
"capital_gain": 0,
31+
"capital_loss": 0,
32+
"hours_per_week": 40,
33+
"native_country": " United-States"}]
2234

35+
model = TFModel(config)
2336
job_id = model.train()
24-
model.serve(job_id=job_id)
37+
version = model.serve(job_id=job_id)
38+
preds = model.online_predict(pred_input, version=version)
39+
40+
print("Features: {}".format(pred_input))
41+
print("Predictions: {}".format(preds))
2542

2643

2744
if __name__ == "__main__":

0 commit comments

Comments
 (0)