﻿1
00:00:00,266 --> 00:00:01,233
All right, my friends.

2
00:00:01,233 --> 00:00:02,466
Are you ready to.

3
00:00:02,466 --> 00:00:05,100
Train your primary model on the whole.

4
00:00:05,100 --> 00:00:06,300
Data set?

5
00:00:06,300 --> 00:00:07,833
Well, I bet you are.

6
00:00:07,833 --> 00:00:10,333
Because, indeed,
we actually did. The most.

7
00:00:10,333 --> 00:00:13,000
Difficult. Parts.
You know, the most. Difficult part was to.

8
00:00:13,000 --> 00:00:17,366
Make that transaction's list containing
all the different transactions of our.

9
00:00:17,400 --> 00:00:18,000
Data set.

10
00:00:18,000 --> 00:00:21,500
You know, to 7501 transactions.

11
00:00:21,733 --> 00:00:22,333
We all.

12
00:00:22,333 --> 00:00:25,800
Put them into this transactions
list with strings for.

13
00:00:25,800 --> 00:00:26,933
Each of the products.

14
00:00:26,933 --> 00:00:28,500
And this transactions list.

15
00:00:28,500 --> 00:00:31,233
Will be the input of the primary.

16
00:00:31,233 --> 00:00:35,766
Function, which we will use right now to
train the primary model on this data set.

17
00:00:36,000 --> 00:00:37,633
And so that's what I'm talking about.

18
00:00:37,633 --> 00:00:38,400
Most of.

19
00:00:38,400 --> 00:00:40,833
The job. Is done
because now the only thing that we.

20
00:00:40,833 --> 00:00:43,066
Have to do is just call this primary.

21
00:00:43,066 --> 00:00:45,933
Function from this a. Binary package.

22
00:00:45,933 --> 00:00:50,133
Which we installed in the first cell
and call that function with some relevant.

23
00:00:50,133 --> 00:00:52,100
Values of the. Parameters.

24
00:00:52,100 --> 00:00:54,200
And that will be most of the.

25
00:00:54,200 --> 00:00:56,966
Reflection will have when building
and training this.

26
00:00:56,966 --> 00:00:59,500
Apriori. Model. All right. Are you ready?

27
00:00:59,500 --> 00:01:00,400
Let's do this.

28
00:01:00,400 --> 00:01:03,200
Let's create a new code cell.

29
00:01:03,200 --> 00:01:08,633
So the first thing to do will be to import
effectively that a primary function.

30
00:01:08,633 --> 00:01:11,533
Because so far.
Make sure to understand that we.

31
00:01:11,533 --> 00:01:14,400
Only installed the primary package but we.

32
00:01:14,400 --> 00:01:16,133
Haven't imported anything.

33
00:01:16,133 --> 00:01:20,400
The only libraries we import
were numpy, matplotlib and pandas.

34
00:01:20,566 --> 00:01:21,333
So now we need.

35
00:01:21,333 --> 00:01:24,433
Indeed to upload this a primary.

36
00:01:24,433 --> 00:01:26,966
Function.
And this primary function belongs.

37
00:01:26,966 --> 00:01:30,066
To the binary package
which we installed first.

38
00:01:30,233 --> 00:01:30,933
Therefore we need to.

39
00:01:30,933 --> 00:01:32,566
Start. From.

40
00:01:32,566 --> 00:01:35,566
That a binary package.

41
00:01:35,666 --> 00:01:36,900
There you go from.

42
00:01:36,900 --> 00:01:38,666
Which we import.

43
00:01:38,666 --> 00:01:41,666
That a primary function. All right.

44
00:01:41,966 --> 00:01:43,933
There we go again a primary.

45
00:01:43,933 --> 00:01:46,933
And now now we can call that function.

46
00:01:47,100 --> 00:01:47,366
All right.

47
00:01:47,366 --> 00:01:49,833
So first thing to understand
is that this function will.

48
00:01:49,833 --> 00:01:51,766
Actually return the rules.

49
00:01:51,766 --> 00:01:55,033
You know not only will train
the primary model on the data.

50
00:01:55,033 --> 00:01:55,966
Set, but also at.

51
00:01:55,966 --> 00:01:58,100
The same time
this function will indeed train

52
00:01:58,100 --> 00:02:01,500
this primary model
and in the end return the final rules,

53
00:02:01,500 --> 00:02:04,700
you know, with the different supports,
confidences and lifts.

54
00:02:04,966 --> 00:02:06,366
And therefore, since we're now.

55
00:02:06,366 --> 00:02:08,400
Ready to call. This function, and since.

56
00:02:08,400 --> 00:02:12,200
This function returns the rules,
well, let's create a new variable here

57
00:02:12,300 --> 00:02:14,833
which we're simply. Going to. Call rules.

58
00:02:14,833 --> 00:02:15,300
All right.

59
00:02:15,300 --> 00:02:18,300
And that will be the output
of that function.

60
00:02:18,300 --> 00:02:20,066
And speaking of that function well let's.

61
00:02:20,066 --> 00:02:22,433
Call it. Right now. A priori.

62
00:02:22,433 --> 00:02:23,600
That's the function.

63
00:02:23,600 --> 00:02:25,766
Therefore I'm adding some parentheses.

64
00:02:25,766 --> 00:02:26,966
And now there we go.

65
00:02:26,966 --> 00:02:29,966
Let's see what parameters
we have to input.

66
00:02:30,533 --> 00:02:30,866
All right.

67
00:02:30,866 --> 00:02:35,733
So this function takes as input
some very intuitive arguments.

68
00:02:35,733 --> 00:02:38,533
We could actually you know almost guess
all of them.

69
00:02:38,533 --> 00:02:39,600
The first one is of course.

70
00:02:39,600 --> 00:02:41,700
Well the data sets.
You know, the. Data set.

71
00:02:41,700 --> 00:02:44,400
On which you're going to train your.
A priori. Model.

72
00:02:44,400 --> 00:02:47,266
And the name for that
parameter is transactions.

73
00:02:47,266 --> 00:02:49,933
Actually,
you know. Because the. Primary model is.

74
00:02:49,933 --> 00:02:51,600
Mostly used to.

75
00:02:51,600 --> 00:02:54,466
Compute
some correlations and association. Rules.

76
00:02:54,466 --> 00:02:56,000
Among transactions.

77
00:02:56,000 --> 00:02:58,500
So that's actually
the name of the parameter.

78
00:02:58,500 --> 00:02:59,566
And of course the value.

79
00:02:59,566 --> 00:03:01,533
For that parameter must. Be well that.

80
00:03:01,533 --> 00:03:03,600
Same transactions.

81
00:03:03,600 --> 00:03:06,266
List which we created.

82
00:03:06,266 --> 00:03:07,666
In the right format.

83
00:03:07,666 --> 00:03:09,633
Right before this tutorial. In the.

84
00:03:09,633 --> 00:03:11,033
Data preprocessing phase.

85
00:03:11,033 --> 00:03:12,900
Okay.
So this is the name of the parameter.

86
00:03:12,900 --> 00:03:14,966
And this is the name of our transactions.

87
00:03:14,966 --> 00:03:17,966
List which is the value of that parameter.

88
00:03:18,366 --> 00:03:20,400
Okay. Good.
So that's for the first argument.

89
00:03:20,400 --> 00:03:21,866
That was an obvious one.

90
00:03:21,866 --> 00:03:22,466
And now.

91
00:03:22,466 --> 00:03:24,233
According to you what would.

92
00:03:24,233 --> 00:03:26,233
Be the next argument.

93
00:03:26,233 --> 00:03:27,866
Well, the next argument has to do.

94
00:03:27,866 --> 00:03:29,200
With the support.

95
00:03:29,200 --> 00:03:30,133
Of course, it's

96
00:03:30,133 --> 00:03:34,400
not going to be a simple support
because we have a support for each rule.

97
00:03:34,500 --> 00:03:37,333
But what we can set is actually.

98
00:03:37,333 --> 00:03:40,900
A minimum support,
you know, in order not to compute.

99
00:03:40,900 --> 00:03:43,800
All the rules,
but only the rules that have at least.

100
00:03:43,800 --> 00:03:45,300
Some certain relevance.

101
00:03:45,300 --> 00:03:46,700
And therefore we will.

102
00:03:46,700 --> 00:03:49,200
Set a minimum support. Value.

103
00:03:49,200 --> 00:03:50,300
In order to take not.

104
00:03:50,300 --> 00:03:53,400
All the rules, but only the rules
that have a support higher.

105
00:03:53,400 --> 00:03:55,500
Than this minimum. Support.

106
00:03:55,500 --> 00:03:57,633
All right. So let's first. Enter
the name of the.

107
00:03:57,633 --> 00:03:58,633
Parameter here, which.

108
00:03:58,633 --> 00:04:00,900
Is min underscore.

109
00:04:00,900 --> 00:04:03,433
Support. Right.

110
00:04:03,433 --> 00:04:04,033
And now.

111
00:04:04,033 --> 00:04:06,600
According to you what should we choose.

112
00:04:06,600 --> 00:04:08,400
As a minimum support. Here.

113
00:04:08,400 --> 00:04:11,700
Well this has to do
of course with our situation.

114
00:04:11,700 --> 00:04:15,066
You know the problem itself
and of course some common sense.

115
00:04:15,400 --> 00:04:16,733
So let's recap.

116
00:04:16,733 --> 00:04:21,366
We have in total 7501 transactions.

117
00:04:21,366 --> 00:04:24,366
That were recorded over. One full week.

118
00:04:24,466 --> 00:04:29,866
And among these 7501 transactions,
we want to get the most relevant rules.

119
00:04:29,866 --> 00:04:33,866
You know, the were, you know, the.

120
00:04:33,866 --> 00:04:35,533
Strongest rules of two.

121
00:04:35,533 --> 00:04:38,866
Elements, you know, with one element
of the left hand side of the rule,

122
00:04:38,866 --> 00:04:41,966
you know, one product and one element
in the right hand side of the.

123
00:04:41,966 --> 00:04:43,833
Rule, which is another product.

124
00:04:43,833 --> 00:04:46,000
And we want. Therefore, these products to.

125
00:04:46,000 --> 00:04:47,733
Appear a minimum amount of time.

126
00:04:47,733 --> 00:04:50,200
And that's exactly
what the support is about.

127
00:04:50,200 --> 00:04:51,300
Remember the support.

128
00:04:51,300 --> 00:04:53,400
Of a couple of products A and B.

129
00:04:53,400 --> 00:04:55,966
Is the number of transactions containing.

130
00:04:55,966 --> 00:04:56,433
These two.

131
00:04:56,433 --> 00:04:57,500
Products A and B.

132
00:04:57,500 --> 00:04:58,666
Divided by the total.

133
00:04:58,666 --> 00:05:00,600
Number of transactions.

134
00:05:00,600 --> 00:05:02,000
So we need to see here.

135
00:05:02,000 --> 00:05:02,700
You know, for.

136
00:05:02,700 --> 00:05:04,500
A couple of products A and B.

137
00:05:04,500 --> 00:05:06,500
How many tons per. Week.

138
00:05:06,500 --> 00:05:08,300
We need to have at.
Least these two products.

139
00:05:08,300 --> 00:05:09,866
In the transactions.

140
00:05:09,866 --> 00:05:12,366
Well you know. Let's.
Do some common sense.

141
00:05:12,366 --> 00:05:15,333
Let's say that each day
we would like to consider

142
00:05:15,333 --> 00:05:18,366
the products
that appear in at least three.

143
00:05:18,433 --> 00:05:20,366
Transactions in the day.

144
00:05:20,366 --> 00:05:20,700
All right.

145
00:05:20,700 --> 00:05:21,966
Three transactions in a day.

146
00:05:21,966 --> 00:05:24,066
Because all the products that appear.

147
00:05:24,066 --> 00:05:27,166
In only one transaction
or two transactions, you know,

148
00:05:27,166 --> 00:05:31,000
are actually not frequent,
and we would not build some strong rules.

149
00:05:31,200 --> 00:05:32,466
Out of these products.

150
00:05:32,466 --> 00:05:34,000
So our common sense here.

151
00:05:34,000 --> 00:05:35,400
Is to. Only consider the.

152
00:05:35,400 --> 00:05:37,333
Products that appear at least.

153
00:05:37,333 --> 00:05:38,833
Three times a day.

154
00:05:38,833 --> 00:05:39,766
And therefore.

155
00:05:39,766 --> 00:05:43,133
Since the 7501 transactions.

156
00:05:43,133 --> 00:05:45,266
Were recorded. During the full. Week.

157
00:05:45,266 --> 00:05:48,100
Well, we need to multiply this number
of three transactions.

158
00:05:48,100 --> 00:05:48,966
Per day by.

159
00:05:48,966 --> 00:05:52,566
Seven in order to get, you know,
that minimum number of times.

160
00:05:52,566 --> 00:05:55,566
We want to see these products
in the transactions per week.

161
00:05:55,633 --> 00:05:59,566
And therefore that number of times
is three times seven equals 21.

162
00:05:59,833 --> 00:06:01,766
And since the. Support is.

163
00:06:01,766 --> 00:06:03,233
The number of times the. Products.

164
00:06:03,233 --> 00:06:06,866
Appear in the transactions divided
by the total number of transactions.

165
00:06:07,000 --> 00:06:09,066
Well. The minimum. Support.

166
00:06:09,066 --> 00:06:11,366
Considering that we want to see minimum
three times.

167
00:06:11,366 --> 00:06:13,733
Per day, the products must be.

168
00:06:13,733 --> 00:06:14,900
Three times seven.

169
00:06:14,900 --> 00:06:17,900
Divided by. 7000 and 501.

170
00:06:17,966 --> 00:06:18,266
All right.

171
00:06:18,266 --> 00:06:19,533
So that's purely.

172
00:06:19,533 --> 00:06:20,900
Based on common sense.

173
00:06:20,900 --> 00:06:22,966
You could choose another minimum support.

174
00:06:22,966 --> 00:06:24,866
But there you go.
That's the minimum support.

175
00:06:24,866 --> 00:06:26,700
That goes well with our scenario.

176
00:06:26,700 --> 00:06:29,033
You know with our business. Case study.

177
00:06:29,033 --> 00:06:31,466
And therefore
what I'm simply going to do now.

178
00:06:31,466 --> 00:06:35,166
Is just open a new tab
here to quickly compute.

179
00:06:35,300 --> 00:06:38,100
Well, three as. In minimum
three times one.

180
00:06:38,100 --> 00:06:40,900
To see the products
appear. In the transactions per. Day.

181
00:06:40,900 --> 00:06:43,066
Then times seven.

182
00:06:43,066 --> 00:06:46,200
Because. The 7501 transactions are.

183
00:06:46,333 --> 00:06:47,800
Recorded over a week.

184
00:06:47,800 --> 00:06:49,833
And therefore,
when calculating the support

185
00:06:49,833 --> 00:06:52,033
and dividing by the total number
of transactions,

186
00:06:52,033 --> 00:06:53,833
the numerator and the denominator

187
00:06:53,833 --> 00:06:57,866
must be in the same unit of time,
which is one week, and then divided.

188
00:06:57,866 --> 00:06:58,833
By seven.

189
00:06:58,833 --> 00:07:01,133
Thousand 501.

190
00:07:01,133 --> 00:07:02,666
Total. Transactions.

191
00:07:02,666 --> 00:07:03,233
There's just press.

192
00:07:03,233 --> 00:07:03,866
Enter.

193
00:07:03,866 --> 00:07:06,300
We'll get the result which is oh point.

194
00:07:06,300 --> 00:07:08,100
Oh 27.

195
00:07:08,100 --> 00:07:11,100
And we can round that up to 0.03.

196
00:07:11,266 --> 00:07:15,233
And 0.03
will be exactly our minimum support.

197
00:07:15,633 --> 00:07:16,833
So I'm going to close this.

198
00:07:16,833 --> 00:07:17,700
And I'm going to enter.

199
00:07:17,700 --> 00:07:20,800
Here 0.003.

200
00:07:21,333 --> 00:07:24,333
Perfect.
So that's for. Our minimum support.

201
00:07:24,433 --> 00:07:26,600
Now the next argument what do you think.

202
00:07:26,600 --> 00:07:27,433
It's going to be.

203
00:07:27,433 --> 00:07:29,633
Well you probably guess that this.

204
00:07:29,633 --> 00:07:33,333
Time we're going to choose a minimum
confidence.

205
00:07:33,766 --> 00:07:36,566
Right. A minimum confidence.

206
00:07:36,566 --> 00:07:39,000
All right.
So this time what. Should we set.

207
00:07:39,000 --> 00:07:40,433
As the minimum confidence.

208
00:07:40,433 --> 00:07:43,066
Should we use. Again
common sense. Or should we.

209
00:07:43,066 --> 00:07:44,666
Try some different values.

210
00:07:44,666 --> 00:07:48,333
Well this time we won't do the same kind
of calculation as we did for the support.

211
00:07:48,700 --> 00:07:51,600
This time I'm rather going
to give you some rule of sums.

212
00:07:51,600 --> 00:07:54,600
You know, which you can try
when doing association rule learning.

213
00:07:54,933 --> 00:07:55,833
So I.

214
00:07:55,833 --> 00:07:58,133
Know from the other packages,
you know the one from.

215
00:07:58,133 --> 00:07:59,700
R, because there is actually.

216
00:07:59,700 --> 00:08:02,666
A great function
in. Order to do association. Learning.

217
00:08:02,666 --> 00:08:04,800
And it. Has indeed a default value.

218
00:08:04,800 --> 00:08:07,733
For the minimum confidence. Which is 0.8.

219
00:08:07,733 --> 00:08:10,200
So what I actually. Did, you know, for
this problem.

220
00:08:10,200 --> 00:08:14,066
Is to start first with 0.8,
but this was way too high

221
00:08:14,066 --> 00:08:17,366
because 0.88 would require the rule
to be correct 80.

222
00:08:17,366 --> 00:08:18,400
Percent of the time.

223
00:08:18,400 --> 00:08:21,066
And therefore I ended up
with actually no rule.

224
00:08:21,066 --> 00:08:23,433
So I had to reduce the confidence.

225
00:08:23,433 --> 00:08:25,333
So I. Divided by two so.

226
00:08:25,333 --> 00:08:28,333
That I can try
a minimum confidence of 0.4.

227
00:08:28,400 --> 00:08:30,400
But still I got very few rules.

228
00:08:30,400 --> 00:08:32,333
And so I divided by two again.

229
00:08:32,333 --> 00:08:32,700
And this.

230
00:08:32,700 --> 00:08:35,933
With 0.2,
I actually got. Some. Great rules.

231
00:08:35,933 --> 00:08:38,800
You know, not too much,
not too. Few, but a. Dozen of them.

232
00:08:38,800 --> 00:08:39,900
So that was a good choice.

233
00:08:39,900 --> 00:08:40,300
And that's.

234
00:08:40,300 --> 00:08:41,933
How I chose. This minimum.

235
00:08:41,933 --> 00:08:44,200
Confidence. Therefore here for this.

236
00:08:44,200 --> 00:08:47,166
Minimum confidence
we will. Set it equal to oh.

237
00:08:47,166 --> 00:08:48,366
Point two.

238
00:08:48,366 --> 00:08:50,500
Okay. Once again no rule of thumb.

239
00:08:50,500 --> 00:08:53,766
You can try different values
depending on your business requirements.

240
00:08:54,366 --> 00:08:54,966
All right.

241
00:08:54,966 --> 00:08:56,066
Then next.

242
00:08:56,066 --> 00:08:58,200
Parameter I'm sure you guessed it as well.

243
00:08:58,200 --> 00:09:01,066
That is this time the minimum lift.

244
00:09:01,066 --> 00:09:02,233
You know that other.

245
00:09:02,233 --> 00:09:03,300
Metric which.

246
00:09:03,300 --> 00:09:06,600
Measures the quality of a rule
or the relevance of a rule?

247
00:09:06,933 --> 00:09:07,466
And so now.

248
00:09:07,466 --> 00:09:09,700
According to you, what would be a good.

249
00:09:09,700 --> 00:09:10,800
Minimum lift?

250
00:09:10,800 --> 00:09:11,633
Well, that.

251
00:09:11,633 --> 00:09:14,633
Kind of decision to make,
you know, you give them with experience.

252
00:09:14,733 --> 00:09:16,233
You will see through the.

253
00:09:16,233 --> 00:09:18,000
Many. Association rule.

254
00:09:18,000 --> 00:09:20,033
Learning models
that you're going to build on your data.

255
00:09:20,033 --> 00:09:25,500
Sets, that generally a good lift
is at least three, you know, 3456.

256
00:09:25,500 --> 00:09:27,600
7789. You know, these are.

257
00:09:27,600 --> 00:09:30,366
Good lifts, but lift below three.

258
00:09:30,366 --> 00:09:32,066
Make the rules not that relevant.

259
00:09:32,066 --> 00:09:33,533
And therefore this is kind.

260
00:09:33,533 --> 00:09:35,266
Of a rule of thumb
that I'm giving you here.

261
00:09:35,266 --> 00:09:38,400
It is not based on common sense,
rather based on experience.

262
00:09:38,666 --> 00:09:39,900
And therefore I recommend.

263
00:09:39,900 --> 00:09:42,966
To choose. A minimum lift. Of three.

264
00:09:43,200 --> 00:09:43,800
All right.

265
00:09:43,800 --> 00:09:46,266
And with this minimum lift
we. Will get good rules.

266
00:09:46,266 --> 00:09:47,366
You know relevant rules.

267
00:09:47,366 --> 00:09:50,133
Okay. So minimum lift equals three.

268
00:09:50,133 --> 00:09:51,800
And then we have two less.

269
00:09:51,800 --> 00:09:53,800
Arguments that are. Actually very.

270
00:09:53,800 --> 00:09:55,366
Very important and in fact.

271
00:09:55,366 --> 00:09:57,200
Compulsory for our.

272
00:09:57,200 --> 00:09:59,366
Business problem.

273
00:09:59,366 --> 00:10:00,500
It has to do with the fact.

274
00:10:00,500 --> 00:10:02,600
That, you know, we want to identify.

275
00:10:02,600 --> 00:10:04,433
The best deals of by.

276
00:10:04,433 --> 00:10:06,566
One product A, and get another.

277
00:10:06,566 --> 00:10:09,966
Product B for free,
and therefore the rules we.

278
00:10:09,966 --> 00:10:12,100
Want to get in the end must have.

279
00:10:12,100 --> 00:10:14,100
Only two products, one.

280
00:10:14,100 --> 00:10:17,666
Product in the left hand side of the rule
and one product in the right hand

281
00:10:17,666 --> 00:10:18,700
side of. The rule.

282
00:10:18,700 --> 00:10:20,333
All right. And therefore to make sure.

283
00:10:20,333 --> 00:10:21,266
We have this, you know.

284
00:10:21,266 --> 00:10:24,000
One product A
on the left and one. For a B on the right.

285
00:10:24,000 --> 00:10:26,300
Well,
we need to add two more arguments here.

286
00:10:26,300 --> 00:10:29,300
Which is. First min length.

287
00:10:29,333 --> 00:10:32,266
Okay. And then max.

288
00:10:32,266 --> 00:10:32,800
Length

289
00:10:33,833 --> 00:10:34,500
where of.

290
00:10:34,500 --> 00:10:37,966
Course min length is the minimum
number of elements you want to have.

291
00:10:37,966 --> 00:10:38,566
In your rule.

292
00:10:38,566 --> 00:10:39,866
You know, left or right.

293
00:10:39,866 --> 00:10:42,833
And max length is the maximum
number of elements you want to.

294
00:10:42,833 --> 00:10:44,833
Have in your rule, left or right.

295
00:10:44,833 --> 00:10:45,966
And therefore here to make sure.

296
00:10:45,966 --> 00:10:47,366
We only have two.

297
00:10:47,366 --> 00:10:49,433
In our rule,
you know, one on the left and one on the.

298
00:10:49,433 --> 00:10:49,966
Right.

299
00:10:49,966 --> 00:10:52,533
Well, obviously we need to set mid-length.

300
00:10:52,533 --> 00:10:53,766
To two.

301
00:10:53,766 --> 00:10:56,400
And max length same.

302
00:10:56,400 --> 00:10:57,500
To two.

303
00:10:57,500 --> 00:11:01,033
And that's only because
in our business problem we want to find.

304
00:11:01,033 --> 00:11:02,500
These best deals of.

305
00:11:02,500 --> 00:11:04,100
Buying one product A and get.

306
00:11:04,100 --> 00:11:05,533
One product for free.

307
00:11:05,533 --> 00:11:09,000
Therefore
our rules must have exactly two elements.

308
00:11:09,300 --> 00:11:10,533
Then imagine you wanted.

309
00:11:10,533 --> 00:11:14,866
To find the best deals of buy two products
and get a third one for free.

310
00:11:15,066 --> 00:11:17,533
Then you would set min lengths to. Three.

311
00:11:17,533 --> 00:11:19,233
And max length. To three.

312
00:11:19,233 --> 00:11:20,800
And if you want to be very, very.

313
00:11:20,800 --> 00:11:23,100
Flexible on your deals,
like you know, you.

314
00:11:23,100 --> 00:11:25,133
Could have deals with by one product A.

315
00:11:25,133 --> 00:11:27,900
And get one product
B. For free or by two products.

316
00:11:27,900 --> 00:11:28,466
A and.

317
00:11:28,466 --> 00:11:30,000
Get one product B for free.

318
00:11:30,000 --> 00:11:33,000
Or, you know, by ten products
and get one for. Free.

319
00:11:33,000 --> 00:11:34,033
Well, in this. Case you would.

320
00:11:34,033 --> 00:11:36,600
Set min lengths to two
and then max length.

321
00:11:36,600 --> 00:11:37,733
To 11.

322
00:11:37,733 --> 00:11:39,933
Okay,
so that really. Depends on your. Business.

323
00:11:39,933 --> 00:11:41,666
Requirements, your business problem.

324
00:11:41,666 --> 00:11:42,000
Here we.

325
00:11:42,000 --> 00:11:44,700
Just want to find the best. Deals
of two products.

326
00:11:44,700 --> 00:11:47,433
By one product
A, get. One product B for free and.

327
00:11:47,433 --> 00:11:47,900
That's it.

328
00:11:47,900 --> 00:11:50,933
And that's why we set min links to two
and max links to two.

329
00:11:50,933 --> 00:11:51,900
So that our. Rule can.

330
00:11:51,900 --> 00:11:54,133
Have only two products.

331
00:11:54,133 --> 00:11:55,166
All right. And that's it.

332
00:11:55,166 --> 00:11:56,166
Well you know we're done.

333
00:11:56,166 --> 00:11:57,766
With this a priori.

334
00:11:57,766 --> 00:11:59,266
Function which will return the.

335
00:11:59,266 --> 00:12:02,166
Rules respecting all these values.

336
00:12:02,166 --> 00:12:03,400
We said for the parameters.

337
00:12:03,400 --> 00:12:04,366
A minimum support.

338
00:12:04,366 --> 00:12:07,366
Of 0.03, which. Means that.

339
00:12:07,400 --> 00:12:08,966
The. Products in the rules.

340
00:12:08,966 --> 00:12:12,300
Appear at least 0.3 percent of. The time.

341
00:12:12,666 --> 00:12:14,766
Then the minimum confidence,
which means that.

342
00:12:14,766 --> 00:12:16,233
For each product A.

343
00:12:16,233 --> 00:12:17,266
In the left hand side.

344
00:12:17,266 --> 00:12:19,600
Of the rules, well,
we will have product B in the.

345
00:12:19,600 --> 00:12:20,300
Right hand side.

346
00:12:20,300 --> 00:12:22,200
Of the rule at least 20% of the.

347
00:12:22,200 --> 00:12:24,700
Time,
and then we have a minimum lift of. Three.

348
00:12:24,700 --> 00:12:27,533
And we have only two products.

349
00:12:27,533 --> 00:12:30,866
In our rules thanks to this min
max equals to and max length.

350
00:12:30,866 --> 00:12:32,000
Equals two.

351
00:12:32,000 --> 00:12:33,866
All right. So are you ready.

352
00:12:33,866 --> 00:12:36,566
Are you ready to run that cell
to get the rules.

353
00:12:36,566 --> 00:12:38,733
We won't have them
displayed in the output.

354
00:12:38,733 --> 00:12:40,300
But don't worry we will visualize.

355
00:12:40,300 --> 00:12:42,933
Them right after this
tutorial in the last. Part.

356
00:12:42,933 --> 00:12:44,100
So let's do this.

357
00:12:44,100 --> 00:12:46,900
Let's play the cell. And there we go.

358
00:12:46,900 --> 00:12:48,533
Now my friends, we have the rules.
