Link to the program and Datasets is given below
Market Basket Analysis helps companies understand how their customers make purchases. The objective is to help to configure sales promotions, loyalty programs, and store layout.
Market basket analysis studies the concept of affinity. Affinity is the natural liking or understanding of something. It can also mean the degree to which something tends to combine with another. To perform market basket analysis, we need a data set of transactions. Each transaction consists of a group of products that were bought together. Let’s say that I visited a supermarket and bought yogurt, milk, pens, cheese, and paper. These products were bought in a single transaction. The transactions are then gathered and analyzed to identify rules of association.
So now, How can we determine the strength of the association? To answer this question, we need to consider three metrics:
Support (X -> Y) = Support (X ∪ Y)
Confidence (X -> Y) = Support (X -> Y) / Support (X)
Lift (X -> Y) = Support (X -> Y) / Support (X) * Support (Y)
Finding frequent item-sets is one of the most investigated fields of data mining. The Apriori algorithm is the most established algorithm for Frequent Item-sets Mining (FIM).
A set of items that appears in many baskets is said to be “frequent.” To be formal, we assume there is a number s, called the support threshold. If I is a set of items, the support for I is the number of baskets for which I is a subset. We say I is frequent if its support is s or more.
Let’s consider a simple example. Consider the transactions for the following items
Next consider the rule that item/itemset is frequently purchased if it occurs at least 50% of the times. So here it should be bought at least 2 times.
For simplicity, let’s abbreviate the items as follows;
Apple-A
Mango-M
Pears-P
Cabbage-Ca
Carrots-Cr
So the table now becomes
Step 1: Count the number of transactions in which each item occurs
Step 2: Now remove all the items that are purchased less than 2 times. So the new table becomes
Step 3: Start making pairs of the items from step 2 with each other
Note: Itemset PM,CaP, CrP are the same as MP, PCa,PCr so they are not included in step 3.
Step 4: Now we count how many times each pair as shown in Step 3 occurs in Table 1.
Step 5: Look at the question- it states that consider the itemset that is purchased at least 2 times or 50% of the times.
Applying this rule on Step 4 will reduce the table to the following;
So this table shows that the following items MP (Mango and Pears), MCa (Mango and Cabbage) and MCr (Mango and Carrots) are purchased together at least 50% of the times.
I hope that by now you are somewhat clear on how these notations are used in machine learning. If we simplify the above into words, then we can say that:
We want to build a linear model with the combination of features in x and predict the scalar values in y.
When we consider a simple linear regression, that is, a single x and a single y, then we can write,
y=β0+β1x
where β0 is the intercept parameter and β1 is the slope parameter.
If you analyze the above equation, then you may find that it is the same as the equation of a line:
y=mx+c
where m is the slope and c is the y-intercept.
For now, we just need to keep in mind that the above equations are for single-valued x. We will again come back to these to learn how actually they are used in machine learning. First, let’s discuss what is simple linear regression and what is multiple linear regression.
First, we will load the packages required for our program.
Input:-
Output:-
Input:-
Output:-
Click here to download the Program and Datasets…
Thinksprout Infotech is leading IT Solutions company providing excellent services with great efforts. The Company also deals in Online Application and Custom Software Development. Moreover, we have an extensively experienced team in programming databases and back-end solutions. In the same vein, we develop user-friendly applications for our clients for better operations and outputs.
Thinksprout Infotech is leading IT Solutions company providing excellent services with great efforts. The Company also deals in Online Application and Custom Software Development. Moreover, we have an extensively experienced team in programming databases and back-end solutions. In the same vein, we develop user-friendly applications for our clients for better operations and outputs.