Tech-in-Computer
Machine Learning Lab Assignment for M.Tech and MCA course:-
Prior knowledge:- Brief mathematical knowledge of Regression, Minimum Distance Classifier's, Types of norms, k-means clustering Algo, K-nn Algo, Support Vector Machine, Density Based Spatial Algo, Parallel and Sequential Execution Algo. Python Programming.
By default Datasets:- Iris Dataset, Cancer Daraset, User Input Dataset.
Lab 1:- For practice only
Assign 1: Write a program to fit a line using the Gradient Descent Algorithm for the following pairs of values:
X = (1, 3, 5, 7, 9)
Y = (1, 3, 4, 3, 5)
Then, test the fitted line using the same data.
Y = (1, 3, 4, 3, 5)
Assign 2: Write a program to learn the Naive Bayes classification model using the following dataset:
Person | COVID (Yes/No) | Flu (Yes/No) | Fever (Yes/No) |
|---|---|---|---|
1 | Yes | No | Yes |
2 | No | Yes | Yes |
3 | Yes | Yes | Yes |
4 | No | No | No |
5 | Yes | No | Yes |
6 | No | No | Yes |
7 | Yes | No | Yes |
8 | Yes | No | No |
9 | No | Yes | Yes |
10 | No | Yes | No |
Next, use the learned Naive Bayes model to determine the class of a person (Flu or COVID-19), assuming that Fever is classified into two categories: “Yes” and “No.”
Assign 3: Linear regression is a linear approach to modeling the relationship between a dependent variable and one or more independent variables. Let X be the independent variable and Y be the dependent variable. We define the linear relationship between these two variables as follows:
where
and and represent the means of X and Y, respectively.
Write a program to compute the goodness of fit of the model using the R² value for the following pairs of values:
Determine the R² value, and identify its maximum and minimum possible values.
Solution:-
Where:
= coefficient of determination
= residual sum of squares (unexplained variation)
= total sum of squares (total variation)
It can also be written as:
because
Assign 4: The table below shows the number of hours each student spent studying and whether the student passed (1) or failed (0) the test.
| Hours Studied (xₖ) | Pass/Fail (yₖ) |
|---|---|
| 0.50 | 0 |
| 0.75 | 0 |
| 1.00 | 0 |
| 1.25 | 0 |
| 1.50 | 0 |
| 1.75 | 0 |
| 2.00 | 0 |
| 2.25 | 1 |
| 2.50 | 0 |
| 2.75 | 1 |
| 3.00 | 0 |
| 3.25 | 1 |
| 3.50 | 0 |
| 4.00 | 1 |
| 4.25 | 1 |
| 4.50 | 1 |
| 4.75 | 1 |
| 5.00 | 1 |
| 5.50 | 1 |
Write a program to fit a logistic regression function to the given data, where xₖ represents the number of hours studied and yₖ represents the test outcome, with yₖ = 1 indicating a pass and yₖ = 0 indicating a failure.
Lab 2:-
Assign 1: Write a python program to use linear regression to perform prediction on any dataset.
Assign 2: Write a python program to implement logistic regression on any dataset.
Assign 3: Write a python program to implement multinomial logistic regression on any dataset.
Lab 3:-
Assign 1: Write a python program to implement the Minimum Distance Classifier Algorithm on Iris dataset.
Assign 2: Write python program to implement the Bayes Classification Algorithm.
Assign 3: Write a python program to implement the Naive Bayes Classifier's Algorithm.
Assign 4: Write a python program to implement the Support Vector Machine (SVM) Algorithm on user input data.
Assign 5: Write a python program to implement the Support Vector Machine (SVM) Algorithm on Iris dataset / Cancer dataset.
Assign 6: Write a python program to implement the XOR-Gate by using Support Vector Machine (SVM) Algorithm.
Assign 7: Write a python program to implement the X-NOR-Gate by using Support Vector Machine (SVM) Algorithm.
Assign 8: Write a python program to implement the OR-Gate by using Support Vector Machine (SVM) Algorithm.
Assign 9: Write a python program to implement the AND-Gate by using Support Vector Machine (SVM) Algorithm.
Assign 10: Write a python program to find the optimal value of 'K' in k-means Algorithm by using elbow method.
Assign 11: Write a python program to implement the K-means Algorithm on user input data.
Assign 12: Write a python program to implement the K-means Algorithm on Iris dataset.
Assign 12: Write a python program to find the optimal value of 'K' in K-nearest neighbor (K-nn) Algorithm.
Assign 13: Write a python program to implement the K-nearest neighbor (K-nn) Algorithm.
Assign 14: Write a python program to find the (epsilon) and 'MinPts' parameters uses in DBSCAN Algorithm.
Assign 15: Write a python program to find the contour of a binary image by using DBSCAN Algorithm.
Assign 16: Write a python program to implement the Bagging concept in ML.
Assign 17: Write a python program to implement the Boosting concept in ML.
Lab 4:- For practice only
Assign 1: Write python code to compute the decision function’s of a minimum distance classifier’s for the following pattern.
C1:{(0,0)T,(2,0)T,(2,2)T,(0,2)T}
C2:{(4,4)T,(6,4)T,(6,6)T,(4,6)T}
Now, test for for the input (4,4) belong to the class C2, and input (2,2) belongs to the class C1 .
Assign 2: Write python code to compute the decision function’s of a minimum distance classifier’s for the following pattern.
C1:{(0,0)T,(2,0)T,(2,2)T,(0,2)T}
C2:{(4,4)T,(6,4)T,(6,6)T,(4,6)T}
Plot the decision boundary implemented by the decision function’s as a output.
Assign 3: Compute decision functions of a minimum distance classifier for Iris data set (Iris versicolor, Iris setosa) taking two features only petal length and petal width. Then find the decision boundary for the two classes. Show it pictorially.
Assign 4: Write python code to test the input (4,4) belong to class C2, and the input (2,2) belong to class C1 , by using Bayes decision boundary for the following two pattern classes have Gaussian probability density functions:
C1:{(0,0)T,(2,0)T,(2,2)T,(0,2)T}
C2:{(4,4)T,(6,4)T,(6,6)T,(4,6)T}
Assume that p(c1) = p(c2) =1/2 .
Assign 5: Write python code to plot Bayes decision boundary for the following two pattern classes have Gaussian probability density functions:
C1:{(0,0)T,(2,0)T,(2,2)T,(0,2)T}
C2:{(4,4)T,(6,4)T,(6,6)T,(4,6)T}
Assume that p(c1) = p(c2) = 1/2 .
.png)