0% found this document useful (0 votes)
9 views3 pages

Solved Linear Regression

The document outlines the concept of linear regression, explaining its purpose, the relationship between independent and dependent variables, and providing real-life examples. It includes tasks that illustrate how to identify variables, interpret the linear regression equation, and make predictions based on given data. Additionally, it covers the calculation of slope and intercept, along with practical scenarios for predicting house prices and salaries based on experience and size.

Uploaded by

maheemwasiq109
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Solved Linear Regression

The document outlines the concept of linear regression, explaining its purpose, the relationship between independent and dependent variables, and providing real-life examples. It includes tasks that illustrate how to identify variables, interpret the linear regression equation, and make predictions based on given data. Additionally, it covers the calculation of slope and intercept, along with practical scenarios for predicting house prices and salaries based on experience and size.

Uploaded by

maheemwasiq109
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Based on the worksheet provided, here are the answers and solutions to the tasks.

Task 1: What is Linear Regression?


* Purpose: Linear regression is used to predict the value of a dependent variable based on the
value of an independent variable by finding the relationship between them.
* "Best-fit line": It is a straight line that best represents the data on a scatter plot. It is drawn to
minimize the distance (error) between the actual data points and the line itself.
* Variables:
* Independent variable (X): The input or cause (the variable you control or change).
* Dependent variable (Y): The output or effect (the variable being measured or predicted).
* Real-life examples:
* Predicting house prices based on square footage.
* Predicting a person's weight based on their height.
Task 2: Identify Variables in a Scenario
| Scenario | Independent Variable (X) | Dependent Variable (Y) | Why is linear regression
suitable? |
|---|---|---|---|
| A (AC Usage) | Number of hours AC is used | Electricity consumption (kWh) | There is a direct,
continuous relationship where more hours likely equals more consumption. |
| B (Exam Marks) | Hours studied | Final exam marks | Studying generally correlates with marks,
allowing for prediction based on trends. |
| C (Fuel Cost) | Kilometers driven | Fuel cost | Cost increases linearly as distance increases
(constant fuel price). |
Task 3: The Linear Regression Equation
Equation: Y = mX + c
* m (slope): This represents the rate of change. It tells you how much Y changes for every 1
unit increase in X.
* c (intercept): This is the value of Y when X = 0. It represents the starting point or baseline
value.
* If X increases by 1 unit: Y will change (increase or decrease) by the value of the slope (m).
* Positive slope: As X increases, Y also increases.
* Zero slope: There is no relationship between X and Y; Y remains constant regardless of X.
Task 4: Visual Interpretation
Data Analysis:
* (1, 40), (2, 50), (3, 55), (4, 65)
Answers:
* As X increases: Y also increases (40 \to 50 \to 55 \to 65).
* Trend: This looks like a positive trend.
* Should a model be used? Yes. The data shows a consistent upward pattern, suggesting a
linear relationship exists between study hours and marks.
Task 5: Interpret the Slope
Equation: Y = 8X + 35
* Slope 8: For every 1 additional hour a student studies, their marks are predicted to increase
by 8 marks.
* Intercept 35: If a student studies for 0 hours, they are predicted to score 35 marks (base
score).
* Predictions:
* 5 hours: Y = 8(5) + 35 = 40 + 35 = \mathbf{75}
* 0 hours: Y = 8(0) + 35 = 0 + 35 = \mathbf{35}
* 10 hours: Y = 8(10) + 35 = 80 + 35 = \mathbf{115}
Task 6: Calculate Slope and Intercept (Numerical Problem)
Dataset: (1, 2), (2, 4), (3, 5)
Number of data points (n): 3
Step 1: Compute Summaries
* * * * Step 2: Calculate Slope (m)

Step 3: Calculate Intercept (c)

Step 4: Final Equation

Task 7: Use Your Model to Make Predictions


Using model: Y = 1.5X + 0.67
* When X = 4:

* When X = 0:

* Non-whole number explanation: This is acceptable because linear regression predicts an


average expected value or trend based on the line, not necessarily an exact integer count. For
example, you can't have 0.67 of a person, but you can have an average of 0.67 people per
group.
Task 8: Interpret the Results
* Slope (1.5): There is a positive relationship. As X increases by 1, Y increases by 1.5 units.
* Intercept (0.67): It makes mathematical sense as the starting value of Y. Whether it makes
"real world" sense depends on what the data represents (e.g., if it's counting discrete items,
starting at 0.67 might be just a theoretical baseline).
* Strength: The relationship appears strong because the calculated points lie very close to the
actual data points (e.g., at X=2, actual is 4, predicted is 1.5(2)+0.67 = 3.67, which is very close).
Task 9: House Price Prediction Scenario
Data: (800, 50), (1000, 60), (1200, 68)
* Identify Variables:
* X: House Size (sq ft)
* Y: Price (in lakhs)
* Trend: Increasing (Larger house = Higher price).
* Suitability: Suitable because house prices typically rise in proportion to size.
* Prediction (Y = 0.1X + 10):
* For 1500 sq ft:
* Slope 0.1 means: For every 1 sq ft increase in size, the price increases by 0.1 lakhs (or
10,000).
* Intercept 10 means: The base price of a house (perhaps land value) with 0 sq ft size is 10
lakhs.
Task 10: Salary Prediction Scenario
Model: Y = 5X + 23
* Predict salary for X=6:

* Predict salary for X=0:

* Meaning of slope 5: For every 1 additional year of experience, the salary increases by 5
thousand PKR.
* Meaning of intercept 23: The starting salary for a fresher (someone with 0 years of
experience) is 23 thousand PKR.

You might also like