INTERNSHIP MINI-PROJECT REPORT
2. SALES PREDICTION USING SIMPLE LINEAR
REGRESSION
Submitted By:
Kishore K
Department:
[Link] Artificial Intelligence and Data Science
College:
J.N.N Institute of Engineering
Internship Organization:
Edufyi Tech Solutions
TABLE OF CONTENTS
[Link] ............................................ 3
2. Introduction ..................................... 4
3. Dataset Description ……...................5
4. Methodology ......................................7
5. Results and Discussion ….................9
6. Conclusion ......................................11
2
1. ABSTRACT
Sales prediction plays an important role in helping businesses make informed decisions
regarding marketing strategies, budgeting, and resource allocation. Advertising is one of the
major factors that influences product sales, and understanding the relationship between
advertising expenditure and sales can help organizations optimize their marketing efforts.
The objective of this project is to study the relationship between advertising expenditure and
product sales using a Simple Linear Regression model. The Advertising Dataset contains
information about advertising spending on different media channels and the corresponding
sales generated. In this project, television advertising expenditure was selected as the
independent variable, while sales were considered the dependent variable.
The dataset was analyzed and preprocessed before training the model. A Simple Linear
Regression algorithm was implemented using the Scikit-learn library in Python. The dataset
was divided into training and testing sets, and the model was evaluated using performance
metrics such as Mean Absolute Error (MAE), Mean Squared Error (MSE), and R² Score.
The results demonstrated a positive relationship between advertising expenditure and sales,
indicating that increased advertising investment can contribute to higher sales performance.
This project highlights the practical application of regression techniques in business analytics
and sales forecasting.
3
2. INTRODUCTION
Sales prediction is an important aspect of business analytics that helps organizations
estimate future sales based on historical data. Accurate sales forecasting enables businesses
to make better decisions regarding production planning, inventory management, budgeting,
and marketing strategies. By understanding the factors that influence sales, companies can
allocate resources more efficiently and improve overall business performance.
Advertising is one of the most significant factors affecting product sales. Organizations
invest heavily in advertising through various channels such as television, radio, newspapers,
and digital media to attract customers and increase revenue. Analyzing the relationship
between advertising expenditure and sales helps businesses evaluate the effectiveness of
their marketing campaigns and optimize their investments.
Machine learning and statistical techniques have become powerful tools for analyzing
business data and predicting future outcomes. One of the simplest and most widely used
techniques for studying the relationship between two variables is Linear Regression. Linear
Regression establishes a mathematical relationship between an independent variable and a
dependent variable and uses this relationship to make predictions.
In this project, a Simple Linear Regression model is developed to study the relationship
between advertising expenditure and sales of a dietary weight control product. The
Advertising Dataset is used for analysis, where television advertising expenditure is
considered the independent variable and sales are considered the dependent variable. The
dataset is explored, preprocessed, and divided into training and testing sets before training
the model.
The performance of the model is evaluated using metrics such as Mean Absolute Error
(MAE), Mean Squared Error (MSE), and R² Score. The results help determine how
effectively advertising expenditure influences product sales and demonstrate the practical
application of regression analysis in business decision-making and sales forecasting.
4
3. DATASET DESCRIPTION
The dataset used in this project is the Advertising Dataset, which is widely used for studying
the relationship between advertising expenditure and product sales. The dataset contains
information about advertising budgets spent on different media channels and the
corresponding sales generated. It is commonly used for regression analysis and predictive
modeling.
The primary objective of this dataset is to analyze how advertising investments influence
sales performance and to develop a predictive model capable of estimating sales based on
advertising expenditure.
The dataset consists of 200 records and 5 attributes. Each record represents advertising
expenditure across different media channels along with the corresponding sales value. In this
project, Television (TV) advertising expenditure was selected as the independent variable,
while Sales was considered the dependent variable for implementing Simple Linear
Regression.
Dataset Information:
• Number of Records: 200
• Number of Attributes: 5
• Independent Variable: TV Advertising Expenditure
• Dependent Variable: Sales
• Type of Problem: Regression
The dataset contains the following attributes:
1. Unnamed: 0 – Serial number or index of the record.
2. TV – Advertising budget spent on television advertisements.
3. Radio – Advertising budget spent on radio advertisements.
4. Newspaper – Advertising budget spent on newspaper advertisements.
5. Sales – Sales generated as a result of advertising activities.
5
The Advertising Dataset provides valuable insights into the impact of marketing expenditure
on product sales. By analyzing the relationship between advertising spending and sales,
businesses can improve marketing strategies, optimize budgets, and make informed business
decisions.
Attribute Description
Unnamed: 0 Record Index
TV Television advertising expenditure
Radio Radio advertising expenditure
Newspaper Newspaper advertising expenditure
Sales Product sales
Table 3.1 : Attributes and Description
Figure 3.1: Dataset Information
6
4. METHODOLOGY
The methodology followed in this project involves a series of steps including data loading,
data exploration, feature selection, model training, prediction, and performance evaluation.
The objective is to study the relationship between advertising expenditure and sales using a
Simple Linear Regression model.
4.1 Data Loading
The Advertising Dataset was loaded into the Python environment using the Pandas library.
The dataset was stored in CSV format and imported into a DataFrame for analysis. Initial
exploration was performed using functions such as head(), shape(), info(), and describe() to
understand the dataset structure and statistical properties.
4.2 Data Exploration
The dataset was examined to identify the available features and check for missing values.
The analysis showed that the dataset contained 200 records and 5 attributes. No missing
values were found, indicating that the dataset was clean and suitable for regression analysis.
4.3 Feature Selection
For implementing Simple Linear Regression, only one independent variable and one
dependent variable are required. In this project, TV advertising expenditure was selected as
the independent variable (X), while Sales was selected as the dependent variable (y). The
selected variables were extracted from the dataset and prepared for model training.
Figure 4.1: Feature Selection for Linear Regression
7
4.4 Train-Test Split
The dataset was divided into training and testing sets using the train_test_split() function
from the Scikit-learn library. Eighty percent of the data was used for training the model,
while the remaining twenty percent was reserved for testing. This approach helps evaluate
the model on unseen data and measure its predictive performance.
4.5 Model Training
A Simple Linear Regression model was implemented using the LinearRegression class from
Scikit-learn. The model was trained using the training dataset to learn the relationship
between television advertising expenditure and product sales. During training, the model
estimated the best-fit line representing the relationship between the selected variables.
Figure 4.2: Linear Regression Model Training
After training, the model was used to predict sales values for the testing dataset. These
predictions were then compared with the actual sales values to assess the model's
performance.
4.7 Model Evaluation
The performance of the model was evaluated using Mean Absolute Error (MAE), Mean
Squared Error (MSE), and R² Score. These metrics provide information about prediction
accuracy and the strength of the relationship between advertising expenditure and sales. A
scatter plot with the regression line was also generated to visualize the linear relationship
between the variables.
8
5. RESULTS AND DISCUSSION
After training the Simple Linear Regression model, predictions were generated for the
testing dataset. The model learned the relationship between television advertising
expenditure and product sales and was able to estimate sales values for unseen data.
The predicted sales values were compared with the actual sales values to evaluate the
performance of the model. The first few predicted values indicated that the model
successfully captured the general trend between advertising expenditure and sales.
To measure the effectiveness of the model, three evaluation metrics were used: Mean
Absolute Error (MAE), Mean Squared Error (MSE), and R² Score. The Mean Absolute Error
measures the average difference between predicted and actual values. The Mean Squared
Error measures the average squared prediction error, while the R² Score indicates how well
the independent variable explains the variation in the dependent variable.
The model achieved a Mean Absolute Error (MAE) of 2.44, a Mean Squared Error (MSE)
of 10.20, and an R² Score of 0.6767. The R² Score indicates that approximately 67.67% of
the variation in sales can be explained by television advertising expenditure. This
demonstrates a positive linear relationship between advertising investment and sales
performance.
A scatter plot with the regression line was also generated to visualize the relationship
between TV advertising expenditure and sales. The graph clearly shows an upward trend,
indicating that higher advertising expenditure generally leads to increased sales. The
visualization confirms the effectiveness of the Simple Linear Regression model in analyzing
and predicting sales based on advertising data.
Overall, the results demonstrate that television advertising has a significant influence on
product sales and that Simple Linear Regression can be effectively used for sales prediction
and business analytics.
9
Figure 5.1 : Sample sales Prediction
Figure 5.2: Linear Relationship Between TV Advertising and Sales
10
6. CONCLUSION
In this project, a Simple Linear Regression model was successfully developed to analyze
the relationship between television advertising expenditure and product sales. The
Advertising Dataset was explored and prepared for machine learning analysis. Television
advertising expenditure was selected as the independent variable, while sales was
considered the dependent variable.
The dataset was divided into training and testing sets, and the Linear Regression model
was trained using the Scikit-learn library. The model was evaluated using Mean Absolute
Error (MAE), Mean Squared Error (MSE), and R² Score. The obtained results showed that
the model achieved an MAE of 2.44, an MSE of 10.20, and an R² Score of 0.6767,
indicating a strong positive relationship between television advertising expenditure and
sales.
The regression graph further confirmed that sales tend to increase as advertising
expenditure increases. The model was able to capture the overall trend in the data and
provide reasonably accurate sales predictions.
This project demonstrates the practical application of Simple Linear Regression in business
analytics and sales forecasting. The developed model can help organizations understand
the impact of advertising on sales and support data-driven decision-making for marketing
strategies and budget planning.
11