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:-
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 |
.png)