8000 Add README · lauro-cesar/python-docs-samples@a241ff2 · GitHub
[go: up one dir, main page]

Skip to content

Commit a241ff2

Browse files
committed
Add README
1 parent 6bd101a commit a241ff2

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

ml_engine/online_prediction/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Online Prediction with the Cloud Machine Learning Engine
2+
3+
This sample assumes that you have already run the Cloud ML Engine end to end walkthrough using the UCI Census dataset, including training a wide & deep model and deploying it into production, ready to take prediction requests.
4+
5+
This sample then shows you how to create a client that takes user JSON inputs, and sends those inputs as online prediction requests to a given deployed model.
6+
7+
In order to use this client, first obtain the following information, and store it into the given environment variables:
8+
9+
```
10+
PROJECT=<your project name>
11+
MODEL=<your model name>
12+
VERSION=<version of model you are using>
13+
```
14+
15+
Next, launch this client as follows:
16+
17+
```
18+
python predict.py --project=$PROJECT --model=$MODEL --version=$VERSION
19+
```
20+
21+
After having done that, the client will ask you for ‘Valid JSON’ input as follows:
22+
23+
```
24+
Valid JSON >>>
25+
```
26+
27+
Now you can input a JSON example that corresponds to the schema of the given model. For instance if you are sending prediction requests to the census-based model created in the Cloud ML Engine walkthrough, you can send a JSON example like the following:
28+
29+
```
30+
{"age": 25, "workclass": " Private", "education": " 11th", "education_num": 7, "marital_status": " Never-married", "occupation": " Machine-op-inspct", "relationship": " Own-child", "race": " Black", "gender": " Male", "capital_gain": 0, "capital_loss": 0, "hours_per_week": 40, "native_country": " United-States"}
31+
```
32+
The result should be something along the following lines (depending on how you trained the model/what parameters you used, the results may vary):
33+
34+
```
35+
[{u'probabilities': [0.992774486541748, 0.007225471083074808], u'logits': [-4.922891139984131], u'classes': 0, u'logistic': [0.007225471083074808]}]
36+
```
37+
38+
Now that you have a working client, you can adapt this to your own use cases!

0 commit comments

Comments
 (0)
0