Skip to content

Commit 976fd11

Browse files
committed
ODSC-36246: fix the wording
1 parent 666baf1 commit 976fd11

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

docs/source/user_guide/model_registration/frameworks/genericmodel.rst

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -172,28 +172,6 @@ Here is a more realistic example using CatBoost model.
172172
catboost_model.delete_deployment(wait_for_completion=True)
173173
ModelCatalog(compartment_id=os.environ['NB_SESSION_COMPARTMENT_OCID']).delete_model(model_id)
174174
175-
You can also use the shortcut ``.prepare_save_deploy()`` instead of calling ``.prepare()``, ``.save()`` and ``.deploy()`` seperately.
176-
177-
.. code-block:: python3
178-
179-
import tempfile
180-
from ads.catalog.model import ModelCatalog
181-
from ads.model.generic_model import GenericModel
182-
183-
class Toy:
184-
def predict(self, x):
185-
return x ** 2
186-
estimator = Toy()
187-
188-
model = GenericModel(estimator=estimator)
189-
model.summary_status()
190-
# If you are running the code inside a notebook session and using a service pack, `inference_conda_env` can be omitted.
191-
model.prepare_save_deploy(inference_conda_env="dataexpl_p37_cpu_v3")
192-
model.verify(2)
193-
model.predict(2)
194-
model.delete_deployment(wait_for_completion=True)
195-
ModelCatalog(compartment_id=os.environ['NB_SESSION_COMPARTMENT_OCID']).delete_model(model.model_id)
196-
197175
198176
Example -- Save Your Own Model
199177
==============================
@@ -244,11 +222,11 @@ The example is illustrated using an AutoMLx model.
244222
model = GenericModel(est, artifact_dir = "model_artifact_folder", serialize=False)
245223
model.prepare(inference_conda_env="automlx_p38_cpu_v1",force_overwrite=True, model_file_name="model.pkl", X_sample=X_test)
246224
247-
Now copy the model.pkl file and paste into the ``model_artifact_folder`` folder. And open the score.py in the ``model_artifact_folder`` folder and add implement the ``load_model`` function. You can also edit ``pre_inference`` and ``post_inference`` function. Below is an example implementation of the score.py.
225+
Now copy the model.pkl file and paste into the ``model_artifact_folder`` folder. And open the score.py in the ``model_artifact_folder`` folder to add implementation of the ``load_model`` function. You can also add your preprocessing steps in ``pre_inference`` function and postprocessing steps in ``post_inference`` function. Below is an example implementation of the score.py.
248226
Replace your score.py with the code below.
249227

250228
.. code-block:: python3
251-
:emphasize-lines: 28, 29, 30, 31, 122
229+
:emphasize-lines: 28, 29, 30, 31, 123
252230
253231
# score.py 1.0 generated by ADS 2.8.2 on 20230301_065458
254232
import os
@@ -396,7 +374,7 @@ Replace your score.py with the code below.
396374
)
397375
return {'prediction': yhat}
398376
399-
Save the score.py and now call verify to check if it works locally.
377+
Save the score.py and now call ``.verify()`` to check if it works locally.
400378

401379
.. code-block:: python3
402380
@@ -409,3 +387,25 @@ After verify run successfully, you can save the model to model catalog, deploy a
409387
model_id = model.save(display_name='Demo AutoMLModel model')
410388
deploy = model.deploy(display_name='Demo AutoMLModel deployment')
411389
model.predict(X_test.iloc[:2].to_json())
390+
391+
You can also use the shortcut ``.prepare_save_deploy()`` instead of calling ``.prepare()``, ``.save()`` and ``.deploy()`` seperately.
392+
393+
.. code-block:: python3
394+
395+
import tempfile
396+
from ads.catalog.model import ModelCatalog
397+
from ads.model.generic_model import GenericModel
398+
399+
class Toy:
400+
def predict(self, x):
401+
return x ** 2
402+
estimator = Toy()
403+
404+
model = GenericModel(estimator=estimator)
405+
model.summary_status()
406+
# If you are running the code inside a notebook session and using a service pack, `inference_conda_env` can be omitted.
407+
model.prepare_save_deploy(inference_conda_env="dataexpl_p37_cpu_v3")
408+
model.verify(2)
409+
model.predict(2)
410+
model.delete_deployment(wait_for_completion=True)
411+
ModelCatalog(compartment_id=os.environ['NB_SESSION_COMPARTMENT_OCID']).delete_model(model.model_id)

0 commit comments

Comments
 (0)