DAP Lab Manual (1)
DAP Lab Manual (1)
YOGEESH S 1
DATA ANALYTICS LAB WITH MINI-PROJECT 22MCAL36
YOGEESH S 2
DATA ANALYTICS LAB WITH MINI-PROJECT 22MCAL36
class B(A):
def __init__(self,y):
self._y = y
def __add__(self,other):
return self._y + other._x
def display(self):
print(f"x = {self._x} y = {self._y}")
obj1 = B(5)
obj2 = B(6)
obj1.display()
obj2.display()
print(obj2 + obj1)
Output
x = 5 y = 5
x = 5 y = 6
11
YOGEESH S 3
DATA ANALYTICS LAB WITH MINI-PROJECT 22MCAL36
import pandas as pd
import numpy as np
# 1. Importing Datasets
df = pd.read_csv('sample_data.csv')
print(df)
0 False
1 False
2 False
3 False
4 False
5 False
6 False
7 False
8 False
9 True
10 True
dtype: bool
YOGEESH S 4
DATA ANALYTICS LAB WITH MINI-PROJECT 22MCAL36
df = df.drop_duplicates()
df
df = df.fillna({'Age':int(np.mean(df['Age']))})
df
YOGEESH S 5
DATA ANALYTICS LAB WITH MINI-PROJECT 22MCAL36
df = df.fillna({'Salary': np.mean(df['Salary'])})
df
YOGEESH S 6
DATA ANALYTICS LAB WITH MINI-PROJECT 22MCAL36
YOGEESH S 7
DATA ANALYTICS LAB WITH MINI-PROJECT 22MCAL36
YOGEESH S 8
DATA ANALYTICS LAB WITH MINI-PROJECT 22MCAL36
YOGEESH S 9
DATA ANALYTICS LAB WITH MINI-PROJECT 22MCAL36
x = np.array([2,4,6,8,10])
y = np.array([3,4,6,10,13])
plt.figure(figsize=(6,4))
plt.plot(x,y)
plt.title('Line Graph')
plt.xlabel('X axis')
plt.ylabel('Y axis')
plt.show()
plt.figure(figsize=(6,4))
plt.scatter(x,y)
plt.title('Scatter Graph')
plt.xlabel('X axis')
plt.ylabel('Y axis')
plt.show()
plt.figure(figsize=(6,4))
plt.bar(x,y)
plt.title('Bar Graph')
plt.xlabel('X axis')
plt.ylabel('Y axis')
plt.show()
plt.figure(figsize=(6,4))
plt.pie(x,labels=['a','b','c','d','e'])
plt.title('Pie Graph')
plt.xlabel('X axis')
plt.ylabel('Y axis')
plt.show()
YOGEESH S 10
DATA ANALYTICS LAB WITH MINI-PROJECT 22MCAL36
YOGEESH S 11
DATA ANALYTICS LAB WITH MINI-PROJECT 22MCAL36
YOGEESH S 12
DATA ANALYTICS LAB WITH MINI-PROJECT 22MCAL36
7. Write a Python program that creates a mxn integer array and Prints its
attributes using matplotlib
import numpy as np
import matplotlib.pyplot as plt
m = 5
n = 7
arr = np.random.randint(100,size=(m,n))
print(arr)
print(arr.shape)
print(arr.size)
print(arr.T)
print(arr.dtype)
print(arr.ndim)
print(arr.itemsize)
print(arr.data)
plt.imshow(arr)
plt.show()
YOGEESH S 13
DATA ANALYTICS LAB WITH MINI-PROJECT 22MCAL36
x = np.array([[1,2],[2,4],[3,6],[4,8],[5,10],[6,12]])
y = np.array([2,4,6,8,10,12])
model = LinearRegression()
model.fit(x,y)
print("Coefficent: ",model.coef_)
print("Intercept: ",model.intercept_)
newdata = np.array([[7,14]])
prediction = model.predict(newdata)
print(prediction)
plt.scatter(x[:,0],y,color='blue')
plt.plot(x[:,0],model.predict(x),color='red')
plt.show()
YOGEESH S 14
DATA ANALYTICS LAB WITH MINI-PROJECT 22MCAL36
x = np.array([[1,2],[2,4],[3,6],[4,8],[5,10],[6,12]])
y = np.array([0,0,0,1,1,1])
model = LogisticRegression()
model.fit(x,y)
print("Coefficent: ",model.coef_)
print("Intercept: ",model.intercept_)
newdata = np.array([[7,14]])
prediction = model.predict(newdata)
print(prediction)
plt.scatter(x[:,0],y,color='blue')
plt.plot(x[:,0],model.predict(x),color='red')
plt.show()
YOGEESH S 15
DATA ANALYTICS LAB WITH MINI-PROJECT 22MCAL36
YOGEESH S 16
DATA ANALYTICS LAB WITH MINI-PROJECT 22MCAL36
YOGEESH S 17
DATA ANALYTICS LAB WITH MINI-PROJECT 22MCAL36
YOGEESH S 18
DATA ANALYTICS LAB WITH MINI-PROJECT 22MCAL36
YOGEESH S 19
DATA ANALYTICS LAB WITH MINI-PROJECT 22MCAL36
YOGEESH S 20