# Models

Once the Notebook script is executed successfully, the users can save them as a model. The saved model can be loaded into the Notebook.

## Saving a Data Science Lab Model <a href="#saving-a-dsl-model" id="saving-a-dsl-model"></a>

* Navigate to a Notebook.
* Write code using the following sequence:
  * Read DataFrame
  * Define test and train data
  * Create a model
* Execute the script by running the code cell.

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2FOxKTKVwZcuWgvG66JOfR%2Fimage.png?alt=media&#x26;token=12d14633-49ba-4f4d-9cc1-a0677f3bbc17" alt=""><figcaption><p><em><strong>Sample Script for a Data Science Model</strong></em></p></figcaption></figure>

* Get a new cell.
* Click the ***Save model*** option.&#x20;

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2FqTidOlrXS1oCn5mM2EAI%2Fimage.png?alt=media&#x26;token=2b84622e-dfce-413f-a4f1-021de5f22f5c" alt=""><figcaption></figcaption></figure>

* A code gets generated in the newly added code cell.
* Give a model name to specify the model and model type as ***ml.***
* Execute the code cell.

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2FxDAjXU15aUzZ6BHAP0lL%2Fimage.png?alt=media&#x26;token=b1042784-3c32-47f9-91f5-9174f9a05862" alt=""><figcaption></figcaption></figure>

* After the code gets executed, the Model gets saved under the ***Models*** tab.

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2FQRhULXufPTVdQIBDzA8O%2Fimage.png?alt=media&#x26;token=ce46287e-aed8-420e-8dad-41b96dd42ae4" alt=""><figcaption><p><em><strong>the model gets saved</strong></em> </p></figcaption></figure>

{% hint style="info" %}
*<mark style="color:green;">Please Note:</mark> The newly saved model gets saved under the unregistered category given inside the **Models** tab.*
{% endhint %}

### **Function Parameters**

* model - Trained model variable name.
* modelName - Desired name given by user for the trained model.
* modelType - Type in which model can be saved.
* X - This array contains the input features or predictors used to train the model. Each row in the X\_train array represents a sample or observation in the training set, and each column represents a feature or variable.
* Y - This array contains the corresponding output or response variable for each sample in the training set. It is also called the target variable, dependent variable, or label. The Y\_train array has the same number of rows as the X\_train array.
* estimator\_type - The estimator\_type of a data science model refers to the type of estimator use.

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2F1vxUO7SfJCmNK1AOeyph%2Fimage.png?alt=media&#x26;token=cba71bbb-320e-448e-8b63-33ad3da45aa8" alt=""><figcaption><p><em><strong>Specify a Data Science Lab Model by giving a Model name &#x26; Model Type</strong></em></p></figcaption></figure>

## Loading a Data Science Lab Model <a href="#loading-a-dsl-model" id="loading-a-dsl-model"></a>

* Open the ***Models*** tab.
* Access the Unregistered category.
* The saved model will be available under the Models tab. Select the model by using the given checkbox to load it.
* The model gets loaded into a new cell.
* Run the cell.

<figure><img src="https://4082649235-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2F7zdWK51oBmlS0ascfboZ%2Fimage.png?alt=media&#x26;token=429390e8-1ecb-4200-b0d0-72360d4b205a" alt=""><figcaption><p><em><strong>Loading a saved Data Science Lab Model</strong></em></p></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 %}
