DS Lab Manual Lovesh 1
DS Lab Manual Lovesh 1
Practical-1
Aim: Find Mean, Median, Mode, Standard Deviation,
Skewness and Kurtosis for above student data in excel.
Solution:
pg.
200160116031
Practical-2
Aim: Find Mean, Median, Mode, Standard Deviation,
Skewness and Kurtosis for above student data in Python.
Solution:
Code-
import numpy as np
from scipy import stats as st
from scipy.stats import skew
from scipy.stats import kurtosis
Lovesh = [78, 67, 76, 91]
print("\nmean of Lovesh : ", np.mean(Lovesh))
print("\nmedian of Lovesh : ", np.median(Lovesh))
data = np.array([78, 67, 76, 91])
print("\nMode of Lovesh :", st.mode(data))
print("\nSkewness of Lovesh :")
print(skew(Lovesh, bias=False))
Output-
pg.
200160116031
Practical-3
Aim: Draw the following graphs:
Plot the graph showing result of student in each
semester.
Plot the graph showing the geographical location of
students.
Plot the graph showing number of male and female
students.
Solution:
Code-
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import scipy as sp
data = { 'Sem1' : 7.4, 'Sem2': 5.9, 'Sem3' : 8.3, 'Sem4' : 8.5 }
Sem = list(data.keys())
Result = list(data.values())
fig = plt.figure(figsize = (10,5))
plt.bar(Sem, Result, color ='maroon', width = 0.4 )
plt.xlabel("Semester")
plt.ylabel("Result of student in sem")
plt.title("Result of stuent in 4 semesters")
plt.show()
pg.
200160116031
Output-
pg.
200160116031
Output-
pg.
200160116031
pg.
200160116031
Practical-4
Aim: Implement a method to treat missing value for gender
and missing value for marks.
Solution-
Code-
pg.
200160116031
Practical-5
Aim: Implement linear regression to predict the 5th semester
result of student.
Implement logistic regression and decision tree to classify the
student as average or clever.
Solution-
Code-
import numpy as np
import pandas as pd
import plotly.express as px
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
data=pd.read_csv("https://raw.githubusercontent.com/ama
nkharwal/Website-data/master/Student_Marks.csv")
print(data.head(10))
print(data.isnull().sum())
pg.
200160116031
data["number_courses"].value_counts()
pg.
200160116031
correlation = data.corr()
print(correlation["Marks"].sort_values(ascending=False))
x = np.array(data[["time_study", "number_courses"]])
y = np.array(data["Marks"])
xtrain, xtest, ytrain, ytest = train_test_split(x, y, test_size=0.2,
random_state=42)
model = LinearRegression()
model.fit(xtrain, ytrain)
model.score(xtest, ytest)
# Features = [["time_study", "number_courses"]]
features = np.array([[4.508, 3]])
model.predict(features)
pg.
200160116031
pg.
200160116031
pg.
200160116031
pg.
200160116031
Output:
# Flask-Netflix-Recommendation-System:
A flask web-app which can be used to get recommendations for a
tv-show/movie, the app recommends a list of media according to
the input.
pg.
200160116031
Conclusion:
Netflix recommendation system is a real time application built using
python which helps user recommend and find movies which have
common subject and user’s interest.
pg.