> For the complete documentation index, see [llms.txt](https://docs.bdb.ai/data-science-lab-4/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bdb.ai/data-science-lab-4/project/tabs-for-a-data-science-lab-project/tabs-for-tensorflow-and-pytorch-environment/notebook/notebook-page/notebook-operations/models.md).

# Models

Saving & loading a Data Science Lab model

{% hint style="success" %}
*Check-out the walk-through on how to save and load a DSL Model.*
{% endhint %}

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLGYLEkBUnc8nVEBAuEI%2Fuploads%2FFsvkH9FhB8RUEi1nu0Jg%2FSave%20%26%20Load%20Model.mp4?alt=media&token=4b136ff1-ddcd-4bf5-8292-14b68bd447dd>" %}
Save and load a model
{% endembed %}

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://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/oik8g2qYwIgS1MzswXRO/image.png" 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://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/lVZ5jsMOSlkqGcmIBBr8/image.png" 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://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/Aosm5SB8fzI8dA0t28Yn/image.png" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/e0eEPeeoGg5rEUv4hln6/image.png" alt=""><figcaption></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://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/BP6bD3bxI02VV2O93qAK/image.png" alt=""><figcaption><p><em><strong>Specify a Data Science Lab Model by giving a name</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://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/bfHf5PpswVqLSYMR61g9/image.png" 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 %}
