Code For Linear Regression Analysis
Code For Linear Regression Analysis
Problem-1: Consider a small sample of the dataset as shown below and perform linear regression analysis.
Solution:
1. Importing Libraries:
Import the necessary libraries. You will be using pandas for data manipulation and sklearn for building the
linear regression model.
5. Making Predictions:
Use the model to predict the test scores for the test data.
Solution:
1. Importing Libraries:
2. Preparing the Data:
Load the data into a DataFrame and separate the features and target variable.
5. Making Predictions:
Use the model to predict sales for the test data.
6. Evaluating the Model:
The coefficients of the model will tell us how much each advertising medium contributes to sales. We can
get the details using the function as follows:
*****