Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

PDS Labmanualword

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 32

Ahmedabad Institute of Technology

CE Department

Python for Data Science


(3150713)

Laboratory Manual

NAME

ENROLLMENT NUMBER

BATCH

YEAR

SUBJECT COORDINATOR SUBJECT MEMBER


Dr. Dushyantsinh Rathod Prof. Archana Jethava
Ahmedabad Institute of Technology
CE Department

CERTIFICATE

This is to certify that Mr.\Ms._________________________________Of


EnrollmentNo ___________________________has Satisfactorily completed the
course in ____________________________________as by the Gujarat Technological
University for ____ Year (B.E.) semester___ of Computer Engineering in the
Academic year ______.

Date of Submission:-

Faculty Name : Dr. Dushyantsinh


Rathod

Signature (Head Of Department)


INDEX
Sr. TITLE PAGE DATE MARK SIGN
No. NO.

1 To study about tools and technology in


Python
2
1) Write a program to perform different
Arithmetic operations in python.
2) Write a python program to check
whether the given number is even odd

3 Implement Python Programs for Looping


And control structure.
1) Loping
2) Structure

4 Write a python program to find following


pattern
1) Left Triangle Star Pattern In Python
*
**
** *
** * *
** * * *
2)
** * * *
** * *
** *
**
*
5
Strings:
1) Write a python program to find the
length of a given string and reverse
same.
2) Write a python program to check
whether the string is in uppercase,
lowercase and capitalized first letter
or not
6 Pandas:
1) Write a Program to perform how
to Read .csv dataset using pandas.
2) Write a Program to perform how
to display data from .csv dataset
using pandas.

7 Pandas:
1) Write a Program to perform how
to display.csv dataset structure
using pandas.
2) Write a Program to perform how
to display top 5 data from .csv
datas using pandas. e
8 Pandas:
1) Write a Program to perform Data
Pre-processing on .csv dataset
using pandas
2) Write a Program to perform Train
And Test Split on .csv dataset
using pandas
9 Pandas:
Write a Program to Implement Decision
Tree , Random Forest, NB ML models
on .csv dataset using pandas

1 Matplotlib:
0 Implement scatter plot,boxplot and
histogram using pyplot library
EXPERIMENT NO: 1 DATE: / /

AIM: Study about various machine learning tools

Objective: To Learn about Supervised Learning techniques

Machine Learning Real Examples


Given below are some real examples of ML:

Example 1:
If you have used Netflix, then you must know that it recommends you some movies or shows for
watching based on what you have watched earlier. Machine Learning is used for this recommendation and to
select the data which matches your choice. It uses the earlier data.

Example 2:
The second example would be Facebook.

When you upload a photo on Facebook, it can recognize a person in that photo and suggest mutual
friends. ML is used for these predictions. It uses data like your friend-list, photos available etc. and it makes
predictions based on that.

Example 3:
The third example is Software, which shows how you will look when you get older. This image
processing also uses machine learning.

All these are some examples that help us to understand how machine learning is used. ML is similar
to AI up to some extent, however, there is a difference between the two. It is related to data mining.

How does Machine Learning Help us? It helps


through powerful processing.

With the help of machine learning, systems make better decisions, at a high speed and most of the
times they are accurate. Using this technique is inexpensive and it can analyze large and complex data sets.

Most Popular Machine Learning Software Tools


1. Scikit-learn
Scikit-learn is for machine learning development in python. It provides a library for the Python
programming language.
Features:
● It helps in data mining and data analysis.

2100201070002 PDS(3150713) Page No : 1


● It provides models and algorithms for Classification, Regression, Clustering,
Dimensional reduction, Model selection, and Pre-processing.
Pros:
● Easily understandable documentation is provided.
● Parameters for any specific algorithm can be changed while calling objects.

2. PyTorch
PyTorch is a Torch based, Python machine learning library. The torch is a Lua based computing
framework, scripting language, and machine learning library.

Features:
● It helps in building neural networks through the Autograd Module.
● It provides a variety of optimization algorithms for building neural networks.
● PyTorch can be used on cloud platforms.
● It provides distributed training, various tools, and libraries.
Pros:
● It helps in creating computational graphs.
● Ease of use because of the hybrid front-end.

3.TensorFlow
TensorFlow provides a JavaScript library which helps in machine learning. APIs will help you to
build and train the models.

Features:
● Helps in training and building your models.
● You can run your existing models with the help of TensorFlow.js which is a model
converter.
● It helps in the neural network.
Pros:
● You can use it in two ways, i.e. by script tags or by installing through NPM.
● It can even help for human pose estimation.
Cons:
● It is difficult to learn.

4.Weka
These machine learning algorithms help in data mining.

Features:
● Data preparation
● Classification

2100201070002 PDS(3150713) Page No : 2


● Regression
● Clustering

● Visualization and
● Association rules mining.

Pros:
● Provides online courses for training.
● Easy to understand algorithms.
● It is good for students as well.
Cons:
● Not much documentation and online support are available.

5.KNIME
KNIME is a tool for data analytics, reporting and integration platform. Using the data pipelining
concept, it combines different components for machine learning and data mining.

Features:
● It can integrate the code of programming languages like C, C++, R, Python, Java,
JavaScript etc.
● It can be used for business intelligence, financial data analysis, and CRM.
Pros:
● It can work as a SAS alternative.
● It is easy to deploy and install.
● Easy to learn.
Cons:
● Difficult to build complicated models.
● Limited visualization and exporting capabilities.

6.Colab
Google Colab is a cloud service which supports Python. It will help you in building the machine
learning applications using the libraries of PyTorch, Keras, TensorFlow, and OpenCV

Features:
● It helps in machine learning education.
● Assists in machine learning research.
Pros:
● You can use it from your google drive.

2100201070002 PDS(3150713) Page No : 3


7.Keras.io
Keras is an API for neural networks. It helps in doing quick research and is written in Python.

Features:
● It can be used for easy and fast prototyping.
● It supports convolution networks.
● It assists recurrent networks.
● It supports a combination of two networks.
● It can be run on the CPU and GPU.
Pros:
● User-friendly
● Modular ● Extensible
Cons:
● In order to use Keras, you must need TensorFlow, Theano, or CNTK.

8.Rapid Miner
Rapid Miner provides a platform for machine learning, deep learning, data preparation, text
mining, and predictive analytics. It can be used for research, education and application development.

Features:
● Through GUI, it helps in designing and implementing analytical workflows.
● It helps with data preparation.
● Result Visualization.
● Model validation and optimization.
Pros:
● Extensible through plugins.
● Easy to use.
● No programming skills are required.
Cons:
● The tool is costly.

EVALUATION:

2100201070002 PDS(3150713) Page No : 4


Involvement Timely Total (10)
Understanding / Completion
(4)
Problem solving (3)
(3)

Signature

VIVA-VOCE QUESTIONS :
1.Is python programming language or scripting language? justify your statement.
2.List the different modes of running python scripts? 3.Mention five benefits of using
Python?
4.List the differences between compiler and interpreter? 5.What are the
supported data types in Python?
6.What is the command line argument?
7.How to represent complex numbers in python?
8.What is the importance of type conversion?
9.How to determine the type of a variable in Python? 10.How to assign multiple values to
variables in a single line in python? 11.How many reserved keywords are there in
python? 12.Write a print statement to display the output Hello”World”Everyone?
13.How to write multiline statements in python?
14.What is an indentation error with an example?

EXPERIMENT NO: 2 DATE: / /

AIM:

2100201070002 PDS(3150713) Page No : 5


1. Write a program to perform different Arithmetic operations in python.

Objective:
∙ To study Python on different platforms. ∙

To study and implement python data types

Program :

x = 9 y = 13 print("The given two integers are: {0} ,

{1}".format(x,y)) print("addi on of two numbers is")

print(x+y) print("substrac on of two numbers is")

print(x-y)

print("mul plica on of two numbers is")

print(x*y) print("division of two

numbers is") print(x/y)

print("modulo of two numbers is")

print(x%y) print("floor of two

numbers is") print(x//y)

Output :

2100201070002 PDS(3150713) Page No : 6


2100201070002 PDS(3150713) Page No : 7
2. Write a python program to check whether the given number is even or odd Objective:
∙ To study Python on different platforms.

∙ To study and implement python data types

Program :

x = int(input("Enter a number = "))


if x%2==0:
print("{0} is even number".format(x))
else:
print("{0} is odd number".format(x))

Output :

EVALUATION:
Involvement(4) Timely
Completion Total (10)
Understanding
(3)
/ Problem

solving(3)

Signature

2100201070002 PDS(3150713) Page No : 8


EXPERIMENT NO: 3 DATE: / /

TITLE:

3.1 To Implement Python Programs for Looping and control structure.

OBJECTIVES: After completing study of this practical the students will be familiarized with...
➢ Concept of Branching Program.
➢ Concept of Iteration.

The Python for loop is an iterator based for loop. It steps through the items of lists, tuples, strings, the keys of
dictionaries and other iterables. The Python for loop starts with the keyword "for" followed by an arbitrary
variable name, which will hold the values of the following sequence object. for <variable> in <sequence>:
<statements>
else:
<statements>

Program : For

loop:

string = "RIDDH"

for s in string:

if s == "II":

print("if block")

else:

print(s)

While loop:

2100201070002 PDS(3150713) Page No : 9


a=0
b=10

if a < b:

while a < b:

print(a) a=a + 1

else :

print("please enter value of


a less than b")

Output:

For loop:
R
If block
D
D
H

While loop:
0
1
2
3
4
5
6
7
8
9

2100201070002 PDS(3150713) Page No : 10


3.2 To Implement Python Programs for control structure.

if Statements
The if statement is arguably the most used statement to control loops. For instance:

Program :

a=5

b=2

print("the value of a is :",a)

print("the value of b is :",b)

if a > b :

print("a is greater")

else :

print("b is greater")

Output:

EVALUATION:

2100201070002 PDS(3150713) Page No : 11


Involvement(4) Timely
Completion Total (10)
Understanding
(3)
/ Problem

solving(3)

Signature

EXPERIMENT NO: 4 DATE: / /

2100201070002 PDS(3150713) Page No : 12


TITLE: To Implement Python Programs to find the following pattern.

1. Left Triangle star pattern:

● The left triangle star pattern is a star pattern in the shape of a triangle. It is quite easy to create
it.
● Steps to create a left triangle star pattern:
o Run a nested for loop where internal loop will run for number of
times external loop has run.
o Print stars in each iteration of the internal loop. o Print a new line at
the end of the internal loop. o
4.1 Write a python program to find following pattern

1) Left Triangle Star Pattern In Python


*
**
* **
* ***
* ****

Program :

n=5 for i in
range(1,n+1): for k
in range (1,i+1):
print ("*", end="")
print()

Output:

2. Right triangle star pattern:

2100201070002 PDS(3150713) Page No : 13


● The right triangle star pattern is a star pattern in the shape of a triangle as shown above. It is similar to the
left triangle star pattern but you will have to deal with spaces.

● Steps to create a right triangle star pattern:

o Create a loop that will run for the number of rows (size).
o Inside this we will have 2 loops, first will print spaces and second will print stars. (look at pattern above)
o Spaces will be printed for size - i times and stars will be printed for i times. Where i is the current row.
o Print a new line at the end of both internal loops.

4.2 Write a python program to find following pattern

1) Left Triangle Star Pattern In Python

*
**
***
****
*****

Program :

size 5 for i in

range(size):

for j in range(1, size -

i) for k in range(0, i +

1):

print("", end="") print("*", end="")

print()

2100201070002 PDS(3150713) Page No : 14


Output:

2100201070002 PDS(3150713) Page No : 15


EVALUATION:
Involvement(4) Timely
Completion Total (10)
Understanding
(3)
/ Problem

solving(3)

Signature

2100201070002 PDS(3150713) Page No : 16


EXPERIMENT NO: 5 DATE: / /

TITLE: To Implement Python Programs Strings


OBJECTIVES: After completing study of this practical the students will be familiarized with...
➢ Concept of Strings
➢ Methods that can be implemented on strings.

In Python, Strings are arrays of bytes representing Unicode characters.


Python does not have a character data type, a single character is simply a string with a length of 1.Square
brackets can be used to access elements of the string.
Strings in Python can be created using single quotes or double quotes or even triple quotes.

2100201070002 PDS(3150713) Page No : 17


2100201070002 PDS(3150713) Page No : 18
2100201070002 PDS(3150713) Page No : 19
1. Write a python program to find the length of a given string and reverse the same.

Program : def

reverse(s):

str = ""

for i in s:

str = i + str

return str

s = "Riddh"

print("The original string is : ", end="")

print(s)

length = len(s)

print("The Length of the string",s,"is",length)

print("The reversed string(using loops) is : ", end="")

print(reverse(s))

Output:

2100201070002 PDS(3150713) Page No : 20


2. Write a python program to check whether the string is in uppercase,lowercase and capitalized first letter or not

Program :

def check_string_case(string):
if string.isupper():
return f"'{string}' is in
uppercase."
elif string.islower():
return f"'{string}' is in
lowercase."
elif string.is tle():
return f"'{string}' has a
capitalized first le er."
else:
return f"'{string}' has
mixed case."

# Input string input_string =


input_string = input("Enter a
string: ")
result =
check_string_case(input_strin
g)
print(result)

Output:

EVALUATION:

2100201070002 PDS(3150713) Page No : 21


Involvement(4) Understanding
/ Problem Total (10)
Timely
Completion
(3)

solving(3)

Signature

EXPERIMENT NO: 6 DATE: / /

TITLE: To Implement Python Programs for reading .CSV Files


OBJECTIVES: After completing study of this practical the students will be familiarized with...
➢ Different methods for reading .CSV Files

2100201070002 PDS(3150713) Page No : 22


Using the Pandas Library
Here we’re importing Pandas, a Python library used to conduct data manipulation and analysis. It contains the
.read_csv() method we need in order to read our csv file.

Data Set

1. Write a Program to perform how to display.csv dataset structure using pandas.

Program :

2100201070002 PDS(3150713) Page No : 23


Output:

2. Write a Program to perform how to display top 5 data from .csv dataset using pandas.

Program :

Output:

EVALUATION:
Involvement(4) Timely
Understanding Total (10)
Completion
/ Problem
(3)

solving(3)

Signature

EXPERIMENT NO: 7 DATE: / /


TITLE:TITLE:Program to perform different methods of Pandas on .CSV dataset.

1.Write a Program to perform how to display.csv dataset structure using pandas.

2100201070002 PDS(3150713) Page No : 24


Program :

Output:

2. Write a Program to perform how to display top 5 data from .csv dataset using pandas.

Program :

Output:

EVALUATION:
Involvement(4) Timely
Completion Total (10)
Understanding
(3)
/ Problem

solving(3)

Signature

EXPERIMENT NO:8 DATE: / /

TITLE: Implement functions to perform conditional operations on data frames using pandas.
1) Write a Program to perform Data Pre-processing on .csv dataset using pandas

Program :

2100201070002 PDS(3150713) Page No : 25


Output:

2) Write a Program to perform Train And Test Split on .csv dataset using pandas

Program :

Output:

EVALUATION:
Involvement(4) Timely
Completion Total (10)
Understanding
(3)
/ Problem

solving(3)

Signature

EXPERIMENT NO: 9 DATE: / /

TITLE: Implement scatter plot,boxplot and histogram using pyplot library

2100201070002 PDS(3150713) Page No : 26


1. Write a Program to Implement Decision Tree , Random Forest, NB ML models on .csv dataset using
pandas

Program :

Output:

EVALUATION:
Involvement(4) Understanding
/ Problem Total (10)
Timely
Completion
(3)
solving(3)

Signature
EXPERIMENT NO: 10 DATE: / /
TITLE: Creating dataframes from pandas for csv and image files Program :

1. Implement scatter plot,boxplot and histogram using pyplot library

Program :

Output:

2100201070002 PDS(3150713) Page No : 27


2. histogram using pyplot library

Program :

Output:

EVALUATION:
Involvement(4) Timely
Completion Total (10)
Understanding
(3)
/ Problem

solving(3)

Signature

2100201070002 PDS(3150713) Page No : 28

You might also like