Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
PRACTICAL: 01
AIM: Dealing With Data Using Stats Numpy and Pandas Library.
import statistics as st import numpy as np import pandas
as pd age = [10,20,30,40,50]
a_age = st.mean(age) print("Mean of age:",a_age)
Mean of age: 30
a3 = np.array([[10,20,30],[40,50,60],[60,70,80]])
print(a3) print(a3.ndim) print(a3.dtype)
print(a3.itemsize) print(a3.shape) print(a3.size)
[[10 20 30]
[40 50 60]
[60 70 80]]
2 int64 8
(3, 3)
9
a4 = np.zeros((5,5)) print(a4)
[[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0.]]
a5 = np.zeros((0,3)) print(a5)
[]
a6 = np.arange(2,101,2) a6
array([ 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34,
36, 38, 40, 42, 44, 46, 48, 50, 52,
54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78,
80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100])
a7 = np.reshape(a6,(10,5)) a7
array([[ 2, 4, 6, 8, 10], [ 12, 14, 16, 18, 20],
[ 22, 24, 26, 28, 30],
[ 32, 34, 36, 38, 40],
[ 42, 44, 46, 48, 50],
[ 52, 54, 56, 58, 60],
[ 62, 64, 66, 68, 70],
[ 72, 74, 76, 78, 80],
[ 82, 84, 86, 88, 90],
[ 92, 94, 96, 98, 100]])
a8 = np.reshape(a6,(2,5,5)) a8
array([[[ 2, 4, 6, 8, 10], [ 12, 14, 16, 18, 20],
[ 22, 24, 26, 28, 30],
[ 32, 34, 36, 38, 40],
[ 42, 44, 46, 48, 50]],
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) Page| 1
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
[[ 52, 54, 56, 58, 60], [ 62, 64, 66, 68,
70],
[ 72, 74, 76, 78, 80],
[ 82, 84, 86, 88, 90],
[ 92, 94, 96, 98, 100]]])
print(a6) print(a6[:5]) print(a6[::5]) print(a6[2:5])
print(a6[0:-1])
[ 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36
38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72
74 76 78 80 82 84 86 88 90 92 94 96 98 100]
[ 2 4 6 8 10]
[ 2 12 22 32 42 52 62 72 82 92]
[ 6 8 10]
[ 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48
50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96
98]
my_dictionary = {
"id":[101,103],
"name":["Nandani","Rathod"],
} print(my_dictionary) dtfr = pd.DataFrame(my_dictionary) dtfr
{'id': [101, 103], 'name': ['Nandani', 'Rathod']} id name
0 101 Nandani
1 103 Rathod
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) Page| 2
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
PRACTICAL: 02
AIM: Data Analysis and Visualization on Diwali Sales Database.
import numpy as np import pandas as
pd import seaborn as sns import
matplotlib.pyplot as plt
df = pd.read_csv('/content/Diwali Sales Data.csv', encoding='unicode_escape')
df.shape
(11251, 15)
df.head()
Ag Ag Marital_Stat
User_ICust_naProduct_Gend Gro Stat
0 1002903 Sanskriti P00125942F 26-35 28 0 Maharashtra
1 1000732 Kartik P00110942 F 26-35 35 1 Andhra Pradesh
2 1001990 Bindu P00118542 F 26-35 35 1 Uttar Pradesh
3 1001425 Sudevi P00237842M 0-17 16 0 Karnataka
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 11251 entries, 0 to 11250 Data
columns (total 15 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 User_ID 11251 non-null int64
1 Cust_name 11251 non-null object
2 Product_ID 11251 non-null object
3 Gender 11251 non-null object
4 Age Group 11251 non-null object
5 Age 11251 non-null int64
6 Marital_Status 11251 non-null int64
7 State 11251 non-null object
8 Zone 11251 non-null object
9 Occupation 11251 non-null object
10 Product_Category 11251 non-null object
11 Orders 11251 non-null int64
12 Amount 11239 non-null float64
13 Status 0 non-null float64 14 unnamed1 0 non-null float64 dtypes:
float64(3), int64(4), object(8) memory usage: 1.3+ MB
Drop unused/unnecessary columns i.e Status and unnamed1
df.drop(['Status','unnamed1'], axis=1, inplace=True)
pd.isnull(df).sum()
User_ID 0
Cust_name 0
Product_ID 0
Gender 0
Age Group 0
Age 0
Marital_Status 0
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) Page| 3
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
State 0
Zone 0
Occupation 0
Product_Category 0
Orders 0 Amount
12 dtype: int64
Drop all null values in Amount as 12 is very less compared to 11251 records
df.dropna(inplace=True)
df['Amount'] = df['Amount'].astype('int')
df['Amount'].dtypes dtype('int64')
df.columns
Index(['User_ID', 'Cust_name', 'Product_ID', 'Gender', 'Age Group', 'Age',
'Marital_Status', 'State', 'Zone', 'Occupation', 'Product_Category',
'Orders', 'Amount'],
dtype='object')
df.rename(columns={'Marital_Status':'Shaadi'})
A A Shaa
User_ Cust_naProduct_Gend Gro Stat Zo OccupatiProduct_Categ
Orde A
0 1002903 Sanskriti P00125942F 26-35 28 0 Maharashtra Western Healthcare Auto
1 2
1 1000732 Kartik P00110942 F 26-35 35 1 Andhra Pradesh Southern Govt Auto
3 2
2 1001990 Bindu P00118542 F 26-35 35 1 Uttar Pradesh Central Automobile Auto
3 2
3 1001425 Sudevi P00237842M 0-17 16 0 Karnataka Southern Construction Auto
2 2
Food
4 1000588 Joni P00057942M 26-35 28 1 Gujarat Western Auto 2 2
Processing
... ... ... ... ... ... ... ... ... ... ...
...
11246 1000695 Manning P00296942M 18-25 19 1 Maharashtra Western Chemical Office
4
11247 1004089 Reichenbach P00171342M 26-35 33 0 Haryana Northern Healthcare
Veterinary 3
Madhya
11248 1001209 Oshin P00201342F 36-45 40 0 Central Textile Office 4
Pradesh
11249 1004023 Noonan P00059442M 36-45 37 0 Karnataka Southern Agriculture Office 3
df.describe()
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) Page| 4
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
User_I Ag Marital_Stat Orde Amo
count 1.123900e+04 11239.000000 11239.000000 11239.000000 11239.000000
mean 1.003004e+06 35.410357 0.420055 2.489634 9453.610553
std 1.716039e+03 12.753866 0.493589 1.114967 5222.355168
min 1.000001e+06 12.000000 0.000000 1.000000 188.000000
25% 1.001492e+06 27.000000 0.000000 2.000000 5443.000000
50% 1.003064e+06 33.000000 0.000000 2.000000 8109.000000
75% 1.004426e+06 43.000000 1.000000 3.000000 12675.000000
max 1.006040e+06 92.000000 1.000000 4.000000 23952.000000
df[['Age','Orders','Amount']].describe
()
Ag Orde Amo
count 11239.000000 11239.000000 11239.000000
mean 35.410357 2.489634 9453.610553
std 12.753866 1.114967 5222.355168
min 12.000000 1.000000 188.000000
25% 27.000000 2.000000 5443.000000
50% 33.000000 2.000000 8109.000000
75% 43.000000 3.000000 12675.000000
max 92.000000 4.000000 23952.000000
df.describe(include='all')
count 1.123900e+04 11239 11239 11239 11239 11239.000000 11239.000000 11239 11239 11239 1123
unique NaN 1250 A7
User_ Cust_naProduct_GendGro 2350 2 NaN NaN 16 5 1
A Marital_StatStat Zo OccupatiProduct_Cate 15
Uttar
Clothing &
top NaN Vishakha P00265242 F 26-35 NaN NaN Pradesh Central IT Sector
Appar
freq NaN 42 53 7832 4541 NaN NaN 1944 4289 1583 265
mean 1.003004e+06 NaN NaN NaN NaN 35.410357 0.420055 NaN NaN NaN Na
std 1.716039e+03 NaN NaN NaN NaN 12.753866 0.493589 NaN NaN NaN Na
min 1.000001e+06 NaN NaN NaN NaN 12.000000 0.000000 NaN NaN NaN Na
25% 1.001492e+06 NaN NaN NaN NaN 27.000000 0.000000 NaN NaN NaN Na
50% 1.003064e+06 NaN NaN NaN NaN 33.000000 0.000000 NaN NaN NaN Na
75% 1 004426e+06 NaN NaN NaN NaN 43 000000 1 000000 NaN NaN NaN Na
Exploratory Data Analysis
ax = sns.countplot(x='Gender', data = df) for
bars in ax.containers:
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) Page| 5
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
ax.bar_label
(bars)
#gen vs amount sales_gen = df.groupby(['Gender'], as_index=False)['Amount'].sum().sort_values(by='Amount',
ascending=False) sns.barplot(x='Gender', y='Amount', data=sales_gen)
<Axes: xlabel='Gender', ylabel='Amount'>
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) Page| 6
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Age
ax = sns.countplot(data=df, x='Age Group', hue='Gender') for bars in ax.containers: ax.bar_label(bars)
#age vs amount sales_age = df.groupby(['Age Group'], as_index=False)
['Amount'].sum().sort_values(by='Amount', ascending=False) sns.barplot(x='Age Group',
y='Amount', data=sales_age)
<Axes: xlabel='Age Group', ylabel='Amount'>
State
#total number of orders from top 10 states sales_state = df.groupby(['State'], as_index=False)
['Orders'].sum().sort_values(by='Orders', ascending=False).head(10) sns.set(rc={'figure.figsize':
(15,5)})
sns.barplot data=(sales_state, x='State', y='Orders')
sns.barplot data=sales_state
Axes: xlabel='State', ylabel='Orders'
#total amount/sales from top 10 states sales_state = df.groupby(['State'], as_index=False)
['Amount'].sum().sort_values(by='Amount', ascending=False).head(10)
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) Page| 7
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
sns.set(rc={'figure.figsize':(15,5)})
sns.barplot(data=sales_state, x='State',
y='Amount') <Axes: xlabel='State',
ylabel='Amount'>
Marital Status
ax = sns.countplot(data=df, x='Marital_Status')
sns.set(rc={'figure.figsi
ze':(7,5)})
for bars in
ax.containers:
(bar)
sales_state = df.groupby(['Marital_Status', 'Gender'], as_index=False)
['Amount'].sum().sort_values(by='Amount',ascending=False) sns.set(rc={'figure.figsize':(6,5)})
sns.barplot(data=sales_state, x='Marital_Status', y='Amount',hue='Gender')
<Axes: xlabel='Marital_Status', ylabel='Amount'>
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) Page| 8
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Occupation
sns.set(rc={'figure.figsize'
:(20,5)}) ax =
sns.countplot(data=df,x='Occ
upation') for bars in
ax.containers:
ax.bar_label
(bars)
sales_state = df.groupby(['Occupation'], as_index=False)
['Amount'].sum().sort_values(by='Amount',ascending=False) sns.set(rc={'figure.figsize':(20,5)})
sns.barplot
(data=sales_state
, 'Occupation'
, 'Amoun)
<Axes: xlabel='Occupation', ylabel='Amount'
>
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) Page| 9
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Product Category
sns.set(rc={'figure.figsize':(20,5)}) ax = sns.countplot(data=df,x='Product_Category')
for bars in ax.containers: ax.bar_label(bars)
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 10
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
PRACTICAL: 03
AIM: Implementation of Regressions (Make Until Its Completed
in Class).
Regression: Prediction
import numpy as np import pandas as pd import matplotlib.pyplot as plt
#placement.csv
df = pd.read_csv('/content/placement.csv')
df.head()
cgpa package
0 6.89 3.26
1 5.12 1.98
2 7.82 3.25
3 7.42 3.67
4 6.94 3.57
plt.scatter(df['cgpa'],df['package']) plt.xlabel('CGPA')
plt.ylabel('Package(in lpa)')
Text(0, 0.5, 'Package(in lpa)')
x=df.iloc[:,0:1] y = df.iloc[:,-1]
0 3.26
11.98
23.25
33.67
43.57
195 2.46
196 2.57
197 3.24
198 3.96
199 2.33
Name: package, Length: 200, dtype: float64
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 11
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
from sklearn.model_selection import train_test_split x_train, x_test,
y_train,y_test = train_test_split(x,y,test_size=0.2, random_state=2)
from sklearn.linear_model import LinearRegression
#model selection
lr = LinearRegression()
lr.fit(x_train,y_train)
#training a model fit method pass training variables
▾LinearRegression
LinearRegression()
x_test
115 8.35
35 6.87
12 8.94
92 7.90
13 6.93
126 5.91
174 7.32
2 7.82
44 5.09
3 7.42
113 6.94
14 7.73
23 6.19
25 7.28
6 6.73
134 7.20
165 8.21
173 6.75
45 7.87
65 7.60
48 8.63
122 5.12
178 8.15
64 7 36
64 7.36
9 8.31
57 6.60
78 6.59
71 7.47
128 7.93
176 6.29
131 6.37
53 6.47
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 12
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
lr.predict(x_test.iloc[0].values.reshape(1,1))
#method used for testing : predict
/usr/local/lib/python3.10/dist-packages/sklearn/base.py:439:
UserWarning: X does not warnings.warn( array([3.89111601])
plt.scatter(df['cgpa'],df['package'])
plt.plot(x_train,lr.predict(x_train),color='red') plt.xlabel('CGPA')
plt.ylabel ( 'Package(in lpa)' )
Text(0, 0.5, 'Package(in lpa)')
m=lr.coef_
b=lr.intercept_
m*8.58+b array([3.89111601])
m*9.5+b array([4.40443183])
m*100+b array([54.89908542])
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 13
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
#Evaluate model from sklearn.metrics import
r2_score,mean_absolute_error,mean_squared_error
y_pred = lr.predict(x_test) score = r2_score(y_test,y_pred)
print(f'Accuracy score:{score}')
Accuracy score:0.780730147510384
y_pred
array([3.89111601, 3.09324469, 2.38464568, 2.57434935, 1.6537286 ,
1.77647803, 2.07219258, 2.93143862, 3.76278706, 2.93701814,
4.09197872, 3.51170867, 2.97049525, 2.40138424, 3.18809652,
3.46707251, 1.94386362, 3.24389172, 2.97607477, 3.41685683,
2.55761079, 3.16577844, 2.85890486, 3.12114229, 3.68467378,
2.8700639 , 3.49497011, 3.34432308, 3.91901361, 1.96060218,
3.65119666, 3.2104146 , 3.74046898, 2.7863711 , 2.78079158,
3.27178932, 3.52844723, 2.61340599, 2.65804215, 2.71383735])
x_test
cgpa
112 8.58
29 7.15
182 5.88
199 6.22
193 4.57
85 4.79
10 5.32
54 6.86
115 8.35
35 6.87
12 8.94
92 7.90
13 6.93
126 5.91
174 7.32
2 7.82
44 5.09
3 7.42
113 6.94
14 7.73
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 14
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
import numpy as np import pandas as pd import
matplotlib.pyplot as plt
df = pd.read_csv('/content/50_Startups.csv')
df.head()
R&D AdministratiMarketing Stat Profit
0 165349. 136897. 471784.New 192261.
1 162597.70 151377.59 443898.53 California 191792.06
2 153441.51 101145.55 407934.54 Florida 191050.39
3 144372.41 118671.85 383199.62 New York 182901.99
4 142107.34 91391.77 366168.42 Florida 166187.94
Next Generate d View
df.isnull().sum()
R&D Spend 0
Administration 0
Marketing Spend 0
State 0 Profit 0
dtype: int64
df["State"].unique() array(['New York', 'California', 'Florida'],
dtype=object)
#plot R&D vs Profit x1 = df.iloc[:,0].values y1=
df.iloc[:,-1].values plt.scatter(x1,y1, color="Green",
s=50) plt.xlabel("R&D") plt.ylabel("Profit") plt.title("R&D
vs Profit")
plt.show
()
#plot Administration vs Profit x1 = df.iloc[:,1].values
y1= df.iloc[:,-1].values plt.scatter(x1,y1, color="Red",
s=50) plt.xlabel("Administration") plt.ylabel("Profit")
plt.title("Administration vs Profit")
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 15
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
plt.show
()
#plot marketing spend vs Profit x1 = df.iloc[:,2].values
y1= df.iloc[:,-1].values plt.scatter(x1,y1, color="blue",
s=50) plt.xlabel("Marketing spend") plt.ylabel("Profit")
plt.title("marketing spend vs Profit")
plt.show
()
#plot state vs Profit x1 = df.iloc[:,3].values y1=
df.iloc[:,-1].values plt.scatter(x1,y1, color="purple",
s=50) plt.xlabel("state") plt.ylabel("Profit")
plt.title("state vs Profit") plt.show()
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 16
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
df["New York"]=np.where(df["State"]=="New York",1,0)
df["California"]=np.where(df["State"]=="California",1,0)
df["Florida"]=np.where(df["State"]=="Florida",1,0) df.drop(columns=['State'], axis=1,
inplace=True)
df.head()
R Marketi Ne
Spen Administrati Spen Profit Yor CaliforniFlorid
0 165349.20 136897.80 471784.10 192261.83 1 0 0
1 162597.70 151377.59 443898.53 191792.06 0 1 0
2 153441.51 101145.55 407934.54 191050.39 0 0 1
3 144372.41 118671.85 383199.62 182901.99 1 0 0
4 142107.34 91391.77 366168.42 166187.94 0 0 1
Next steps: Generate code with df View recommended plots
df.head()
R&D AdministratiMarketing ProfitNew CaliforniFlorid
0 165349. 136897. 471784.192261. 1 0 0
1 162597.70 151377.59 443898.53 191792.06 0 1 0
2 153441.51 101145.55 407934.54 191050.39 0 0 1
3 144372.41 118671.85 383199.62 182901.99 1 0 0
4 142107.34 91391.77 366168.42 166187.94 0 0 1
Next Generated View
y='Profit'
x=df.columns.tolist()
x.remove(y) x
['R&D Spend',
'Administration',
'Marketing Spend',
'New York',
'California', 'Florida']
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 17
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
x=df[x].values
y=df[y].values
x
[7.8389470e+04, 1.5377343e+05, 2.9973729e+05, 1.0000000e+00, 0.0000000e+00,
0.0000000e+00],
[7.3994560e+04, 1.2278275e+05, 3.0331926e+05, 0.0000000e+00, 0.0000000e+00,
1.0000000e+00],
[6.7532530e+04, 1.0575103e+05, 3.0476873e+05, 0.0000000e+00, 0.0000000e+00,
1.0000000e+00],
[7.7044010e+04, 9.9281340e+04, 1.4057481e+05, 1.0000000e+00,
0.0000000e+00, 0.0000000e+00],
[6.4664710e+04, 1.3955316e+05, 1.3796262e+05, 0.0000000e+00, 1.0000000e+00,
0.0000000e+00],
[7.5328870e+04, 1.4413598e+05, 1.3405007e+05, 0.0000000e+00, 0.0000000e+00,
1.0000000e+00],
[7.2107600e+04, 1.2786455e+05, 3.5318381e+05, 1.0000000e+00,
0.0000000e+00, 0.0000000e+00],
[6.6051520e+04, 1.8264556e+05, 1.1814820e+05, 0.0000000e+00, 0.0000000e+00,
1.0000000e+00],
[6.5605480e+04, 1.5303206e+05, 1.0713838e+05, 1.0000000e+00, 0.0000000e+00,
0.0000000e+00],
[6.1994480e+04, 1.1564128e+05, 9.1131240e+04, 0.0000000e+00, 0.0000000e+00,
1.0000000e+00],
[6.1136380e+04, 1.5270192e+05, 8.8218230e+04, 1.0000000e+00,
0.0000000e+00, 0.0000000e+00],
[6.3408860e+04, 1.2921961e+05, 4.6085250e+04, 0.0000000e+00, 1.0000000e+00,
0.0000000e+00],
[5.5493950e+04, 1.0305749e+05, 2.1463481e+05, 0.0000000e+00, 0.0000000e+00,
1.0000000e+00],
[4.6426070e+04, 1.5769392e+05, 2.1079767e+05, 0.0000000e+00,
1.0000000e+00, 0.0000000e+00],
[4.6014020e+04, 8.5047440e+04, 2.0551764e+05, 1.0000000e+00,
0.0000000e+00, 0.0000000e+00],
[2.8663760e+04, 1.2705621e+05, 2.0112682e+05, 0.0000000e+00, 0.0000000e+00,
1.0000000e+00],
[4.4069950e+04, 5.1283140e+04, 1.9702942e+05, 0.0000000e+00, 1.0000000e+00,
0.0000000e+00],
[2.0229590e+04, 6.5947930e+04, 1.8526510e+05, 1.0000000e+00,
0.0000000e+00, 0.0000000e+00],
[3.8558510e+04, 8.2982090e+04, 1.7499930e+05, 0.0000000e+00, 1.0000000e+00,
0.0000000e+00],
[2.8754330e+04, 1.1854605e+05, 1.7279567e+05, 0.0000000e+00, 1.0000000e+00,
0.0000000e+00],
[2.7892920e+04, 8.4710770e+04, 1.6447071e+05, 0.0000000e+00,
0.0000000e+00, 1.0000000e+00],
[2.3640930e+04, 9.6189630e+04, 1.4800111e+05, 0.0000000e+00,
1.0000000e+00, 0.0000000e+00],
[1.5505730e+04, 1.2738230e+05, 3.5534170e+04, 1.0000000e+00, 0.0000000e+00,
0.0000000e+00],
[2.2177740e+04, 1.5480614e+05, 2.8334720e+04, 0.0000000e+00, 1.0000000e+00,
0.0000000e+00],
[1.0002300e+03, 1.2415304e+05, 1.9039300e+03, 1.0000000e+00,
0.0000000e+00, 0.0000000e+00],
[1.3154600e+03, 1.1581621e+05, 2.9711446e+05, 0.0000000e+00, 0.0000000e+00,
1.0000000e+00],
[0.0000000e+00, 1.3542692e+05, 0.0000000e+00, 0.0000000e+00, 1.0000000e+00,
0.0000000e+00],
[5.4205000e+02, 5.1743150e+04, 0.0000000e+00, 1.0000000e+00, 0.0000000e+00,
0.0000000e+00],
[0.0000000e+00, 1.1698380e+05, 4.5173060e+04, 0.0000000e+00, 1.0000000e+00,
0.0000000e+00]])
array([192261.83, 191792.06, 191050.39, 182901.99, 166187.94, 156991.12, 156122.51,
155752.6 , 152211.77, 149759.96, 146121.95, 144259.4 ,
141585.52, 134307.35, 132602.65, 129917.04, 126992.93, 125370.37,
124266.9 , 122776.86, 118474.03, 111313.02, 110352.25, 108733.99,
108552.04, 107404.34, 105733.54, 105008.31, 103282.38, 101004.64, 99937.59,
97483.56, 97427.84, 96778.92, 96712.8 , 96479.51,
90708.19, 89949.14, 81229.06, 81005.76, 78239.91, 77798.83,
71498.49, 69758.98, 65200.33, 64926.08, 49490.75, 42559.73,
35673.41, 14681.4 ])
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 18
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
x_train
array([[0.4738321 , 0.4510652 , 0.31668231, 1. , 0. ,
0. ],
[0.00333369, 0.00432296, 0. , 1. , 0. ,
0. ],
[0.58215559, 0.88143739, 0.63657411, 1. , 0. ,
0. ],
[0.577276 , 0.71456332, 0.56283007, 0. , 0. ,
1. ],
[0.44347245, 0.71967718, 0.79564086, 1. , 0. ,
0. ],
[0.34129603, 0.48655174, 0.48352224, 0. , 0. ,
1. ],
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 19
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 20
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 21
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 22
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
PRACTICAL: 04
AIM: Implement the naïve Bayesian classifier for a sample
training data set stored as a .CSV file. Compute the accuracy of the
classifier, considering a few test data sets.
import numpy as np import matplotlib.pyplot as plt import
pandas as pd
df = pd.read_csv('50_Startups.csv')
df.head()
R&D AdministratiMarketing Stat Profit
0 165349. 136897. 471784.New 192261.
1 162597.70 151377.59 443898.53 California 191792.06
2 153441.51 101145.55 407934.54 Florida 191050.39
3 144372.41 118671.85 383199.62 New York 182901.99
Next Generated View
4 14
2107.34 91391.77 366168.42 Florida 166187.94
df.tail()
R&D AdministratiMarketing Stat Profit
4 1000. 124153. 1903. New 64926.
46 1315.46 115816.21 297114.46 Florida 49490.75
47 0.00135426.92 0.00 California 42559.73
48 542.05 51743.15 0.00 New York 35673.41
49 0.00116983.80 45173.06 California 14681.40
df.isnull().sum()
R&D Spend 0
Administration 0
Marketing Spend 0
State 0 Profit 0 dtype: int64
df["State"].unique()
array(['New York', 'California', 'Florida'], dtype=object)
x1 = df.iloc[:,0].values y1 = df.iloc[:,-1].values
plt.scatter(x1,y1,color="Green",s=50) plt.xlabel("R&D")
plt.ylabel("Profit") plt.title("R&D vs Profit") plt.show()
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 23
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
#Plot Administration vs Profit x1=df.iloc[:,1].values y1=df.iloc[:,-
1].values plt.scatter(x1,y1,color="Red",s=50)
plt.xlabel("Administration") plt.ylabel("Profit")
plt.title("Administration vs Profit")
plt.show
()
#Plot Marketing spend vs Profit x1=df.iloc[:,2].values
y1=df.iloc[:,-1].values plt.scatter(x1,y1,color="Black",s=50)
plt.xlabel("Marketing Spend") plt.ylabel("Profit")
plt.title("Marketing Spend vs Profit") plt.show()
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 24
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
#Plot state vs Profit x1=df.iloc[:,3].values y1=df.iloc[:,-
1].values plt.scatter(x1,y1,color="Blue",s=50)
plt.xlabel("State") plt.ylabel("Profit") plt.title("State vs
Profit")
plt.show
()
df.State.value_counts()
State
New York 17
California 17
Florida 16
Name: count, dtype: int64
df['New York']=np.where(df['State']=='New York',1,0)
df['California']=np.where(df['State']=='California',1,0) df['Florida']=np.where(df['State']=='Florida',1,0)
df.drop(columns=['State'],axis=1,inplace=True)
df.head()
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 25
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
R Marketi Ne
Spen Administrati Spen Profit Yor CaliforniFlorid
0 165349.20 136897.80 471784.10 192261.83 1 0 0
1 162597.70 151377.59 443898.53 191792.06 0 1 0
2 153441.51 101145.55 407934.54 191050.39 0 0 1
3 144372.41 118671.85 383199.62 182901.99 1 0 0
4 142107.34 91391.77 366168.42 166187.94 0 0 1
Next steps: Generate code with df View recommended plots
y='Profit'
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 26
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
PRACTICAL: 05
AIM: Assuming a set of documents that need to be classified, use
the naïve Bayesian Classifier model to perform this task.
import
seaborn
as sns
import
pandas
as pd
import
numpy as
np
df=sns.load_datase
t('iris')
df.head()
sepal_length sepal_width petal_length petal_width species
0 5.1 3.5 1.4 0.2 setosa
1 4.9 3.0 1.4 0.2 setosa
2 Next steps: 4.7 3.2df
Generate code with View
1.3recommended
0.2
plots setosa
3 4.6 3.1 1.5 0.2 setosa
4 5.0 3.6 1.4 0.2 setosa
df.tail()
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 27
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
sepal_length sepal_width petal_length petal_width species
145 6.7 3.0 5.2 2.3 virginica
146 6.3 2.5 5.0 1.9 virginica
147 6.5 3.0 5.2 2.0 virginica
148 6.2 3.4 5.4 2.3 virginica
149 5.9 3.0 5.1 1.8 virginica
df['species'].unique() array(['setosa',
'versicolor', 'virginica'], dtype=object)
df.isnull().sum()
sepal_l
ength
0
sepal_w
idth
0
petal_l
ength
0
petal_w
idth
0
species
0
dtype:
int64
df=df[df['species']!='setosa']
df.head()
sepal_length sepal_width petal_length petal_width species
50 7.0 3.2 4.7 1.4 versicolor
51 6.4 3.2 4.5 1.5 versicolor
52 6.9 3.1 4.9 1.5 versicolor
53 5.5 2.3 4.0 1.3 versicolor
54 6.5 2.8 4.6 1.5 versicolor
df
Next steps: Generate code with View recommended plots
df['species']=df['species'].map({'varsicolor':0,'virginica':1})
df.head()
sepal_length sepal_width petal_length petal_width species
50 7.0 3.2 4.7 1.4 NaN
51 6.4 3.2 4.5 1.5 NaN
52 6.9 3.1 4.9 1.5 NaN
53 5.5 2.3 4.0 1.3 NaN
54 6.5 2.8 4.6 1.5 NaN
df
Next steps: Generate code with View recommended plots
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 28
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
x=df.iloc[:,:-
1]
y=df.iloc[:,-
1]
sepal_length sepal_width petal_length petal_width
50 7.0 3.2 4.7 1.4
51 6.4 3.2 4.5 1.5
52 6.9 3.1 4.9 1.5
53 5.5 2.3 4.0
1.3
54 6.5 2.8 4.6 1.5 ... ... ... ... ...
145 6.7 3.0 5.2
2.3
146 6.3 2.5 5.0
1.9
147 6.5 3.0 5.2
2.0
148 6.2 3.4 5.4
2.3
149 5.9 3.0 5.1
1.8
100 rows × 4 columns
x
Next steps: Generate code with View recommended plots
50 NaN
51 NaN
52 NaN
53 NaN
54 NaN ... 145 1.0
146 1.0
147 1.0
148 1.0
149 1.0
Name: species, Length: 100, dtype: float64
from sklearn.model_selection import
train_test_split x_train, x_test,
y_train,
y_test=train_test_split( x,y,test_siz
e=0.25,random_state=42
)
from sklearn.linear_model import LogisticRegression
classifier=LogisticRegression()
from sklearn.model_selection import GridSearchCV parameter ={'penalty':
['l1','l2','elasticnet'],'C':[1,2,3,4,5,6,10,20,30,40,50],'max_iter':
[100,200,300]}
classifier_regressor=GridSearchCV(classifier,param_grid=parameter,scoring='accura
cy',cv=5)
classifier_regressor.fit(x_train,y_train)
/usr/local/lib/python3.10/dist-
packages/sklearn/utils/multiclass.py:380:
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 29
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
RuntimeWarni if xp.any(data !=
data.astype(int)):
---------------------------------------------------------------
-----------ValueError Traceback
(most recent call last)
<ipython-input-28-613a9f6f8019> in
<cell line: 1>() ----> 1
classifier_regressor.fit(x_train,y_t
rain)
3 frames
/usr/local/lib/python3.10/dist-packages/sklearn/utils/validation.py
in _assert_all_finite(X, allow_nan, msg_dtype, estimator_name,
input_name)
159 "#estimators-that-handle-nan-values"
160 )
--> 161 raise
ValueError(msg_err)
162
163
ValueError: Input y contains NaN
Next steps: Explain error
print(classifier_regressor.best_params_)
print(classifier_regressor.best_score_)
------------------------------------------------------------------
--------AttributeError Traceback (most
recent call last)
<ipython-input-30-e6dbc56d2a3b> in <cell line: 1>()
----> 1 print(classifier_regressor.best_params_)
AttributeError: 'GridSearchCV' object has no attribute 'best_params_'
Next steps: Explain error
y_pred=classifier_regressor.predict(x_test)
------------------------------------------------------------------
--------NotFittedError Traceback (most
recent call last)
<ipython-input-24-fbc5171df548> in <cell line: 1>()
----> 1 y_pred=classifier_regressor.predict(x_test)
1 frames
/usr/local/lib/python3.10/dist-packages/sklearn/utils/validation.py in check_is_fitted(estimator,
attributes, msg, all_or_any)
1388
1389 if not fitted:
-> 1390 raise NotFittedError(msg % {"name": type(estimator).__name__})
1391
1392
NotFittedError: This GridSearchCV instance is not fitted yet. Call 'fit' with appropriate arguments
before using this estimator.
Next steps: Explain error
from sklearn.metrics import accuracy_score,classification_report
Start coding or generate with AI.
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 30
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
PRACTICAL: 06
AIM: Decision tree-based ID3 algorithm.
import pandas as Pd from sklearn
import datasets from
sklearn .neighbors import
KNeighborsC1assifier from
sklearn . metrics import
confusion matrix, classification
report from sklearn .
model_selection import
train_test_split import seaborn
as sns
import
warning
s
warning
s .
filterw
arnings
( '
ignore
' )
cancer ds = datasets .
( )
cancer ds.data y = cancer ds.target
x. shape
(569, 30)
Y. shape
...t$ț (569, )
x_train, x_test, y_train, y_test = train_test_split(x, y, test size=e.3,
random_state=e)
knn model =
KNeighborsC1assifi
er(n_neighbors=5)
knn_model
y_train) y_pred =
knn_model.predict(
x_test) cm =
confusion_matrix(y
_test, y_pred)
cls_rpt = y_pred
classification_report(y_te )
st,
print(c
m)
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 31
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
print
(cls_rp
t)
..Ț?.« 59 4]
C 5 103] ]
precisi recal fl- suppor
t
on l score
9.92 e . a.93 63
94
1 e.96 e. 95 8.96 108
a.95 171
accuracy
macro avg e. 94 e.95 94 171
weighted avg e.95 e.95 a.95 171
x_train . shape
#hyper parameter tuning
from sklearn . model_selection import
GridSearchCV
knn modal =
KNeighborsC1assifier
() params = { '
n_neighbors ' : [3,
7,9, 11, 13,15, 17,
19,21] }
gscv = GridSearchCV(knn_mode1, param_grid=params,
scoring= ' accuracy' ) gscv.fit(x_train, y_train)
gscv . best_score_
. 9346518987341772
gscv . best_params
X&printMode=true
1/3
('n_neighbors• : 11}
model = gscv. best_estimator_
y_pred = model. predict (x test)
_
cm = cls_rpt =
y_pred)
print(cm)
print(cls_rpt)
59
2 10611
precisio recal fl- suppor
t
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 32
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
n l scor
e
94 e.
e 95 63
98 e.97 138
accurac
y 171
macro avg a. 97 96 e. 171
96
weighted 96 96 171
avg
from sklearn. tree import
DecisionTreeC1assifier
# decisiontree on cancer dataset
cancer ds - - datasets.
load_breast_cancer()
x=cancer data
Y=cancer_ds. target
x—test, x-train , y_train, y_test
train_test_split(x, y,
dt
dt
p
L cm cls_rpt print (cm) print (c
y_pred) Is rpt)
_
[C 59 4]
8 loe] ]
precisio recal fl- suppor
n scor t
l e
0.88 0.94 €.91
o. 93 e. 108
94
accurac €.93 171
y
macro avg a. 92 o. 93 €.93 171
weighted 0.93 0.93 €.93 171
avg
from
sklearn.tree
import
plot_tree
import
matplotlib.
pyplot as plt
plot_t
ree
(dt_mo
del )
plt.sh
ow()
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 33
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
8200484687
-tart or enerate with Al .
codin
X&printMode=true
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 34
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
PRACTICAL: 07
AIM: Write a program to implement the KNearest Neighbor
algorithm to classify the iris data set.
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 35
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 36
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 37
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
PRACTICAL: 08
AIM: Apply EM algorithm to cluster a set of data stored in a .CSV
file. Use the same data set for clustering using k-Means algorithm.
from sklearn
import datasets
from
sklearn.cluster
import
KMeans
from matplotlib import pyplot as
plt
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 38
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
cluster_3_model = KMeans (n_clusters = 3) cluster_lables = cluster_3_model.fit_predict(x[:,[0,1]])
plt.scatter(x[:,0],x[:,1],c=cluster_lables) centroids = cluster_3_model.cluster_centers_
plt.scatter(centroids[:,0],centroids[:,1],c='red') plt.show()
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 39
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 40
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
k_values = [2,3,4,5] wcss_values = []
for k_value in k_values:
model = KMeans
(n_clusters = k_value)
model.fit(x_data[0])
wcss_value =
model.inertia_
wcss_values.append(mode
l.inertia_)
plt.plot(k_values,wcss_val
ues) plt.show()
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 41
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 42
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
PRACTICAL: 09
AIM: Write a program to construct a Bayesian network
considering medical data. Use this model to demonstrate the
diagnosis of heart patients using standard Heart Disease Data Set.
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 43
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 44
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 45
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 46
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 47
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 48
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 49
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 50
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 51
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 52
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 53
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 54
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
PRACTICAL: 10
AIM: Compare the various supervised learning algorithms by using
the appropriate dataset.
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 55
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 56
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 57
Faculty of Engineering & Technology
Machine Learning Laboratory (203105403)
B. Tech CSE 4th Year 7th Semester
Enrollment No.: 210303105168
CHAUDHARY UMANGKUMAR BALUBHAI
Div: 25(CSE) P a g e | 58