# How to implement multiple linear regression Scikit learn tutorial

1. Introduction to Multiple linear regression
2. Problem Statement
3. Code walkthrough
4. Video Tutorial

1 Introduction to Multiple linear regression

1. Multiple linear regression is quite similar to simple linear regression wherein Multiple linear regression instead of the single variable we have multiple-input variables X and one output variable Y and we want to build a linear relationship between these variables.
2. In Simple linear regression (Y) = b0+b1X1
3. In multiple linear regression (Y) = b0+b1X1+b2X2+b3X3……….bnXn
4. Here the X1, X2, X3…..XN are independent variable and the output variable is called dependent

2 Problem Statement

1. Dataset consisting of 4columns R&D, administration, and marketing are independent variables and profit is our dependent variable.
2. So we need to find out profit based on the amount spent on R&D administration and marketing so

3 Code walkthrough

Imported the all necessary libraries Matplotlib which will be used for plotting the second one is pandas for reading dataset.

Imported my data set using read CSV function and initialized x and y variables with R&D, administration, marketing spend, and profit respectively

1. split the data set into a training set and test set we will be using a function called train test split which will split a 5/6 th dataset into a training set and 1/6 th to test.
2. After splitting the data into training and testing sets finally the time is to train our algorithm for that we need to import the linear regression class and then we will be instantiating a regressor
3. Once that is done we will call up the fit function giving it the parameters as x-train and y train the training data
4. After training is done model will return you the best fit for the particular data and then you can get all the intercept and the theta values you can
5. We can get the intercept from the arguments if you call the regressor. intercept_ we will get B0 value if you call regressor.coefficient

Predictions on x test:

1. We predicted all my testing data set using the predict function
2. predict function give us all the predicted Y values and then we have tried comparing it with our actual values and our predicted values