Python-for-Machine-Learning/C2/Setup-Python-environment-for-Machine-Learning/English

From Script | Spoken-Tutorial
Jump to: navigation, search


Visual Cue Narration
Show Slide Welcome to the Spoken Tutorial on Setup Python Environment for Machine Learning.
Show slide:

Learning Objectives

In this tutorial, we will learn how to
  • Install Miniconda Distribution in Linux
  • Create a Machine Learning environment
  • Install necessary Python libraries required for Machine Learning

We will also learn about,

  • Installing Jupyter Notebook
  • Basics of Jupyter Notebook
Show slide:

System Requirements

To record this tutorial, I am using
  • Ubuntu Linux OS version 24.04
Show slide:

Prerequisite

To follow this tutorial,
  • The learner must have basic knowledge of using Linux Terminal and Python
  • For pre-requisite Linux and Python tutorials, please visit this website.
Show slide:

Code files

  • The files used in this tutorial are provided in the Code files link.
  • Please download and extract the files.
  • Make a copy and then use them while practicing.
Only narration Let’s see how to install Miniconda Distribution in Linux.
Go to the Downloads folder. I have the necessary files required for this tutorial in the Downloads folder.

These are available in the code files link of this tutorial.

Point to the Miniconda_installation.txt file

Point to the MLpackages.txt file

Open the file

I have created a Miniconda_installation.txt file, which has the command to install Miniconda.

I have also created MLpackages.txt file.

This file contains the libraries used in the Python for Machine Learning series.

Press Ctrl, Alt and T keys

Type cd Downloads

Press Enter

Open the terminal window by pressing Ctrl, Alt and T keys together.

Type cd space Downloads to navigate to the Downloads folder and press Enter.

Remember to press the Enter key after each command in the terminal.

Type cat Miniconda_installation.txt

Highlight:

Press Right Click >> Select Copy

Press Right Click >> Select Paste

Type cat space Miniconda underscore installation dot txt to display the contents in the file.

Select this entire command.


Press Right Click on the terminal and select "Copy" from the context menu.

Now, press Right Click on the terminal and select "Paste" from the context menu.

Press Enter Press Enter to execute the command.
Only narration

Type: bash Miniconda3-latest-Linux-x86_64.sh

Highlight: Welcome to Miniconda3

Press Enter

Hold the Enter

You will see the line Welcome to Miniconda3.

Press Enter

Hold the Enter key until you see Please answer 'yes' or 'no':' on the terminal.

Highlight:

Please answer 'yes' or 'no':'

Type Yes and Enter

When you see the prompt to proceed, type yes and Enter.
Highlight: Miniconda3 will now be installed into this location:

Type yes and Enter

Highlight: Thank you for installing Miniconda3!

Press Enter to execute the command.

Then type yes and Enter.

We have successfully installed the Miniconda.

Only narration Now, close the terminal to incorporate the installation process and get completed.
Press Ctrl, Alt and T keys

Highlight: (base)

Now, once again open the terminal.

The word ‘base’ in the command prompt shows that we have installed Miniconda successfully.

Only narration

Type: conda config --set auto_activate_base false

If we don’t want to get the (base) environment in the terminal as a default

Type the command.

Type: conda create --name ml python=3.9

Press y and Enter

Let us create a python environment for Machine Learning.

Now type conda space create space Hyphen Hyphen name space ml space python equal to 3.9

Press y and Enter to Proceed further.

Type: conda activate ml

Highlight: (ml)

Type conda space activate space ml to activate the Machine Learning environment.

ml shows that our machine learning environment is activated.

Only narration

Type cd Downloads

Let us install the python libraries required for this Python for Machine Learning series.

Go to the Downloads directory by typing cd space Downloads.

Type pip install -r MLpackages.txt. Now type, pip space install space hyphen r space MLpackages dot txt.

This will install all the necessary libraries.

Type: conda install jupyter

Press y and Enter

Then type conda space install space jupyter to install the Jupyter Notebook.

Press y and Enter to Proceed.

Type: conda install nb_conda_kernels

Press y and Enter

Type conda space install space nb underscore conda underscore kernels to install the conda kernels.

Press y and Enter to proceed.

Only narration As we can see the commands get executed successfully.

Our Python setup and installation of Jupyter Notebook is completed.

Now, let us look at the basics of Jupyter Notebook.

Type jupyter notebook

Press Enter

Let us open the Jupyter Notebook.

Type, jupyter space notebook.

Press Enter.

Show Jupyter Notebook Home page:

Click New

Go to New >> Python [conda env:ml]

We see the Jupyter Notebook Home page.

To create a new Jupyter Notebook, click on the button New in the top right corner.

Select Python [conda env:ml] from the list.

Only narration The Untitled.ipynb file gets opened.

So, let us first change the Jupyter Notebook file name.

Click Untitled

Show Rename Notebook

Click Rename

Click on Untitled.

You can see the Rename Notebook option.

Enter “Sample” and click on the Rename button.

Only narration

Type print(‘Hello World’)

Press Shift + Enter

Highlight: Hello world

Let us start with executing a python code in the Jupyter Notebook cell.

Click onto the first cell and Press Enter.

Now, Type print within parentheses within quotes Hello World.

Press Shift + Enter to execute the cell and create a new cell

We get the output as Hello world.

Only narration

Type import pandas as pd

Press Shift + Enter

Let us see how to import the Wine.csv dataset and display the first five rows.

For that we will first import the pandas library.

Type import space pandas space as space pd

Press Shift + Enter to execute the cell and create a new cell.

Type df=pd.read_csv('/home/karthik-sankhar/Downloads/Wine.csv')

Press Shift + Enter

Type df.head()

Press Shift + Enter

Type df equals pd dot read underscore csv open parenthesis Wine.csv.

Press Shift + Enter.

Type df dot head parentheses.

Press Shift + Enter to execute the cell.

It will display the first five rows from Wine.csv

Only narration

Press Ctrl + S

Now let us see how to save the Jupyter Notebook.

Press Ctrl + S to save the changes.

Only narration

Go to File >> Click Close and Halt

To close the Jupyter Notebook file

Go to File and Click Close and Shutdown Notebook.

Type conda deactivate

Patch video n audio

Go back to the terminal window.

To deactivate an active environment

Press Ctrl and c keys together.

Type y to proceed.

Then, type conda deactivate.

Only narration Please refer to the Installation sheet of this series for “Setup Python Environment for Machine Learning in Windows 11.”
Show slide:

Summary

In this tutorial, we have learnt to
  • Install Miniconda Distribution in Linux.
  • Create a Machine Learning environment
  • Install necessary Python libraries required for Machine Learning.

We have also learnt about

  • Install Jupyter Notebook
  • Basics of Jupyter Notebook
Show Slide:

FOSSEE Forum

For any general or technical questions on Python for Machine Learning, visit the FOSSEE forum and post your questions.
Show slide:

Thank You

This is Anvita Thadavoose Manjummel, from

FOSSEE Summer Fellowship 2025, IIT Bombay signing off.

Thanks for joining.

Contributors and Content Editors

Madhurig, Nirmala Venkat