Chapter 19 of 30
Keep learning and build your Data Science skills.
Regression Analysis
Learn how regression is used to model relationships between variables.
Theory
Regression analysis models the relationship between a dependent variable and one or more independent variables.
Regression can be used for:
• Prediction
• Trend analysis
• Understanding relationships
Linear regression is one common form of regression analysis.
A simple linear regression model can be written as:
y = mx + b
Example
from sklearn.linear_model import LinearRegression
X = [[1], [2], [3], [4]]
y = [10, 20, 30, 40]
model = LinearRegression()
model.fit(X, y)
print(model.predict([[5]]))Output
The regression model predicts the target value for a new input.
Practice
Build a regression model using a numerical dataset.
Interview Questions
1
What is regression analysis?
2
What is linear regression?
3
What is the dependent variable?
Quick Quiz
Which option best describes this chapter?
A.Modeling relationships between variables
B.Creating HTML pages
C.Managing computer networks
D.Building operating systems