# 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://content.gitbook.com/content/28ipFzCz8EMtVtHrBFLx/blobs/AnDxiEadWi4jS5TzQDg9/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.

<figure><img src="https://content.gitbook.com/content/28ipFzCz8EMtVtHrBFLx/blobs/vR5Lw4gtd7axdkdfnBpP/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/28ipFzCz8EMtVtHrBFLx/blobs/3BxEnfHZgcKILXAjFqvd/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/28ipFzCz8EMtVtHrBFLx/blobs/nFwloAe6FUVkitRWbkPc/image.png" 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://content.gitbook.com/content/28ipFzCz8EMtVtHrBFLx/blobs/LSix7Huhhn5Pu8ZAaqpF/image.png" 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://content.gitbook.com/content/28ipFzCz8EMtVtHrBFLx/blobs/RjAIW5DlrX7LFyB5YIST/image.png" alt=""><figcaption><p><em><strong>Loading a saved Data Science Lab Model</strong></em></p></figcaption></figure>
