# Algorithms

{% hint style="success" %}
*<mark style="color:green;">Pre-requisite:</mark>*&#x20;

1. **Configure the Algorithms** using the [**Admin module**](https://docs.bdb.ai/bdb-documentation/core-platform/platform-administration/admin-panel-options/configurations/ds-lab-settings) to access them under the [**Data Science Lab Project**](https://docs.bdb.ai/bdb-documentation/data-science-lab/project/creating-a-project) creatio&#x6E;*.*&#x20;
2. The user must select Algorithms while creating a Project to make them accessible for a Notebook within the Project.
   {% endhint %}

{% hint style="info" %}
*Check-out the walk through on how to apply Algorithms inside Notebook.*
{% endhint %}

![Algorithm tab inside the Notebook page](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FZa0654ix8AwBch2GO00B%2FAlgorithms.gif?alt=media\&token=9f544599-5dcc-4079-86c3-4dd5dea6a1dc)

The entire process to access the Algorithms option inside the DS Lab and actually create a model based on the Algorithm is a three step process:

1. [**Admin Settings for Algorithms**](#admin-settings-for-algorithms)
2. [**Project Level Algorithm Selection**](#project-level-algorithm-selection)
3. [**Using Algorithm inside a Notebook**](#algorithms-tab-inside-notebook)

### Admin Settings for Algorithms

* Navigate to the ***Admin*** module.
* Open the ***Notebook Settings*** option from the ***Configuration*** section of the ***Admin*** panel.
* The Notebook Settings page opens.
* Select the ***Algorithms*** using the drop-down option.
* Click the ***Save*** option.
* A confirmation message appears to inform about the Notebook details updates.

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2Fqz85gdF4RZXm9CFt0H9h%2Fimage.png?alt=media\&token=519102a2-fcba-4488-9c8b-87f295769224)

### Project Level Algorithm Selection

Once the Algorithm settings is configured in the Admin module, the user can access the Algorithm within the Data Science Lab.

* Navigate to the ***Data Science Lab***.
* Click the ***Create Project*** option.

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2Fl5pIUL08owyEU7QsQ9WA%2Fimage.png?alt=media\&token=4322f471-ecc4-45cf-9e28-9da1fdbb0751)

* Together with the other required fields select the algorithms using the given checkboxes  from the drop-down menu.

&#x20;    &#x20;

![Selecting Algorithms using the Project page](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FQwKeadgfWUR9IkZBGy3Y%2Fimage.png?alt=media\&token=6c651abc-1791-4b75-817e-ec43a090071c)

* The selected Algorithms appear on the field separated by comma.     &#x20;

![Selected Algorithms](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FitXbDdJ27HX0jIt3vdQt%2Fimage.png?alt=media\&token=f7ded3db-4b35-48d6-831a-24d92e7754a8)

* ***Save*** the project.

![Saving the Project with Algorithms](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2F0RqmGwHLOW360k5vRbEB%2Fimage.png?alt=media\&token=15400ac2-3110-452e-9925-71eacb8cddcd)

### Using Algorithms inside a Notebook

Once the Algorithms are selected while creating a Project, those algorithms will be available for all the Notebooks created inside that project.

* Open the ***Notebook tab*** inside the ***same Project.***&#x20;
* ***Create a new Notebook*** or ***Navigate*****&#x20;to a*****n existing Notebook*** under the same Project.

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2F4cd5p0a3LutC3gskerzl%2Fimage.png?alt=media\&token=04fbf498-4ae8-4132-8fdf-09551f3cfda5)

* You can see ***the selected Algorithms at the project level*** get listed under the right-side panel of the Notebook.

![Accessing the selected Algorithms inside a Notebook](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2F7m18y6eT9AU1DJD5We67%2Fimage.png?alt=media\&token=8c98d253-469b-4184-80d9-fe539ecf4359)

* Add a code cell with the dataset information.
* Define the ***Dataframe*** using another code cell.  &#x20;

![Code cells with Dataset and Data frames](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FasCrxBlQmXPccTiFg3En%2Fimage.png?alt=media\&token=d0127d8a-11b3-4c9f-871c-52d49c1b201c)

{% hint style="info" %} <mark style="color:green;">Please Note:</mark> You can run the cell containing the data frame details to see the data output below:

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FEMFdBLkWCyYt5sEnJrFA%2Fimage.png?alt=media\&token=6a68ede5-5b0d-4f04-8740-5dd99b9fa31e)

{% endhint %}

* Add another code cell below.
* Select an algorithm type by using the checkbox.
* You will get the algorithm script pasted in the intended code cell. &#x20;

![Default script gets added to the Code cell based on the selected Algorithm type](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FcgA6vXwiqGY7RrjL1EXa%2Fimage.png?alt=media\&token=ee917ff7-272b-4634-a156-26d0e32bdb94)

* Specify train and test data.
* Run the cell.     &#x20;

![Specifying the train and test data](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FCAGYQIX0TkOhehjWOeH8%2Fimage.png?alt=media\&token=5f173e5b-be47-4bcb-aebe-624b43c526a7)

* You can see the data output below.

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2F91pcjGPT8Yo7Gg2SZ0yK%2Fimage.png?alt=media\&token=cec0152c-b3ba-4db5-8deb-335eaabef1c1)

* Add a new code cell below.
* Click the ***Save Model*** option.
* Specify the model name and model type in the auto generated code.
* Run the cell.

![Saving the Algorithm based model](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FfQQxoftV52tzEHPoqmIQ%2Fimage.png?alt=media\&token=e44b3834-d1de-4671-9225-f3af3fa65454)

* The model gets saved and lists under the Models tab (The model will list under the ***Unregistered*** models as it is not registered yet).

![The saved model](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FoTYUr37o6mW9WxjVbKr4%2Fimage.png?alt=media\&token=c3ca951c-9f7f-4f19-acde-c79fe5513916)

* Add new code cell.
* ***Load the model*** in the cell by clicking the checkbox given next to the model.

![The saved model gets loaded in the new cell](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FHrdyHzxQBzi5z2oNSN9p%2Fimage.png?alt=media\&token=2ab73dcc-94f1-444e-bff6-3ff86f0f294b)

* Specify the model as the loaded model and model type for the loaded model.
* Run the cell.

![Specifying the model and model type for a loaded model](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2F31yztfTVPJ9vyaKpzj6B%2Fimage.png?alt=media\&token=504299ef-32fc-446d-b7c0-b102d9a7ebcb)

* The data output gets displayed below.

![Output data after running the loaded model](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FeNS8nzHubtQ9vufMR3i6%2Fimage.png?alt=media\&token=325f9be7-83c3-4be8-9733-f2a7dde4f728)

#### Registering an Algorithm based Model

This section displays the flow on how to register a saved model from a Notebook.

* Click the ***Register*** option for the saved model.

&#x20;     ![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2F3n5Osg6GaFDSHSXLIGv0%2Fimage.png?alt=media\&token=8b1a617b-8973-46cf-b7c5-315820474031)

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

&#x20;      ![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2F7D5GlzlHHnrVUtd7tt4T%2Fimage.png?alt=media\&token=97148b8a-3031-4f7b-bcc0-1525b5e54bcb)

* A confirmation message appears to inform about the completion of the model registration action.

![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FkUNgQvMVRF8tqMWWIYiA%2Fimage.png?alt=media\&token=5cae51a0-908e-43b1-95f6-8208bc94a33e)

* The concerned model appears under the ***Registered*** model list.

&#x20;     ![](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2FYUkNuTY1VtCEw29JwjwG%2Fimage.png?alt=media\&token=cb01e185-7407-4a98-a8df-bb620c60ca6e)

* Open a Pipeline using the ***Data Pipeline module*** that contains the ***DS Lab Model Runner component***.
* You can see the same model (which was registered from the DS Lab module) listing under the ***Meta Information*** tab of the ***DS Lab Model Runner*** component.

&#x20;    &#x20;

![Accessing the same registered model under the Data Pipeline module](https://972575688-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRYq1HgffNfbnIMWPu1D5%2Fuploads%2F6WvWcSgjwSwNUssZchoU%2Fimage.png?alt=media\&token=5e5919c0-f9bb-4990-ac72-742f2e3604d8)

{% hint style="info" %} <mark style="color:green;">Please Note</mark>: The model based on an Algorithm script can be registered as an API service. You can refer to the [*<mark style="color:blue;">**Publish a Model as an API Service**</mark>*](https://docs.bdb.ai/bdb-documentation/data-science-lab/various-tabs-to-work-with/model/register-model-as-an-api-service) section for more details.
{% endhint %}
