Linear Regression and Multiple Linear Regression

Simple linear regression (SLR) and multiple linear regression (MLR) are both methods used in predictive modeling to understand and quantify the relationship between independent and dependent variables.

Simple Linear Regression (SLR):

  • Definition: SLR is a statistical technique that models the relationship between a single independent variable and a dependent variable by fitting a linear equation to observed data.
  • Equation: =0+1+, where:
    • 0 is the intercept,
    • 1 is the slope,
    • is the error term.
  • Usage: SLR is used when there is a linear relationship between one independent variable and the dependent variable.
  • Example: Predicting car price based on highway miles per gallon (HPM).

Multiple Linear Regression (MLR):

  • Definition: MLR extends SLR by incorporating multiple independent variables to predict a dependent variable.
  • Equation: =0+11+22+...++, where:
    • 1,2,..., are the independent variables,
    • 0,1,2,..., are the coefficients.
  • Usage: MLR is used when there are multiple independent variables influencing the dependent variable.
  • Example: Predicting car price based on factors like highway miles per gallon, engine size, and age of the car.

Implementation in Python:

  1. Simple Linear Regression:

    • Import the linear model from scikit-learn.
    • Create a linear regression object.
    • Define predictor and target variables.
    • Fit the model using the fit method.
    • Obtain predictions using the predict method.
    • The intercept and coefficients can be accessed as attributes of the model object.
  2. Multiple Linear Regression:

    • Follow similar steps as SLR, but with multiple predictor variables.
    • Extract and store predictor variables in a variable.
    • Train the model using the fit method with the appropriate inputs.
    • Obtain predictions using the predict method.
    • Intercept and coefficients are accessed as attributes of the model object.

Both SLR and MLR allow us to understand and predict the dependent variable based on the relationships with one or more independent variables. 

Comments

Popular posts from this blog

Common cybersecurity terminology

Introduction to security frameworks and controls

syllabus