Practical-3:: Practical 3.1 AIM: Installing Anaconda On Windows. 1
Practical-3:: Practical 3.1 AIM: Installing Anaconda On Windows. 1
PRACTICAL-3
Practical 3.1:-
AIM: Installing Anaconda on Windows.
2. Select Windows
3. Download
Download the most recent Python 3 release. At the time of writing, the most recent release
was the Python 3.6 Version. Python 2.7 is legacy Python. For problem solvers, select the
Python 3.6 version. If you are unsure if your computer is running a 64-bit or 32-bit
version of Windows, select 64-bit as 64-bit Windows is most common.
The download is quite large (over 500 MB) so it may take a while to
forAnaconda to download.
Click on install.
Practical 3.2: -
AIM: Working with Jupyter Notebook.
Creating a New Notebook
After the installation of Anaconda is complete, you can go to the Windows startmenu and
select the Jupyter Notebook.
After Opening Jupyter Notebook Click on New button at right top of the screenand select
Python 3.
To open existing notebooks select the notebook file on home screen ofthe Jupyter
notebook.
Google Drive is the default location for many operations in Colab, and you can
always choose it as a destination. When working with Drive, yousee a list of
files similar to those shown in Figure. Toopen a particular file, you click its link
in the dialog box. The file opens in the current tab of your browser.
When working with GitHub, you initially need to provide the location ofthe source
code online, as shown in Figure. The location must point to apublic project; you
can’t use Colab to access private projects.
If you want to use the downloadable source for this book, or any local source for
that matter, you select the Upload tab of the dialog box. In thecenter is a single
button, Choose File. Clicking this button opens the FileOpen dialog box for your
browser.
You locate the file you want to upload, just as you normally would for opening
any file.
The default location for storing your data is Google Drive. When you choose File ⇒
Save, the content you create goes to the root directory of your Google Drive. If you
want to save the content to a different folder, you need to select that folder in
Google Drive (https://drive.google.com/).
Practical 3.3: -
AIM:Performing Common Tasks
The first cell that Colab creates for you is a code cell. The code you create in Colab
uses all the same features that you find in Notebook. However, off to the side of
the cell, you see a menu of extras that you canuse with Colab that aren’t present in
Notebook, as shown in Figure.
Link to Cell: Displays a dialog box containing a link you can use to access a
specific cell within the notebook. You can embed this link anywhere on a web page
or within a notebook to allow someone to accessthat specific cell. The person still
sees the entire notebook but doesn’t have to search for the cell you want to discuss.
Clear Output: Removes the output from the cell. You must run the codeagain to
regenerate the output. View Output Fullscreen: Displays the output (not the entire
cell or any other part of the notebook) in full-screenmode on the host device. This
option is useful when displaying a significant amount of content or when a
detailed view of graphics helps explain a topic. Press Esc to exit full-screen mode.
Add a Comment: Creates a comment balloon to the right of the cell. This is not
the same as a code omment, which exists in line with the codebut affects the entire
cell. You can edit, delete, or resolve comments. A resolved comment is one that
receives attention and is no longer applica-ble.
Add a Form: Inserts a form into the cell to the right of the code. You useforms to
provide a graphical input for parameters. Forms don’t appear in Notebook, but
because of how you create them, they won’t prevent you from running the code
in Notebook. You can read more about forms at
https://colab.research.google.com/notebooks/forms.ipynb.
Code cells also tell you about the code and its execution. The little icon next to the
output displays information about the execution when you hover your mouse over it,
as shown in Figure. Clicking the icon clears theoutput. You must run the code again
to regenerate the output.
Text cells work much like Markup cells in Notebook. However, Figure shows that
you receive additional help in formatting the text using a graphical interface. The
markup is the same, but you have the option of allowing the GUI to help you create
the markup. For example, in this case, to create the # sign for a heading, you click
the double T icon that appears first in the list. Clicking the double T icon again
would increasethe header level. To the right, you see how the text will appear in
the notebook.
Notice the menu to the right of the text cell. This menu contains many ofthe
same options that a code cell does. For example, you can create a listof links to
help people access specific parts of your notebook through anindex. Unlike
Notebook, you can’t execute text cells to resolve the markup they contain.
The special cells that Colab provides are variations of the text cell. Thesespecial
cells, which you access using the Insert menu option, make creating the
required cells faster. The following sections describe each ofthese special cell
types.
When you choose Insert ⇒ Section Header Cell, you see a new
cellcreated below the currently selected
cell that has the appropriate header level 1 entry in it. You can increasethe
heading level by clicking
the double T icon. The GUI looks the same as the one in Figure 4-11, soyou have
all the standard
The Table of Contents cell contains a heading in the actual cell that youcan modify
in the same way as any other heading in your notebook. Thetable of contents
appears in the cell output. To update the table of contents, click Refresh to the
right of the cell output. You also have access to all the usual text cell features
when working with a Table of Contents cell.
Editing cells
Both Colab and Notebook have Edit menus that contain the options you except,
such as the ability to cut, copy, and paste cells. The two productshave some
interesting differences. For example, Notebook allows you tosplit and merge cells.
Colab contains an option to show or hide the code as a toggle. These differences
give each product a slightly different flavor but don’t really change your ability to
use it to create and modify Python code.
Moving cells
The same technique you use for moving cells in Notebook also workswith
Colab. The only difference is that Colab relies exclusively on
toolbar buttons, while Notebook also has cell movement options on theEdit menu.
For your to be useful, you need to run it at some point. Previous sections have
mentioned the right-pointing arrow that appears in the current cell. Clicking it
runs just the current cell. Of course, you have other options than clicking the right-
pointing arrow, and all these options appear on theRuntime menu.
Running the current cell: Besides clicking the right-pointing arrow,you can
also choose Runtime⇒ Run the Focused Cell to execute the code in the
current cell.
Running all the cells: In some cases, you want to execute all the code ina notebook.
In this case,choose Runtime ⇒ Run All. Execution starts at the top of the notebook,
in the first cell containing code, and continues tothe last cell that contains code in
the notebook. You can stop execution atany time by choosing Runtime ⇒ Interrupt
Execution.
Practical 3.3 : -
AIM: Defining the code repository
You use folders to hold your code files for a particular project. Theproject for
this book is Rohit. The following steps help you create a new folder for this
book.
You see the Rename Directory dialog box, shown in Figure 3-6.
Notebook asks whether you want to use a new name, as shown in Figure.
This book follows a convention of putting the source code files together
that makes them easy to use. The following steps tell youabout this
convention:
The hash mark (#) creates a heading. A single # creates a first-level heading.
The text that follows contains that actual heading information. Clicking Run
turns the formatted text into a heading, asshown in Figure. Notice that Notebook
automatically creates a new cell for you to use.
Exporting a notebook
It isn’t much fun to create notebooks and keep them all to yourself. Atsome
point, you want to share them with other people. To perform this task, you must
export your notebook from the repository to a file. You can then send the file to
someone else who will import it into his or her repository.The previous section
shows how to create a notebook named Sample. You can open this notebook by
clicking its entry in the repository list. The file reopens so that you can see your
code again. To export this code, choose File ⇒ Download As ⇒ Notebook
(.ipynb). What you see next depends on your browser, but you generally see
some sort of dialog box for saving the notebook as a file. Use the same method
for saving the Notebook file as you use for any other file you save using your
browser.
Removing Notebook
3. Click Delete.
Importing Notebook
To use the source code from this book, you must import the downloaded files
into your repository. The source code comes in an archive file that you extract
to a location on your hard drive. The archive contains a list of .ipynb (IPython
Notebook) files containing the source code. The following steps tell how to
import thes files intoyour repository:
You see the file added to an upload list, as shown in Figure. The file isn’t part of the
repository yet — you’ve simply selected it for upload.
4. Click Upload.
Notebook places the file in the repository so that you can begin usingit.
Practical 3.4:-
AIM: Understanding the following datasets with its code.
This book uses a number of datasets, all of which appear in the Scikit-learn library. These
dataset demonstrate various ways in which you can interact with data, and you use them in
the examples to perform a variety of tasks. The following list provides a quick overview of
the function used to import each of the datasets into your Python code:
Load and return the iris dataset (classification).The iris dataset is a classic
and very easy multi-class classification dataset.