You are on page 1of 9

University of Nairobi

Course: Msc. Computer Science (Computational Intelligence)

Date: 22/11/2023

SCS6105 – Machine Learning

Linear Regression

GROUP 3

Group Members

Name email Reg Number

Clara Musenya musyokamusenya@gmail.c


Musyoka om SCS61/45477/2023

AGIRA CHRIS chrisagira@students.uonbi.a SCS61/44672/2023


JAMES c.ke

NGUU JOHN kikuvijohn@students.uonbi. P60/41063/2021


KIKUVI ac.ke
Linear Regression Group Work

The following table shows the results of a survey investigating the different types of
foods sold in Mongolian restaurants, based on certain criteria.
# Food type Weight (grams) Price ($)

1 Tsuivan 241 6.00

2 Pita 165 3.30

3 Tacos 135 3.80

4 Borts 90 2.90

5 Falafel 193 5.70

6 Bansh 150 3.90

7 Horhog 169 3.30

8 Buuz 92 3.40

1. Represent on a graph, the weight (on the x-axis) and the price (on the y-axis)
of the foods surveyed. Is there a relationship between the two variables?
Yes, linear relationship with some few outliers which are not very far from
the estimate as shown by the dotted line.

2. Based on the model: (price) = β0 + β1.(weight) + ε


Estimate the parameters β0 and β1 and write the obtained equation. Show
your working.
(price) = β0 + β1.(weight) + ε

To calculate β0 + β1.

Where b0 is the intercept and b1 is the slope.


3. Draw on the previous graph the line obtained in (2) above and check if this
line models the data satisfactorily.
The line forms a perfect linear regression.

4. Use the regression equation to predict:


a. The price of a food weighing 100 grams.
Given: (price) = β0 + β1.(weight) + ε
And β0 = 1.1348
β1= 0.0188
(price) = β0 + β1.(weight) + ε
Price = 1.1348 +0.0188*100

Price = 3.0148

b. The price of a food weighing 200 grams.


(price) = β0 + β1.(weight) + ε
Price = 1.1348 +0.0188*200
Price = 4.8948

c. The increase in price for an additional 50 grams

(price) = β1.(weight) + ε
Price = 0.0188*50
Price =0.94

5. Calculate the:
a. Mean Squared Error (MSE)
b. sum of squares total (SST)
c. sum of squares regression (SSR)
d. sum of squares error (SSE)
e. R2

= 6.276187454/ 9.47875= 0.662132397

What do you conclude from these measures?


● MSE gives an average of the squared differences between predicted
and actual values.
● Rsquared value indicated approximately 66.21% of the variability in
the dependent variable (price) is explained by the independent
variable (weight).
● A higher R-squared indicates a better fit of the model to the data.
● These measures suggest that the linear regression model provides a
reasonable fit to the data, explaining a significant portion of the
variability in the price based on the weight of the foods.

You might also like