0% found this document useful (0 votes)
43 views15 pages

DS Lab Manual Lovesh 1

The document describes several Python code implementations for data analysis and machine learning algorithms. It includes code to calculate statistical measures like mean, median, mode for student data. Graphs are plotted to visualize student results, gender distribution, and geographic locations. Linear regression and logistic regression models are built to predict exam scores and classify students. The last section discusses a content-based recommendation system project in Flask for Netflix movies.

Uploaded by

Rathod Manthan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views15 pages

DS Lab Manual Lovesh 1

The document describes several Python code implementations for data analysis and machine learning algorithms. It includes code to calculate statistical measures like mean, median, mode for student data. Graphs are plotted to visualize student results, gender distribution, and geographic locations. Linear regression and logistic regression models are built to predict exam scores and classify students. The last section discusses a content-based recommendation system project in Flask for Netflix movies.

Uploaded by

Rathod Manthan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

200160116031

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-

 Plot the graph showing the geographical location of


students.
Code-
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import scipy as sp
y = np.array([75, 12.5, 12.5, 0])
mycitys = ["Vapi" , "Navsari", "Surat", "Ahmedabad",]
fig = plt.figure(figsize = (10,7))
plt.pie(y, labels = mycitys )
plt.show()

pg.
200160116031

Output-

 Plot the graph showing number of male and female


students.
Code-
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import scipy as sp
data = { 'Male' : 4, 'Female' : 1}
Gender = list(data.keys())
Result = list(data.values())
fig = plt.figure(figsize = (10,5))

pg.
200160116031

plt.bar(Gender, Result, color ='maroon', width = 0.3 )


plt.xlabel("Gender in male and female")
plt.ylabel("No of male and female")
plt.title("plotting map on male and female")
plt.show()
Output-

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()

figure = px.scatter(data_frame=data, x = "number_courses",


y = "Marks", size = "time_study", title="Number of Courses
and Marks Scored")
figure.show()

figure = px.scatter(data_frame=data, x = "time_study", y =


"Marks", size = "number_courses", title="Time Spent and
Marks Scored", trendline="ols")
figure.show()

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

Project: Real time application building using data science.


Project - “ Netflix Recommendation system “
Code-

pg.
200160116031

 Content based NRC:

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.

# Screenshot 1 : Main Page:


 Here the user can enter their movie of choice, for example I
have entered La Casa De Papel a Spanish Netflix original show.

pg.
200160116031

# Screenshot 2 : Recommendation Page:


 Here the user will get recommendations, for example I recieved
Elite(another spanish Netflix original) as my top
recommendation.

 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.

 By searching one movie this system shows recommendation list of


similar movies and web series to user

pg.

You might also like