# Transforms

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

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2FGoLrh99LpvzeKa2CeWMS%2FData%20Transform%20model.mp4?alt=media&token=abae372e-8d42-4df3-88f4-84072f80af94>" %}
**Saving a model with transform**&#x20;
{% endembed %}

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. [**Saving and loading a Model with Transform script​**](#saving-and-loading-a-model-with-transform-script)
2. [**​Registering a Transform Model​**](#registering-a-transform-model)
3. **​**[**Publishing a Transform Model as API​**](#publishing-a-transform-model-as-api)

## Saving and loading a Model with Transform script <a href="#saving-and-loading-a-model-with-transform-script" id="saving-and-loading-a-model-with-transform-script"></a>

* 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 (In this case, it has been provided in three cells).&#x20;
* Run the cell(s) (In this case, run all the three cells).
* Add a new code cell.
* Click the ***Save Model*** option for the newly added code cell.

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2FUq3zzrv42FIE3Wq3p94K%2Fimage.png?alt=media&#x26;token=a718ffaa-e2aa-410b-b9ee-0d323e95fd0f" alt=""><figcaption></figcaption></figure>

* Specify the model name and model type in the auto-generated script in the next code cell.
* Run the cell.
* Open the ***Transforms*** tab.
* The model gets saved under the ***Transforms*** tab.

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2FV0NXJghcmvgGRpOqsCnB%2Fimage.png?alt=media&#x26;token=cc12ed3e-93f2-409e-a23f-d5a8f79c446f" alt=""><figcaption></figcaption></figure>

* Add a new code cell.
* Load the transform model by using the checkbox.
* Run that cell.

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2F2J5KHpN5HXl5SeHucF6M%2Fimage.png?alt=media&#x26;token=bd2e359b-fb48-4e99-864a-4e10043a0ac1" alt=""><figcaption></figcaption></figure>

* Insert a new code cell.
* Click the Transform option for the code cell.
* The auto-generated script appears.
* Specify the train data.
* Run the code cell.

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2FIAuppj00c0Sq6wIXomNq%2Fimage.png?alt=media&#x26;token=856a3c10-9352-4478-9ada-cee2ec20cce0" alt=""><figcaption></figcaption></figure>

* It will display the transformed data below.

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2FAL34aNqME2QzutxOd8FM%2Fimage.png?alt=media&#x26;token=20670531-b183-4f9e-b915-0f0465ad96f1" alt=""><figcaption></figcaption></figure>

## Registering a Transform Model <a href="#registering-a-transform-model" id="registering-a-transform-model"></a>

* Open the ***Transforms*** tab inside a Notebook.
* Click the ellipsis icon for the saved transform.
* Select the ***Register*** option for a listed transform.

&#x20;      ![](https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2FeT2Lr01V1FkFO6RCj678%2Fimage.png?alt=media\&token=29cff727-5454-42fd-9283-3df94f970fbe)​

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

&#x20;       ![](https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2Fi4qcbNMFbxoQPscVLBqL%2Fimage.png?alt=media\&token=143b9ab3-d9a9-42c4-bf2d-106329e25f69)​​

* A confirmation message appears to inform completion of the action.
* The model gets registered and lists under the ***Registered*** list of the models.​​

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2FaSRAyOyeJJdc9MiX42W5%2Fimage.png?alt=media&#x26;token=4b820c2a-8167-48f2-8018-00dbe1ebcdb8" alt=""><figcaption></figcaption></figure>

* 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 inside the Data Pipeline module.

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2F95NEtIhmlsrudJ1wqdrg%2Fimage.png?alt=media&#x26;token=6367bc6e-a499-421b-b46b-cdef057a6014" alt=""><figcaption></figcaption></figure>

## Publishing a Transform Model as API <a href="#publishing-a-transform-model-as-api" id="publishing-a-transform-model-as-api"></a>

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

1. [​**Register a Transform Model as API​**](#register-a-transform-model-as-api)
2. [​**Register an API Client​**](#register-an-api-client)
3. [**​Pass Model Values in Postman**](#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.

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2F9uaKxqcCv1Hgqn2XEV8Y%2Fimage.png?alt=media&#x26;token=88ee6f1f-d8d8-4b52-aa6e-ac5808033485" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2FSP6Q4dkeMYmx5vXoYAEk%2Fimage.png?alt=media&#x26;token=51078acf-2e8b-45bb-aaa9-698c1470e7df" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2FALnE5vOcQ7dtcT6Vtizg%2Fimage.png?alt=media&#x26;token=3748ae4e-212f-4b73-a0b6-2e16b3005a89" alt=""><figcaption></figcaption></figure>

### **Register an API Client**

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

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2FYhr7J07KsvWfMaasMiCv%2Fimage.png?alt=media&#x26;token=a2b3deb8-3a05-4e9f-aa94-a50864f04361" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/m4sB20BLMtp3xKhLuKjp/image.png" alt=""><figcaption></figcaption></figure>

* The ***API Client Registration*** page appears.
* Click the ***New*** option.

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2FJsJIztIxUFAouqnIn5nc%2Fimage.png?alt=media&#x26;token=a4d6f72e-4b1c-48a6-abf7-29b16e89e77e" alt=""><figcaption></figcaption></figure>

* The ***API Client Registration*** form opens.
* 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.

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2Fp3y4sqBbfT3HO6XI9vSp%2Fimage.png?alt=media&#x26;token=d610a223-5f96-49c0-a436-e0557888a7a7" alt=""><figcaption></figcaption></figure>

* A confirmation message appears to inform about the completion of the client registration action.
* The API client gets registered.

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2FswK86yIZdlgtQBpWPCsH%2Fimage.png?alt=media&#x26;token=000eeecb-3989-47a6-adc9-e3b20c26be77" alt=""><figcaption></figcaption></figure>

* Open the registered API Client by clicking the ***Edit*** icon.
* The following information can be received after registering an API client.
  * App Name
  * Client Id
  * Client Secret Key

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2FV8ZsIzL0o1ufvsFk37ym%2Fimage.png?alt=media&#x26;token=9c28ea2c-f745-4cb1-8418-607e0fd5f35f" alt=""><figcaption></figcaption></figure>

### **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.

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2FlMKaY2W3w5pflTqVLLm4%2Fimage.png?alt=media&#x26;token=c351156c-110b-4b33-b5c7-3c451775ec24" alt=""><figcaption></figcaption></figure>

* Open the ***Body*** tab.
* Provide the input DataFrame using the raw option.
* Click the ***Send*** option.
* The response will appear below.

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2F92j3C2lxdRRO49SOjNbP%2Fimage.png?alt=media&#x26;token=2fe51096-5672-4e6a-adfe-1e658d7e467d" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
*<mark style="color:green;">Please Note:</mark> Refer the* [***Data Science Lab Quick Start Flow*** ](https://docs.bdb.ai/data-science-lab-4/data-science-lab-quick-start-flow)*page to get an overview of the **Data Science Lab** module in nutshell.*&#x20;
{% endhint %}
