# Model Creation using Data Science Notebook

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

{% hint style="success" %}
*Check out the illustration on saving and loading a Data Science Model.*
{% endhint %}

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2FRRkt69yqIcHSjAMq7MBG%2FSaving%20%26%20loading%20a%20model.mp4?alt=media&token=63cb1cb5-06ae-4f13-9eda-4edf10c4b84c>" %}
***Saving and Loading a Data Science Model***
{% endembed %}

## Saving a Data Science Lab Model

* Navigate to a Data Science 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://3817372244-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2FWLpg8MxOyecGHm3Z5PZc%2Fimage.png?alt=media&#x26;token=f8cd1ea2-d472-444e-a2f2-33a1fef9f84a" 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.

<figure><img src="https://3817372244-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2FrjNzpVPlVmj6mxt5mv38%2Fimage.png?alt=media&#x26;token=547e1bdb-d1e9-4506-b35f-e9b1cdbe1b52" 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://3817372244-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2F1JfP3nwlp8Oxdh9OidrN%2Fimage.png?alt=media&#x26;token=351682c0-f496-4114-9f48-3a556bc416d2" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://3817372244-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2FeSsUpHUHzqJCqjIbONyy%2Fimage.png?alt=media&#x26;token=0f85b728-e778-463f-9f8e-c8ae51b1294c" alt=""><figcaption><p><em><strong>the model gets saved</strong></em></p></figcaption></figure>

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

## **Function Parameters** <a href="#function-parameters" id="function-parameters"></a>

* model - Trained model variable name.
* modelName - The desired name given by the 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 used.

<figure><img src="https://3817372244-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2FPBVwpWPsfu5kFiz3tedX%2Fimage.png?alt=media&#x26;token=d158137c-d6d3-43a1-a37c-5836981d19dc" 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. Please 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://3817372244-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2FprpJGEubIYxP5ZRbYstd%2Fimage.png?alt=media&#x26;token=289ccb16-648a-4cc5-b8aa-2af1102c0506" alt=""><figcaption><p><em><strong>Loading a saved Data Science Lab Model</strong></em></p></figcaption></figure>

A saved model under the Model tab of the Data Science Notebook gets the following options:


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bdb.ai/data-science-lab-5/model-creation-using-data-science-notebook.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
