Skip to content

Commit 62702df

Browse files
ospillingerdeliahu
authored andcommitted
Update tutorial
(cherry picked from commit 8d744ed)
1 parent ded1605 commit 62702df

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

examples/sklearn/iris-classifier/README.md

+16-10
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This example shows how to deploy a classifier trained on the famous [iris data s
1111
1. Create a Python file `trainer.py`.
1212
2. Use scikit-learn's `LogisticRegression` to train your model.
1313
3. Add code to pickle your model (you can use other serialization libraries such as joblib).
14-
4. Upload it to S3 (boto3 will need access to valid AWS credentials).
14+
4. Replace the bucket name "cortex-examples" with your bucket and upload it to S3 (boto3 will need access to valid AWS credentials).
1515

1616
```python
1717
import boto3
@@ -35,7 +35,7 @@ print("accuracy: {:.2f}".format(accuracy))
3535

3636
pickle.dump(model, open("model.pkl", "wb"))
3737
s3 = boto3.client("s3")
38-
s3.upload_file("model.pkl", "my-bucket", "sklearn/iris-classifier/model.pkl")
38+
s3.upload_file("model.pkl", "cortex-examples", "sklearn/iris-classifier/model.pkl")
3939
```
4040

4141
Run the script locally:
@@ -101,7 +101,7 @@ You can skip dependencies that are [pre-installed](../../../docs/deployments/pyt
101101

102102
## Configure your API
103103

104-
Create a `cortex.yaml` file and add the configuration below. An `api` provides a runtime for inference and makes your `predictor.py` implementation available as a web service that can serve real-time predictions:
104+
Create a `cortex.yaml` file and add the configuration below and replace `cortex-examples` with your S3 bucket. An `api` provides a runtime for inference and makes your `predictor.py` implementation available as a web service that can serve real-time predictions:
105105

106106
```yaml
107107
# cortex.yaml
@@ -133,7 +133,7 @@ Track the status of your api using `cortex get`:
133133
$ cortex get iris-classifier --watch
134134
135135
status up-to-date requested last update avg inference 2XX
136-
live 1 1 8s - -
136+
live 1 1 1m - -
137137
138138
endpoint: http://***.amazonaws.com/iris-classifier
139139
```
@@ -194,7 +194,7 @@ After making more predictions, your `cortex get` command will show information a
194194
$ cortex get iris-classifier --watch
195195
196196
status up-to-date requested last update avg inference 2XX
197-
live 1 1 10m 28ms 14
197+
live 1 1 1m 1.1 ms 14
198198
199199
class count
200200
setosa 8
@@ -209,6 +209,8 @@ virginica 4
209209
This model is fairly small but larger models may require more compute resources. You can configure this in your `cortex.yaml`:
210210

211211
```yaml
212+
# cortex.yaml
213+
212214
- name: iris-classifier
213215
predictor:
214216
type: python
@@ -237,7 +239,7 @@ Run `cortex get` again:
237239
$ cortex get iris-classifier --watch
238240
239241
status up-to-date requested last update avg inference 2XX
240-
live 1 1 10m 24ms 14
242+
live 1 1 1m 1.1 ms 14
241243
242244
class count
243245
setosa 8
@@ -252,6 +254,8 @@ virginica 4
252254
If you trained another model and want to A/B test it with your previous model, simply add another `api` to your configuration and specify the new model:
253255

254256
```yaml
257+
# cortex.yaml
258+
255259
- name: iris-classifier
256260
predictor:
257261
type: python
@@ -295,7 +299,7 @@ $ cortex get --watch
295299
296300
api status up-to-date requested last update
297301
iris-classifier live 1 1 5m
298-
another-iris-classifier live 1 1 8s
302+
another-iris-classifier live 1 1 1m
299303
```
300304

301305
## Add a batch API
@@ -335,6 +339,8 @@ class PythonPredictor:
335339
Next, add the `api` to `cortex.yaml`:
336340

337341
```yaml
342+
# cortex.yaml
343+
338344
- name: iris-classifier
339345
predictor:
340346
type: python
@@ -391,9 +397,9 @@ Since a new file was added to the directory, and all files in the directory cont
391397
$ cortex get --watch
392398
393399
api status up-to-date requested last update
394-
iris-classifier live 1 1 17s
395-
another-iris-classifier live 1 1 17s
396-
batch-iris-classifier live 1 1 17s
400+
iris-classifier live 1 1 1m
401+
another-iris-classifier live 1 1 1m
402+
batch-iris-classifier live 1 1 1m
397403
```
398404

399405
<br>

examples/sklearn/iris-classifier/trainer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222

2323
pickle.dump(model, open("model.pkl", "wb"))
2424
s3 = boto3.client("s3")
25-
s3.upload_file("model.pkl", "my-bucket", "sklearn/iris-classifier/model.pkl")
25+
s3.upload_file("model.pkl", "cortex-examples", "sklearn/iris-classifier/model.pkl")

0 commit comments

Comments
 (0)