# Transforms

{% hint style="info" %}
*Check out a walk-through on how to use the Transform script inside Notebook.*
{% endhint %}

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2Fw3kKz5scRS3H4T7utpeW%2FData%20Transformation.gif?alt=media\&token=53f6178c-b632-45ba-9285-20708fe72c02)

You can write or upload a script containing transform function to a Notebook and save a model based on it. You can also register the model as an API service. This entire process gets completed in the below given steps:

1. [<mark style="color:blue;">**Saving and loading a Model with Transform script**</mark>](#saving-and-loading-a-model-with-transform-script)
2. [<mark style="color:blue;">**Registering a Transform Model**</mark>](#registering-a-transform-model)
3. [<mark style="color:blue;">**Publishing a Transform Model as API**</mark>](#publish-a-transform-model-as-api)

### Saving and loading a Model with Transform script

* Navigate to a Notebook.
* Add a Code cell (by default one cell gets added in a new Notebook).
* Write or provide a transform script to the cell.
* Run the cell.

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2F62QpCUmpq47h639JYXhN%2Fimage.png?alt=media\&token=c667a7ac-9cea-4054-8b30-fdadba348a02)

* Add a new Code cell.
* Click the ***Save Model*** option to generate the code to save the desired model.
* Specify the model name and model type in the auto-generated script.
* Run the cell.
* The model gets saved under the Transform tab.

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FPwVPm3ejIPEqauSq67xa%2Fimage.png?alt=media\&token=6b0b63ce-bc24-4cde-b542-54b2efb24a97)

* Add a new Code cell.
* Use the checkbox given next to the saved model to load it.
* Run the cell.

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2F3yxFgOiEgIHqSDFStNsw%2Fimage.png?alt=media\&token=9f2a6c02-9a8b-46ad-8a6f-2d58552b210a)

* Add a new Code cell.
* Click the ***Transform*** option.
* Specify the train data.
* Run the cell.

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FiCNZorHND2HJL4zuewdg%2Fimage.png?alt=media\&token=e538de16-e9ab-46d5-b5da-7abbf51fedad)

* The data output appears below.

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FSvUcb3vouKxB6z7w2vQ3%2Fimage.png?alt=media\&token=90464657-ac54-4f91-9422-1669c2456e89)

### Registering a Transform Model

* Open the ***Transforms*** tab inside a Notebook.
* Select the Register option for a listed transform.&#x20;

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FaHHObeSAQ7Bq7wWRKRXQ%2Fimage.png?alt=media\&token=52af250f-035f-48ab-abd6-89e0723c614b)

* The Register Model dialog box opens to confirm the action.
* Click the ***Yes*** option.

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FXKPXBRgtyhbVgYVLUGon%2Fimage.png?alt=media\&token=fba1d0ec-d8f3-428f-9839-4992334e9637)

* A confirmation message appears to inform completion of the action.

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2F1oU9sAqaISwFZwQaJJEm%2Fimage.png?alt=media\&token=f20e5fe4-caff-4423-8a1f-3a355fce4a92)

* The model gets registered and lists under the ***Registered*** list of the models.

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2Fj3uB6sosFuxApSEyocqa%2Fimage.png?alt=media\&token=390f2079-07bd-4758-8fa1-693f7171f863)

* Open a pipeline workflow with a DS Lab model runner component.
* The registered model gets listed under the Meta Information tab of the DS Lab model runner component.

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2F2vcw8seB5eSg9qbtOWqF%2Fimage.png?alt=media\&token=f88af403-8a8d-4fb7-8913-f047b06e88b2)

### Publishing a Transform Model as API

The Publish Model as API functionality gets completed in three steps:

1. [<mark style="color:blue;">**Register a Transform Model as API**</mark>](#register-a-transform-model-as-api)
2. [<mark style="color:blue;">**Register an API Client**</mark>](#register-an-api-client)
3. [<mark style="color:blue;">**Pass Model Values in Postman**</mark>](#pass-model-values-in-postman)

#### Register a Transform Model as API

* Navigate to the ***Model*** tab.
* Select a saved model from the model list.
* Click the ***Register as API*** option.

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FlNm6Odd2VFs11nijOS0k%2Fimage.png?alt=media\&token=07574a7d-6a19-4adb-8080-36e97692ebd0)

* You will get directed to the ***Update Model*** page.
* Provide the ***Max Instance*** option.
* Click the ***Save and Register*** option.

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FrJnVsGnQpUjjIPI4dZKa%2Fimage.png?alt=media\&token=143ffb8a-1107-4d3e-ad61-f36665d625df)

* A confirmation message appears to indicate that the Model has been saved and registered (The icon for a registered model appears differently).

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FiZUGcRfO8Dr39BrXctUQ%2Fimage.png?alt=media\&token=edecddaf-5f6e-4cbc-bd26-6ec7ddeaca19)

#### Register an API Client

* Navigate to the ***Admin Module*** from the ***Apps*** menu.

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FmOQoNiDInMwstTYy6ex5%2Fimage.png?alt=media\&token=4590727f-dd33-4807-8f12-5c95fc8b8f72)

* Click on the ***API Client Registration*** option from the Admin panel.

#### ![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FiKQdQcxTglC2EI6DExuf%2Fimage.png?alt=media\&token=3d13f516-9a3b-40ec-822c-cc41383c3d26)

* The ***API Client Registration*** form appears.
* Choose the ***Internal*** option from the ***Select*** drop-down.
* Provide the required details to register the API Client:
  * Client Name
  * Client Email
  * App Name
  * Request Per Hour
  * Request Per Day
  * Select App Type (Select ***Model As API*** option from the drop-down menu).
  * Select the saved model using the ***Select the Services Entitled*** option.
  * Click the ***Save*** option to save the client details.

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FY4rOpyC21do8XNBV4JIZ%2Fimage.png?alt=media\&token=5b016230-0517-4dff-9284-7e8c1de50300)

* A confirmation message appears to inform about the completion of the client registration action.

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FmBXr5A7YycxU8dBTXAMk%2Fimage.png?alt=media\&token=e00deee1-7759-4f09-9765-b3b90800d413)

* The API client gets registered. You can get the following details from the registered API Client Registration.
  * App Name
  * Client Id
  * Client Secret Key

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2F3RIJtkmoI2kJiNoKjx5x%2Fimage.png?alt=media\&token=cc9b5f73-53aa-49fa-8c79-076f7265df34)

#### Pass Model values in Postman

* Navigate to the Postman application and select POST service.
* Open the ***Headers*** tab.
* Provide the clientid, clientsecret, and appname from the API Client Registration form as explained in the previous step.&#x20;

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FanLsCbdey6liKECXdAzu%2Fimage.png?alt=media\&token=a7b37df1-b366-44ac-aca2-d8c022b15dfc)

* Open the ***Body*** tab.
* Provide the input dataframe.
* Click the ***Send*** option.
* The response will appear below.
* You can save the response by using the ***Save Response*** option.

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FTKTzmblVlArMiismlu8a%2Fimage.png?alt=media\&token=41cc3979-440e-4fc2-b47f-cfd1aeeb59cb)
