Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

ABSTRACT

Nowadays shopping malls and Big Marts keep the track of their
sales data of each and every individual item for predicting future
demand of the customer and update the inventory management
as well. These data stores basically contain a large number of
customer data and individual item attributes in a data warehouse.
Further, anomalies and frequent patterns are detected by mining
the data store from the data warehouse. The resultant data can
be used for predicting future sales volume with the help of
different machine learning techniques for the retailers like Big
Mart. In this paper, we propose a predictive model using XG
boost Regressor technique for predicting the sales of a company
like Big Mart and found that the model produces better
performance as compared to existing models.

1
CONTENT
Chapter List of content Page no.
I Abstract 1
Ii List of acronyms
Iii List of figures
1 Introduction
2 Literature Survey 13
3 System Requirements 17
3.1 Hardware Requirements
3.2 Software Requirements
3.3 Language Specification
3.4 History of python
4 System Analysis 33
4.1 Purpose
4.2 Scope
4.3 Existing System
4.4 Proposed System
5 System Design 36
5.1 Input Design
5.2 Output Design
5.3 Data Flow Diagram
6 Module Implementations 42
6.1 Modules
6.1.1 Data Collection
6.1.2 Data Set
6.1.3 Data Preparation
6.1.4 Model Selection
6.1.5 Analyze and Prediction
6.1.6 Accuracy on Test Set
6.1.7 Saving the Training Model
7 System Implementation 47
8 System Testing 48
8.1 Unit Testing
8.2 Integration Testing

2
8.3 Functional Testing
8.4 System Test
8.5 White Box Testing
8.6 Black Box Testing
8.7 Acceptance Testing
9 Results And Discussion 53

10 Conclusion 56

11 References 57

LIST OF FIGURES:

FIGURE NO. FIGURE NAME PAGE NO.

7.1 System Architecture 47

9.2 Data collection from kaggle 54

9.4 prediction of sales 55

9.6 performance values of proposed 56

model

3
CHAPTER 1

INTRODUCTION
Big Mart is a big supermarket chain, with stores all around the country and its current
board set out a challenge to all Data Scientist out there to help them create a model that
can predict the sales, per product, for each store to give accurate results. Big Mart has
collected sales data from Kaggle, for various products across different stores in different
cities. With this information the corporation hopes we can identify the products and
stores which play a key role in their sales and use that information to take the correct
measures to ensure success of their business.

1.1 PROPOSED ALGORITHMS

Decision Trees are a type of Supervised Machine Learning (that is you explain what the
input is and what the corresponding output is in the training data) where the data is
continuously split according to a certain parameter. The tree can be explained by two
entities, namely decision nodes and leaves. The leaves are the decisions or the final
outcomes. And the decision nodes are where the data is split.

4
An example of a decision tree can be explained using above binary tree. Let‟s say you
want to predict whether a person is fit given their information like age, eating habit, and
physical activity, etc. The decision nodes here are questions like „What‟s the age?‟,
„Does he exercise?‟, „Does he eat a lot of pizzas‟? And the leaves, which are outcomes
like either „fit‟, or „unfit‟. In this case this was a binary classification problem (a yes no
type problem).

There are two main types of Decision Trees:

Classification trees (Yes/No types)

What we‟ve seen above is an example of classification tree, where the outcome was a
variable like „fit‟ or „unfit‟. Here the decision variable is Categorical.

Regression trees (Continuous data types)

Here the decision or the outcome variable is Continuous, e.g. a number like 123.

Working

Now that we know what a Decision Tree is, we‟ll see how it works internally. There are
many algorithms out there which construct Decision Trees, but one of the best is called
as ID3 Algorithm. ID3 Stands for Iterative Dichotomiser 3.

Before discussing the ID3 algorithm, we‟ll go through few definitions.

o Decision Tree is a Supervised learning technique that can be used for both
classification and Regression problems, but mostly it is preferred for solving
Classification problems. It is a tree-structured classifier, where internal nodes
represent the features of a dataset, branches represent the decision
rules and each leaf node represents the outcome.
o In a Decision tree, there are two nodes, which are the Decision Node and Leaf
Node. Decision nodes are used to make any decision and have multiple
branches, whereas Leaf nodes are the output of those decisions and do not
contain any further branches.

5
o The decisions or the test are performed on the basis of features of the given
dataset.
o It is a graphical representation for getting all the possible solutions to a
problem/decision based on given conditions.
o It is called a decision tree because, similar to a tree, it starts with the root node,
which expands on further branches and constructs a tree-like structure.
o In order to build a tree, we use the CART algorithm, which stands
for Classification and Regression Tree algorithm.
o A decision tree simply asks a question, and based on the answer (Yes/No), it
further split the tree into subtrees.
o Below diagram explains the general structure of a decision tree:

Note: A decision tree can contain categorical data (YES/NO) as well as numeric data.

Why use Decision Trees?

6
There are various algorithms in Machine learning, so choosing the best algorithm for the
given dataset and problem is the main point to remember while creating a machine
learning model. Below are the two reasons for using the Decision tree:

o Decision Trees usually mimic human thinking ability while making a decision, so
it is easy to understand.
o The logic behind the decision tree can be easily understood because it shows a
tree-like structure.

Decision Tree Terminologies

Root Node: Root node is from where the decision tree starts. It represents the entire
dataset, which further gets divided into two or more homogeneous sets.
Leaf Node: Leaf nodes are the final output node, and the tree cannot be segregated
further after getting a leaf node.
Splitting: Splitting is the process of dividing the decision node/root node into sub-
nodes according to the given conditions.
Branch/Sub Tree: A tree formed by splitting the tree.
Pruning: Pruning is the process of removing the unwanted branches from the tree.
Parent/Child node: The root node of the tree is called the parent node, and other
nodes are called the child nodes.

How does the Decision Tree algorithm Work?

In a decision tree, for predicting the class of the given dataset, the algorithm starts from
the root node of the tree. This algorithm compares the values of root attribute with the
record (real dataset) attribute and, based on the comparison, follows the branch and
jumps to the next node.

For the next node, the algorithm again compares the attribute value with the other sub-
nodes and move further. It continues the process until it reaches the leaf node of the
tree. The complete process can be better understood using the below algorithm:

7
Competitive questions on Structures in Hindi
Keep Watching

o Step-1: Begin the tree with the root node, says S, which contains the complete
dataset.
o Step-2: Find the best attribute in the dataset using Attribute Selection Measure
(ASM).
o Step-3: Divide the S into subsets that contains possible values for the best
attributes.
o Step-4: Generate the decision tree node, which contains the best attribute.
o Step-5: Recursively make new decision trees using the subsets of the dataset
created in step -3. Continue this process until a stage is reached where you
cannot further classify the nodes and called the final node as a leaf node.

Example: Suppose there is a candidate who has a job offer and wants to decide
whether he should accept the offer or Not. So, to solve this problem, the decision tree
starts with the root node (Salary attribute by ASM). The root node splits further into the
next decision node (distance from the office) and one leaf node based on the
corresponding labels. The next decision node further gets split into one decision node
(Cab facility) and one leaf node. Finally, the decision node splits into two leaf nodes
(Accepted offers and Declined offer). Consider the below diagram:

8
Attribute Selection Measures

While implementing a Decision tree, the main issue arises that how to select the best
attribute for the root node and for sub-nodes. So, to solve such problems there is a
technique which is called as Attribute selection measure or ASM. By this
measurement, we can easily select the best attribute for the nodes of the tree. There
are two popular techniques for ASM, which are:

o Information Gain
o Gini Index

1. Information Gain:

o Information gain is the measurement of changes in entropy after the


segmentation of a dataset based on an attribute.
o It calculates how much information a feature provides us about a class.

9
o According to the value of information gain, we split the node and build the
decision tree.
o A decision tree algorithm always tries to maximize the value of information gain,
and a node/attribute having the highest information gain is split first. It can be
calculated using the below formula:

1. Information Gain= Entropy(S)- [(Weighted Avg) *Entropy(each feature)

Entropy: Entropy is a metric to measure the impurity in a given attribute. It specifies


randomness in data. Entropy can be calculated as:

Entropy(s)= -P(yes)log2 P(yes)- P(no) log2 P(no)

Where,

o S= Total number of samples


o P(yes)= probability of yes
o P(no)= probability of no

2. Gini Index:

o Gini index is a measure of impurity or purity used while creating a decision tree in
the CART(Classification and Regression Tree) algorithm.
o An attribute with the low Gini index should be preferred as compared to the high
Gini index.
o It only creates binary splits, and the CART algorithm uses the Gini index to
create binary splits.
o Gini index can be calculated using the below formula:

Gini Index= 1- ∑jPj2

Pruning: Getting an Optimal Decision tree

10
Pruning is a process of deleting the unnecessary nodes from a tree in order to get the
optimal decision tree.

A too-large tree increases the risk of overfitting, and a small tree may not capture all the
important features of the dataset. Therefore, a technique that decreases the size of the
learning tree without reducing accuracy is known as Pruning. There are mainly two
types of tree pruning technology used:

o Cost Complexity Pruning


o Reduced Error Pruning.

Advantages of the Decision Tree

o It is simple to understand as it follows the same process which a human follow


while making any decision in real-life.
o It can be very useful for solving decision-related problems.
o It helps to think about all the possible outcomes for a problem.
o There is less requirement of data cleaning compared to other algorithms.

Disadvantages of the Decision Tree

o The decision tree contains lots of layers, which makes it complex.


o It may have an overfitting issue, which can be resolved using the Random
Forest algorithm.
o For more class labels, the computational complexity of the decision tree may
increase.
o

CHAPTER 2
LITERATURE SURVEY

11

You might also like