Abhishek Pandey - BI Lab - Exp 3
Abhishek Pandey - BI Lab - Exp 3
Aim: Write a program to implement Sales Revenue Prediction using Linear Regression
Software Required: Jupyter Notebook (Anaconda)
Description:
● Linear Regression: Linear regression is a type of supervised machine learning algorithm
that computes the linear relationship between a dependent variable and one or more
independent features. When the number of the independent feature is 1 then it is known as
Univariate Linear regression, and in the case of more than one feature, it is known as
multivariate linear regression. The goal of the algorithm is to find the best linear equation
that can predict the value of the dependent variable based on the independent variables.
The equation provides a straight line that represents the relationship between the
dependent and independent variables. The slope of the line indicates how much the
dependent variable changes for a unit change in the independent variable(s).
Implementation:
#Importing Libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import mpl_toolkits
from sklearn import linear_model
%matplotlib inline
plt.style.use('ggplot')
import warnings
Output:
plt.show()
sales
lr = linear_model.LinearRegression()
lr.fit(n_df,sales)
lr.predict([[150]])
#let's generate model prediction for all budget amounts in our dataset
y_predict = lr.predict(n_df)
plt.figure(figsize=(12,6))
plt.show()
# Intercept value
print("Intercept :",lr.intercept_)
# Slope value
print('Slope :',lr.coef_)
plt.figure(figsize=(12,6))
plt.show()
plt.plot(x_ax,y_predict, label="predicted")
plt.legend()
plt.show()
b_df