201CS240-MLLABMANUAL
201CS240-MLLABMANUAL
Submitted by
OWSIKAN M
201CS240
1
BANNARI AMMAN INSTITUTE OF TECHNOLOGY
(An Autonomous Institution Affiliated to Anna University, Chennai)
BONAFIDE CERTIFICATE
2
18CS508 - MACHINE LEARNING LABORATORY
Course Outcomes
3
Table of Contents
S. No. Name of the Experiment Page No. Marks Signature
Awarded
1 Implementation of Candidate
Algorithm for the dataset: 5
Weather Identification Dataset
2 Implementation of Navie Bayers
classifier for the dataset: USER 13
DATA Dataset
3 Implementation of Find - S and
Candidate Algorithm for the
dataset : Enjoy sport
4 Implementation of MLP for the
dataset : Breast cancer dataset
4
IMPLEMENTING CANDIDATE ELIMINATION
ALGORITHM AND GENERATE MOST SPECIFIC
HYPOTHESIS AND MOST GENERAL HYPOTHESIS
AIM : -
To implement the Candidate Elimination algorithm and
demonstrate the Most specific hypothesis and the most general
hypothesis for the dataset.
ALGORTIHM : -
if attribute_value == hypothesis_value:
Do nothing
else:
5
CODING : -
specific_h = d[0].copy()
6
print("\nInstance", i+1 , "is ", val)
if target[i] == "yes":
for x in range(len(specific_h)):
if val[x]!= specific_h[x]:
specific_h[x] ='?'
general_h[x][x] ='?'
if target[i] == "no":
for x in range(len(specific_h)):
if val[x]!= specific_h[x]:
general_h[x][x] = specific_h[x]
else:
general_h[x][x] = '?'
print("\n")
for i in indices:
7
general_h.remove(['?', '?', '?', '?', '?', '?'])
OUTPUT :-
8
CONCLUSION : -
Implementing the Candidate elimination algorithm is
successfully executed and most specific hypothesis and most general
hypothesis also generated successfully.
REFERENCES : -
9
1. https://www.geeksforgeeks.org/ml-candidate-elimination-algorithm/
2. https://colab.research.google.com/drive/1VVZPOAHbi0BqOGDqnpy-
0_cXRTwjd799#scrollTo=2_MNt1BsPELK
AspectType
Sl. Aspect of Extra aspect ofdescription Requirement Max.
description (only for M) marks
(M or J)
No.
10
If downloaded CSV dataset -
Downloading
Yes - 1 1
1. J correct dataset
No - 0
1
Splitting the If Dataset is splitted into separate
dataset into features and labels dataframe
3. J - 1
features and Yes - 1
labels No - 0
Preprocessing
the data
0 - If all the four (i, ii, iii, iv) aspects
Missing values
4. J are not achieved
are removed
0.25 - if any one of the aspects is
Categorical
achieved
values are
0.5 - if any two of the aspects is
converted to - 1
achieved
numerical form
0.75 - if any three of the aspects is
Dimensionality
achieved
reduction is
1 - If all the four (i, ii, iii, iv) aspects
used
are achieved
Outliers are
removed
segregating the
target that has If segregated , the target values
6. J positive and Yes - 1 - 1
negative No - 0
examples
Train the dataset, according to the
Training the specified algorithm
- 1
model Yes - 1
7. J
No - 0
11
If obtained the correct hyposthesis
Obtaining the
8 J Yes - 1 2
hypothesis
No - 0
-
0 - Exceeded 45 mins -
Time
9 J 0.5 - Completed within 30 to 45 mins 1
Management
1 - Completed within 30 min
Coding Ethics -
Proper 0 - If none of the aspect is found
10 J Indentation 0.5 - If exhibiting any one aspect 1
Overall design 1 - If exhibiting all two aspects
look
Total Marks
10
12
AIM:
To implement the Navie Bayers Classifier for the User Dataset and
Predict as well as Visualize the results.
ALGORITHM:
CODING :
import numpy as nm
import pandas as pd
13
dataset = pd.read_csv('User_Data.csv')
y = dataset.iloc[:, 4].values
# Splitting the dataset into the Training set and Test set
# Feature Scaling
sc = StandardScaler()
x_train = sc.fit_transform(x_train)
x_test = sc.transform(x_test)
classifier = GaussianNB()
classifier.fit(x_train, y_train)
14
cm = confusion_matrix(y_test, y_pred)
mtp.xlim(X1.min(), X1.max())
mtp.ylim(X2.min(), X2.max())
for i, j in enumerate(nm.unique(y_set)):
mtp.xlabel('Age')
mtp.ylabel('Estimated Salary')
mtp.legend()
mtp.show()
15
x_set, y_set = x_test, y_test
mtp.xlim(X1.min(), X1.max())
mtp.ylim(X2.min(), X2.max())
for i, j in enumerate(nm.unique(y_set)):
mtp.xlabel('Age')
mtp.ylabel('Estimated Salary')
mtp.legend()
mtp.show()
OUTPUT :
16
Visualization on training set
17
Visualization on testing set
CONCLUSION :
REFERENCES :
1. https://colab.research.google.com/drive/10s1ih3kTlGZLXLeu3T6KDs
uU9yutrbV1?usp=share_link
2. https://www.javatpoint.com/bayes-theorem-in-machine-learning
18
Outcome based lab tasks – Assessment
18CS508 – MACHINE LEARNING LABORATORY
(Navie Bayers classifier - User Data)
AspectType
Sl. (M or J) Aspect of Extra aspect ofdescription Requirement Max.
No. description (only for M) marks
If downloaded CSV dataset -
Downloading
1. J Yes - 1 1
correct dataset
No - 0
19
6. J Train the dataset, according to the
Training the specified algorithm
1
model Yes - 1
No - 0 -
If test data is used for evaluation and
determined the error and accuracy rate
Prediction -
Yes - 1 1
7. J No - 0
Visualization -
Selected features
and labels are 0 - If all the four (i, ii, iii, iv) aspects
visualized are not achieved
Comparison plot 0.25 - if any one of the aspects is
8. J of Actual values achieved
and predicted 0.5 - if any two of the aspects is
1
values achieved
Predicted output 0.75 - if any three of the aspects is
is visualized achieved
Growth in 1 - If all the four (i, ii, iii, iv) aspects
accuracy and are achieved
loss is compared
and visualized
J 0 - Exceeded 45 mins -
9. Time
0.5 - Completed within 30 to 45 mins 1
Management
1 - Completed within 30 min
J Coding Ethics -
10.
Proper 0 - If none of the aspect is found
Indentation 0.5 - If exhibiting any one aspect 1
Overall design 1 - If exhibiting all two aspects
look
Total Marks
10
20