You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+54-2Lines changed: 54 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,6 +78,7 @@ PyMilo is an open source Python package that provides a simple, efficient, and s
78
78
79
79
80
80
## Usage
81
+
### Import/Export
81
82
Imagine you want to train a `LinearRegression` model representing this equation: $y = x_0 + 2x_1 + 3$. You will create data points (`X`, `y`) and train your model as follows.
82
83
```pycon
83
84
>>> import numpy as np
@@ -149,15 +150,66 @@ Now let's load it back. You can do it easily by using PyMilo `Import` class.
149
150
```
150
151
This loaded model is exactly the same as the original trained model.
151
152
153
+
### ML streaming
154
+
You can easily serve your ML model from a remote server using `ML streaming` feature of PyMilo.
155
+
156
+
⚠️ `ML streaming` feature exists in versions `>=1.0`
157
+
158
+
⚠️ In order to use `ML streaming` feature, make sure you've installed the `streaming` mode of PyMilo
159
+
160
+
#### Server
161
+
Let's assume you are in the remote server and you want to import the exported JSON file and start serving your model!
Now `PymiloServer` runs on port `8000` and exposes REST API to `upload`, `download` and retrieve **attributes** either **data attributes** like `model._coef` or **method attributes** like `model.predict(x_test)`.
170
+
171
+
#### Client
172
+
By using `PymiloClient` you can easily connect to the remote `PymiloServer` and execute any functionalities that the given ML model has, let's say you want to run `predict` function on your remote ML model and get the result:
ℹ️ If you've deployed `PymiloServer` locally (on port `8000` for instance), then `SERVER_URL` would be `http://127.0.0.1:8000`
181
+
182
+
You can also download the remote ML model into your local and execute functions locally on your model.
183
+
184
+
Calling `download` function on `PymiloClient` will sync the local model that `PymiloClient` wraps upon with the remote ML model, and it doesn't save model directly to a file.
185
+
186
+
```pycon
187
+
>>> pymilo_client.download()
188
+
```
189
+
If you want to save the ML model to a file in your local, you can use `Export` class.
`PymiloClient` wraps around the ML model, either to the local ML model or the remote ML model, and you can work with `PymiloClient` in the exact same way that you did with the ML model, you can run exact same functions with same signature.
200
+
201
+
ℹ️ Through the usage of `toggle_mode` function you can specify whether `PymiloClient` applies requests on the local ML model `pymilo_client.toggle_mode(mode=Mode.LOCAL)` or delegates it to the remote server `pymilo_client.toggle_mode(mode=Mode.DELEGATE)`
0 commit comments