After understanding the concepts of regression analysis, multicollinearity, and dummy variables, it's time to get some hands-on experience with regression analysis. Let's learn how to build the regression model using the scientific toolkit for machine learning (scikit-learn):
- We will first load the dataset using the read_csv() function:
# Import pandas import pandas as pd
# Read the dataset using read_csv method df = pd.read_csv("Advertising.csv")
# See the top-5 records in the data df.head()
This results in the following output:
Now that we have loaded the Advertising.csv dataset using read_csv() and checked the initial records using the head() function, we will split the data into two parts: dependent or target variable and independent variables or features.
- In this step, we will split the data two times:
- Split into two parts: dependent or target variable and independent variables or features.
- Split data into training and...