In this guide, we will learn how to build a Simple Linear Regression Model using Sci-kit Learn. Simple Linear Regression is a regression algorithm that shows the relationship between a single independent variable and a dependent variable.
The Sci-kit Learn library contains a lot of tools used for machine learning. We will build a model to predict sales revenue from the advertising dataset using simple linear regression.
Prerequisite
The formula of simple linear regression is:
y = θ0x + θ1
PythonCopy
θ0 represents the slope of the regression line
θ1 represents the intercept of the regression line
x is the independent variable
y is the dependent variable
IMPORTING DATASET
Let’s import our libraries
## importing libraries
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
%matplotlib inline
## importing dataset
advert = pd.read_csv('Advertising.csv')
## view first 5 entries
advert.head()
#machine learning #python #sci-kit learn