WEBVTT

00:30.000 --> 00:37.360
Hey, good morning, good afternoon, and good
evening everyone again at the next session of AI42

00:38.120 --> 00:43.460
And before we go into details, let me
welcome my partner, Håkon. Hi, Håkon

00:43.940 --> 00:51.660
Hello, Eve. How are you? I'm good. And hi, Heine,
our beautiful presenter. Hi, how are you, Heine

00:52.260 --> 00:56.880
I'm doing very well, thanks. It's going
well. Awesome. That's good to hear

00:56.880 --> 01:04.480
and today we are going to show you again
something awesome from the mathematics field

01:04.480 --> 01:11.640
which is going to be probability and this
is another one of my favorite parts of the

01:11.640 --> 01:19.540
mathematics field and it's because it is like
getting very very close to to ai and data science

01:19.540 --> 01:25.360
honey would you like to share some words about
this exactly so we are going to be talking about

01:25.360 --> 01:32.360
probabilities today. And as you kind of stated, it is kind
of taking us towards machine learning and being able to

01:32.500 --> 01:40.360
predict something. So it's kind of that bridge from just
having data and then going towards making really kind of new

01:40.360 --> 01:45.280
information out of it. So it's
going to be very exciting today

01:45.280 --> 01:48.820
I'm excited for this session. And I
can't believe it's already the last one

01:50.140 --> 01:54.460
Yes, and this is somehow it's
sad. But in another way, it is

01:54.460 --> 01:58.780
really cool that we have learned a lot
already again. So that's exactly nice

01:58.780 --> 02:04.140
And next it's the step of really starting to
implement it and use everything that has been

02:04.140 --> 02:12.860
learned. Yeah, that's very true. But before we get
there, let's go, let us give you a quick intro to AI42

02:24.460 --> 02:35.580
Hi again. Hello. So let's say a few words
about AI42. Would you all can start it please

02:36.500 --> 02:43.180
Yes. So the idea here with why we started AI42
is we saw that we couldn't really find one good

02:43.180 --> 02:48.620
resource where they could cover everything from
starting out with the basics over to actually do

02:48.620 --> 02:54.060
some some real implementation with machine
learning so then we start me and eve started

02:54.060 --> 03:00.460
up this ai422 initiative so what we do here is
we will be streaming uh two times a month on

03:00.460 --> 03:06.460
wednesdays and then we will invite recognized
speakers and experts that will teach you about

03:06.460 --> 03:13.180
different topics so we started started out with
mathematics and probability theory and then we

03:13.180 --> 03:17.520
we will move more into different
languages like R, R and Python

03:18.100 --> 03:23.960
and SQL, for example. And then we go more
into actual machine learning and data science

03:24.480 --> 03:31.100
And in addition to this more theoretical part, we
also will have some practical workshop sessions

03:32.960 --> 03:40.160
Yes. And we would like to do this
by inviting a lot of experts

03:40.240 --> 03:45.780
basically, in the different fields so
they can also give you a lot of knowledge

03:45.780 --> 03:53.320
and you can extend your network as well with the help
of these people in the field of data science and AI

03:55.560 --> 04:05.940
Yes. And we are also visible here on social media, so
you can follow us on Instagram or Twitter or Facebook

04:06.440 --> 04:10.660
And if you scan our QR code, you
can get to both our YouTube page

04:10.660 --> 04:17.220
where you can find all our previous sessions. And we
will announce our next sessions on our meetup page

04:17.220 --> 04:27.020
where you can also see on this page here. Yes. And we
want to say a big, big, big thank you for our sponsors

04:27.020 --> 04:34.120
which are Microsoft and Myles. We also want
to say thank you for all the contributors

04:34.120 --> 04:42.860
who helped us making this happen. and you
can also learn some more if you join us now

04:42.860 --> 04:50.360
and follow us on Twitter, Facebook and Instagram.
So I'm very happy that you are guys here

04:50.620 --> 04:56.580
How about getting started with some
probability then? Yes, let's go back to Heineer

05:06.080 --> 05:16.920
Hi, Heini. Welcome back. Hello. So this
session is going to be about probabilities

05:17.700 --> 05:22.180
And would you like to give us a quick intro
about what are we going to cover today

05:23.240 --> 05:30.900
So really today's goal is to understand probabilities and
give some idea of the different ways to calculate those

05:30.900 --> 05:35.520
and then at the very end
I'm going to give a little

05:35.520 --> 05:39.280
kind of an overview of how all these
different things we've been covering

05:39.280 --> 05:45.320
fit into doing certain things in machine
learning That sounds really interesting

05:45.320 --> 05:51.620
Okay, do you have any other Yeah, go ahead,
sorry I just wanted to say to the audience

05:51.620 --> 05:55.640
here that before we start, if you have
any questions, just feel free to post them

05:55.640 --> 06:00.560
in the chat and then we will have
a Q&A after the session is finished

06:00.560 --> 06:10.060
yes sounds good so honey are you ready to
take it away yes i am very ready and let's go

06:10.060 --> 06:29.620
good evening everyone and welcome
also on my behalf to the our fifth

06:29.620 --> 06:36.020
mathematics session which will be around
probabilities and before we get too deep

06:36.020 --> 06:41.760
into probabilities, I just want to kind of set the
stage again and kind of give you an overview of

06:41.760 --> 06:48.180
what we have been covering before and how we're
now ending up into the area of probabilities

06:49.300 --> 06:56.420
So really on our previous sessions, we've been
looking at this problem of us having some kind

06:56.420 --> 07:03.040
of data set. And of course, in the beginning, we
just want to find some kind of information about

07:03.040 --> 07:08.140
the data that we have. Last time, we looked very
extensively into statistics and found all those

07:08.140 --> 07:15.400
different methods associated to understanding
our data better in terms of looking at statistics

07:16.460 --> 07:21.960
But then on the previous sessions, we've also
been asking these questions that how can we

07:21.960 --> 07:38.924
find this line for our data set that best describes it And then after that what comes in is how likely is some kind of
event to occur And that is really what takes us into probabilities And so what we been going through in the past sessions

07:38.924 --> 07:44.824
is we, in the first one, we looked at basic
algebra, including looking at things like

07:45.544 --> 07:53.424
data sets, equations, and solving equations and
such, really setting the base for all of the other

07:53.424 --> 08:00.304
math to follow. Then in the second one we
were looking into calculus and calculating

08:00.304 --> 08:06.744
things as derivatives and integrals. And then
in our third session, which was around linear

08:06.744 --> 08:15.604
algebra and might have been the most heavy of
the sessions so far and kind of most extensive

08:15.604 --> 08:21.924
in terms of how it's used in machine learning
as well. And then last week, no, two weeks

08:21.924 --> 08:31.524
ago we went into statistics and looking at those
central tendencies and distribution and so forth

08:32.084 --> 08:35.844
And now in this fifth session we
will be looking into probabilities

08:37.764 --> 08:42.004
So if you have not been following along to
the other sessions, I'm Heine Ilmarinen

08:42.564 --> 08:51.044
I live in Finland and I work as a DevOps console
at Polar Squad. I do work with Azure currently and

08:51.044 --> 08:56.704
And I also do training around Azure
since I am a Microsoft Certified Trainer

08:56.704 --> 09:04.704
And my favorite topic at work is definitely
architecture and figuring out architectural problems

09:04.704 --> 09:08.724
But I used to study math and actually
started to become a math teacher

09:08.724 --> 09:13.764
So it's really nice that I get to combine kind
of those my past skills and current skills

09:13.764 --> 09:18.984
and get to run these sessions for you around
how to use mathematics for machine learning

09:18.984 --> 09:27.304
and data science and everything in that area.
And as you might see in the following slides

09:27.304 --> 09:35.124
I am a bit of a dolder and like to draw pictures
of everything pretty much. So we will be looking

09:35.124 --> 09:42.024
today into probabilities. We will start first.
Well, what we're looking at with probabilities

09:42.024 --> 09:46.824
is really understanding the likelihood of
things. We're looking at how likely is something

09:46.824 --> 09:53.484
to occur. And really, if you think about it, that
is already kind of talking about things regarding

09:53.484 --> 09:59.204
being able to predict something, being able to
determine whether something is likely to happen

09:59.204 --> 10:05.544
or not. And to get to that point, we're first
going to start looking at basic probabilities

10:06.624 --> 10:13.404
Then we will look at, well, how do probabilities
work in real life? And then that will take us

10:13.404 --> 10:19.804
into the law of large numbers. Then we
will look at conditional probability

10:19.804 --> 10:27.004
and how can we determine independent versus
dependent events. And then as the last point

10:27.004 --> 10:32.024
we will be looking at the Bayes' theorem.
And then at the very end, as I mentioned

10:32.024 --> 10:35.944
I will be kind of tying in everything
that we've been going through

10:35.944 --> 10:42.264
with the different sessions so far and
the learnings that we can take from here

10:42.264 --> 10:49.384
for our machine learning career. So
let us start with basic probabilities

10:49.384 --> 10:56.484
So when we're talking about probabilities, we are
really looking at how likely is an event to occur

10:56.484 --> 11:01.484
And so how we would calculate
that is by looking at first

11:02.624 --> 11:09.984
the number of ways that event can occur. And
then we want to divide that by the total number

11:09.984 --> 11:18.304
of options, of outcomes that we have. And
I think one of the most common examples

11:18.304 --> 11:24.224
used in probabilities is throwing a dice, but
it's used a lot because it is so efficient

11:24.224 --> 11:31.564
to really demonstrate this point to us. So
I'm not gonna lose something that works

11:31.564 --> 11:36.724
So we're just gonna take a quick
example here using the role of a dice

11:36.724 --> 11:47.484
So if we think that we're rolling a dice and we
want to calculate the probability of rolling a 1

11:49.824 --> 11:58.764
what we need to think, what is the ways in which
we can roll that number 1? Well, we can roll it

11:58.764 --> 12:07.204
only by one way, because we only have one one in
the dice. So the number of ways it can happen is

12:07.204 --> 12:13.224
one. And then the total number of outcomes in a
dice is, of course, six, because there are six

12:13.224 --> 12:20.584
different numbers on that dice. So the probability
is one out of six. And if we want to turn that

12:20.584 --> 12:29.464
into a percentage, we would just do that division
1 divided by 6 and multiply by 100. So we would

12:29.464 --> 12:40.904
get it to be about 16.7%. And in these simple
situations, it is really easy to calculate these

12:40.904 --> 12:47.144
probabilities. But of course, our situations
might be way more complex, there might be

12:47.144 --> 12:54.104
multiple events happening and things affecting
one portion or the other. So we will be taking

12:54.104 --> 13:00.424
steps into those more complex situations. But
this is our starting point. Just simple event

13:01.464 --> 13:06.504
nothing else affecting it, and we are just
able to directly calculate the outcome

13:08.344 --> 13:12.504
But if we think about this event
of rolling a dice in real life

13:12.504 --> 13:20.824
we now know that the theoretical probability
that we just calculated, we just got the result

13:20.964 --> 13:27.584
we know that rolling one, the probability
is this one divided by six and about 16.7%

13:27.584 --> 13:35.124
But if you think about real life situations,
there is something called experimental probability

13:35.644 --> 13:40.584
Because in real life, if we decide to
test this out, test this probability out

13:40.584 --> 13:48.344
we might not get the same results. So let's say
that we decide that we're going to roll the dice

13:48.344 --> 13:53.904
two times. And then from those two rolls, we're
going to determine what is the probability of

13:53.904 --> 14:01.644
rolling one. And if you've played any kind of game
of dice, you might sometime have gotten that you've

14:01.644 --> 14:08.004
rolled the dice twice, and both times you have
gotten one. So we roll it once, we get a one

14:08.004 --> 14:16.244
and we roll it twice, we get another one.
And so if we have a set where we roll it

14:16.244 --> 14:26.624
two times, and both of those times we get ones. In
this case, when we're calculating the probability

14:26.624 --> 14:37.104
we take the number of events where we got one, and
then we divide it by the number of total events

14:37.104 --> 14:47.104
So down here it's number of total events.
And at the top, it is the number of events

14:47.104 --> 15:07.609
where we got the desired outcome. So this is number of times we get one But of
course on the other hand we could also in two rolls we could get no ones as well

15:07.609 --> 15:14.469
So, but does this mean that when we do
this experiment, we roll the dice twice

15:14.469 --> 15:21.029
Does that mean our probability is
now 100%? Does it work that way

15:21.029 --> 15:34.109
Well, not quite. So what we are to pull away from this scenario is that we have a
difference of the experimental probability, and then we have a theoretical probability

15:35.429 --> 15:43.709
And what the relationship between these two is,
that is what is called a law of large numbers

15:43.709 --> 16:00.029
And what this means is that it means that the more we repeat an experiment, the
closer we should get to that kind of calculated results, the theoretical probability

16:00.029 --> 16:07.429
So in our example, we just rolled the dice twice.
But if we keep rolling that, it is quite likely

16:07.429 --> 16:15.389
that maybe the next ones will not be dices with
one. And we roll it again, and maybe we do get

16:15.389 --> 16:21.509
another one. But we roll it again, and we roll
it again. And at this point, we already get to a

16:21.509 --> 16:29.029
situation where we have our probability, our
experimental probability is one third, which is

16:29.029 --> 16:38.309
already much closer to our theoretical probability
than was our first two tosses. So this law of large

16:38.309 --> 16:45.349
numbers really states that the more we repeat
an experiment, the closer we will get to that

16:45.349 --> 16:53.269
theoretical probability. So if we were to repeat
this experiment, for example, thousands of times

16:53.269 --> 17:03.469
that probability of getting a one would fall
very close to that probability that we got by

17:03.469 --> 17:11.109
calculating, which was the one-sixth. It would be
out of the thousand rolls of dice, about one-sixth

17:11.109 --> 17:19.669
would be ones. So really the probabilities very
much tie together with an actual data set that

17:19.669 --> 17:25.969
we might have. So we might gather some data, and
from our data, we might be able to calculate some

17:25.969 --> 17:33.749
probabilities. And depending on how large our data
set is, that probability will be more or less

17:33.749 --> 17:40.569
accurate. And the less we have data, the less
accurate that probability can be. And whereas

17:40.569 --> 17:49.209
the more we have data, the more accurate that data
will be as well. And if we look at this situation

17:49.209 --> 17:54.609
that we have been looking at here.
This case where we just roll some dice

17:55.529 --> 18:02.629
This particular case has been a situation
where we have very discrete values

18:03.349 --> 18:14.269
So that roll of dice cannot get any value whatsoever.
So it has some discreteness to what it can be showing

18:14.269 --> 18:25.429
So, sorry, I'm trying to change the slide here.
There we go. So really, if we think about how then

18:25.429 --> 18:32.429
those rolls of dices will distribute, if we repeat
it many times, it will create this discrete

18:32.429 --> 18:40.149
distribution where these different numbers on the
dice will get a different repetition of values

18:40.149 --> 18:50.309
And those will be our probability distribution
for that measurement that we're doing. For example

18:51.029 --> 18:57.469
this could describe our distribution when we're
rolling a dice, except I have five bars here

18:57.569 --> 19:01.929
so we should actually have six to really
be representing a roll of the dice

19:03.089 --> 19:08.189
So this is one kind of measurement where
we might be looking at the probabilities

19:08.189 --> 19:16.549
But the other type that we might have is
this, which is a continuous distribution

19:17.349 --> 19:26.849
So where the values that we're measuring can get any value
between certain numbers, maybe some minimum and maximum numbers

19:27.249 --> 19:34.229
and then each of those values will have
a different amount of repetitions again

19:34.229 --> 19:40.769
So we again have the number of repetitions and the
values, and this is the continuous distribution

19:42.069 --> 19:48.209
And you might remember, we actually took a look at
this in our previous session as we were looking

19:48.209 --> 19:54.109
at statistics, because we can, of course, look at
the distribution of the values from the perspective

19:54.109 --> 20:00.889
of this is the data that we have gathered, or we
can look at it from the perspective of what is

20:00.889 --> 20:07.909
the probability of each of those values that we
might get. And of course, as we looked at how to

20:07.909 --> 20:14.049
calculate the probability, we look at the number
of events per that value that we're looking at

20:14.289 --> 20:21.409
divided by the total number of events. So it will
of course be related to the number of events we

20:21.409 --> 20:29.449
have for each specific measurement. So that
is why just the general distribution and the

20:29.449 --> 20:35.689
probability distribution will look very alike.
But as when we're talking about probability

20:35.689 --> 20:42.649
distributions, we're most often, instead of
showing the number of repetitions, we instead

20:43.369 --> 20:53.449
here on this bar here, we change this
to the probability of a specific value

20:53.449 --> 21:09.449
So the scale at which we represent those values will change. So we've
been looking at how we can calculate the probability for one event

21:09.449 --> 21:15.449
But sometimes there is the case that we
might have multiple events happening

21:15.449 --> 21:21.449
And in that case, we will need something
called a conditional probability

21:21.449 --> 21:33.449
But first to understand what conditional probability is about, we
need to look at whether these two events that we're looking at

21:33.449 --> 21:40.449
So we start with two events, and we need to
see whether these two events are independent

21:40.449 --> 21:59.689
or whether they are dependent. So those are our two options.
And what this means is that if we look at independent events

22:00.169 --> 22:07.029
then it means that if we have event A, then
it does not affect the event B in any way

22:07.989 --> 22:15.909
So if we say that event A is,
for example, one roll of a dice

22:18.709 --> 22:24.789
and then the event B is
the second roll of a dice

22:26.869 --> 22:33.034
is the first roll going to affect what
number we gonna get out of the second roll

22:35.094 --> 22:40.394
No, it's not. It's gonna, we're
still gonna have the same probability

22:40.394 --> 22:49.694
So if we're now going to calculate the probability of
rolling a one and a one in our two roll situation here

22:49.694 --> 22:59.054
roll situation here. So to calculate
that, we need to take the probability of A

23:01.054 --> 23:09.374
and then we need to multiply that by the probability
of B. So we need the probability of what is

23:11.214 --> 23:16.734
the probability of getting one in the first
roll of dice, and we need the probability of B

23:16.734 --> 23:22.894
of what is the probability to get one out of
that second roll of the dice. And so this means

23:22.894 --> 23:29.054
we have one sixth since we calculated that before,
because we have one option out of the six to get

23:29.054 --> 23:37.374
one. And then for the second roll, the probability
is exactly the same. And we just multiply those

23:37.374 --> 23:47.614
together. And so in this case, we get 1 out of 36.
And again, you could write this as a percentage

23:47.614 --> 23:56.734
if you would like to. We're just gonna leave it at
that for now. So why do we do the multiplication

23:58.494 --> 24:11.774
Well, because if we think about it, if you think about these
two rolls of the dice, the combination of those two rolls

24:12.254 --> 24:19.774
there's no longer six options, but there is six
times six options total. Because if you get a one

24:19.774 --> 24:26.174
on the first roll, you could get a one, two,
three, four, five, and a six on the second roll

24:26.174 --> 24:31.694
If you get a two, you can again get one, two,
three, four, five, six on the second roll. So you

24:31.694 --> 24:37.854
need to kind of multiply each of those options on
the first roll with the options on the second roll

24:37.854 --> 24:43.774
And that is why we use multiplication in these
scenarios. So whenever you're thinking about

24:43.774 --> 24:51.534
what is the probability of the first one and the
second one, then you use multiplication there

24:51.534 --> 25:02.374
And sometimes, in a way, this can feel a little,
I now have the word only in Finnish in my head

25:03.274 --> 25:14.014
counterintuitive, that's the word, to do the multiplication. But
here it shows that rolling one, number one, in our roll of the dice

25:14.494 --> 25:31.054
is more probable than rolling it twice in a row. And if you think about it in that way, that makes complete
sense. So multiplication when you're looking at two events. But what if we have two dependent events

25:31.054 --> 25:43.674
In that case, we can still look at this situation of
having those two events and multiplying them together

25:44.014 --> 25:53.034
But in that case, we need to consider also
taking into account the other scenario

25:53.034 --> 26:03.034
So, for example, if we have
an event that is, it rains

26:07.034 --> 26:21.514
And we have another event that says, it is sunny. But then we
also know that if it's sunny, it is a bit less likely to rain

26:22.154 --> 26:29.034
But we still do want to calculate the probability
of A and B, that it is both raining and it is

26:29.034 --> 26:36.954
sunny. So to do that we cannot just take the
probability of it rains and it is sunny, but we

26:36.954 --> 26:45.834
have to take the probability of it rains. And
then we need to take the probability of it

26:45.834 --> 26:57.434
it is sunny when we already know that it's
raining. So this second part here is telling us

26:58.714 --> 27:03.994
about, well, if A has already happened,
then what is the probability of B

27:05.834 --> 27:13.994
So for example, in this scenario, we could have
a probability for it rains, because right now we

27:13.994 --> 27:23.434
don't have any numbers here yet. But let's say
that we have a probability of a training being 0.2

27:25.674 --> 27:37.834
And we have a probability of it being sunny, let's
say 0.4. So here we see that we want our 0.2 here

27:37.834 --> 27:47.614
but actually we don't know what this probability
here is. What is the probability of it being sunny

27:47.614 --> 27:57.554
if we know that it rains? So in that case, we
need to have possibly some more information

27:57.554 --> 28:07.594
and maybe in that this case it has been given to
us what is the probability of it then raining

28:07.594 --> 28:16.234
if it is no it being sunny when it rains so we're
in this case we're gonna assume that we have been

28:16.234 --> 28:21.574
given that and let's just say that is 0.2 and
we're gonna return to this in just a little bit so

28:21.574 --> 28:28.214
So we're going to go over this whole process from
a different angle to make it, let it make sense

28:28.654 --> 28:35.714
So pretty much we, in this case, we were given
this probability of it is sunny when we already

28:35.714 --> 28:45.694
know it's raining. We know that it is 0.2. All
right. So what tells us whether those two events

28:45.694 --> 28:53.874
is R independent or dependent. Well, if they're
independent, we can just take the two numbers

28:53.874 --> 29:02.954
and multiply them together directly. If
they are dependent, then we need to have

29:02.954 --> 29:11.254
the probability of the second event happening
when already A has happened. So in this case

29:11.254 --> 29:17.434
we have the probability of it rains times then
the probability of, we know it's already raining

29:17.634 --> 29:24.234
so now the probability of it being sunny is 0.2 as
well. And so we can then take those two numbers

29:24.234 --> 29:34.554
together and then calculate those and get the
probability for that. So 0.2 times 0.2 means

29:34.554 --> 29:45.074
0.04 in this case. All right. So that is
the first thing that we need to know here

29:47.474 --> 29:54.034
But from this calculation of, oh, we actually
need to know what is the probability

29:54.034 --> 29:59.974
when one of these events has already happened.
We then get to this conditional probability

29:59.974 --> 30:09.420
So we're able to take this equation that we ended
up here with. So we're going to be able to take

30:09.420 --> 30:24.760
probability A and B equals probability A times
probability B when A has happened. So this is

30:24.760 --> 30:49.560
really saying probability of B when A has
happened. So this is where we started from

30:49.560 --> 30:58.780
So what if we don't have that information? What if we don't
know what the probability of B is when A has already happened

30:59.540 --> 31:08.460
Well, then in that case, we can use the information of maybe we
do know what is the probability of A and B happening together

31:08.460 --> 31:20.280
So then what we can do with this, if you remember
from our basic algebra to manipulate an equation

31:20.280 --> 31:27.960
in this case we can do a division here and divide
by Pa here. And that way we're able to get the

31:27.960 --> 31:48.520
result of PBA equals P and B divided by P . So
that's what we get from there. So in this case

31:48.520 --> 31:54.860
if we have the probability of A and B together and
we have the probability of A, then we can solve

31:54.860 --> 32:01.320
for what is the probability of B when A has
already happened. And this is called conditional

32:01.320 --> 32:07.740
probability. So sometimes we, for example, might
have some information that, well, we know that

32:07.740 --> 32:18.639
for somebody to, well, let's go back to our
raining example. We might know the probability of

32:18.639 --> 32:25.800
it raining and being sunny at the same time, and
we might know the probability of it just being

32:25.800 --> 32:33.280
sunny. And then by using those, we're able to get
the probability of it raining when it is already

32:33.280 --> 32:41.340
sunny. So that's how it works together. So a lot
of times we're, rather than giving the probability

32:41.340 --> 32:48.139
of when something has already happened,
we most often have the probability of two

32:48.139 --> 32:54.760
happening together. So that's how we're then
able to use this conditional probability to our

32:54.760 --> 33:01.160
advantage. And if we really think about that, this,
most of the time, we don't have just one event

33:01.160 --> 33:06.840
we're looking at. So that is why it's quite
important to be able to use this conditional

33:06.840 --> 33:16.160
probability to our advantage and use it when we
might need it. Then, as kind of where we can get

33:16.160 --> 33:24.080
from here. If we look at this calculation,
another way that we could have presented this

33:24.960 --> 33:35.840
same calculation here is that we would have taken
P, A and B, but we could have looked at it from

33:35.840 --> 33:43.360
the other direction and taking the probability of
B times the probability of P when A has already

33:43.360 --> 33:53.520
happened. And so if we take these two information
that we have gotten from here, we have both this

33:53.520 --> 34:02.240
one at the top and this one at the bottom. We
notice that they equal the same thing. So we're

34:02.240 --> 34:20.720
able to take both of these with just writing
these two out times too many things to write

34:20.720 --> 34:30.239
here. And from here, we get to something called
a Bayes' theorem. And what the Bayes' theorem

34:30.239 --> 34:35.500
is stating that when we have some kind
of information about our probabilities

34:35.500 --> 34:43.860
then we can find out one other aspect based on
the information that we do actually already have

34:43.860 --> 34:48.260
So based on the information we have,
we're able to solve other probabilities

34:48.260 --> 34:53.360
that we might be missing. So in that
this case, we're going to take this

34:53.360 --> 35:02.279
and for example, we're going to just
solve it so that we can get PAB equals

35:03.500 --> 35:08.480
so again, we wanna divide by PB because
there's a multiplication mark there

35:08.480 --> 35:19.620
And so that means that the left side stays put,
and then we're just gonna divide it by this PB

35:19.620 --> 35:36.120
that we had here. And so this is the Bayes' theorem. And so what this is telling us is that if we have
some of this other information, then we're able to solve for any missing parts that we might have here

35:36.120 --> 35:44.180
And then also by combining with this previous
information here, for example, this one

35:44.860 --> 35:54.800
then we are able to leverage any of the information
we have regarding our probabilities in a more

35:54.800 --> 36:02.460
complex scenario. And to make any of this make
sense, I'm just going to pull this information

36:02.460 --> 36:11.420
and we're going to look at a practical example.
So let's just write this out here one more time

36:11.420 --> 36:31.080
so that it's going to be there for us when we
need it. Okay, so that's our Bayes' theorem

36:31.080 --> 36:47.960
And then, on the other hand, we have the information about how to calculate also this
situation with kind of having the information about how two of these aspects fit together

36:47.960 --> 36:56.880
So one way to leverage these Bayes theorems is
when we have probability trees. So we have some

36:56.880 --> 37:05.700
kind of event that has different probabilities at
some level. So let's just do one kind of example

37:06.300 --> 37:16.680
So we have, for example, done an algorithm that
looks at photos. And then by looking at those

37:16.680 --> 37:24.279
photos, it will, for example, determine if the
patient has cancer. And we have determined that..

37:24.880 --> 37:39.698
Oops just a second Let me get my pen here working again So based on this
algorithm we have been able to find out that there is a 4 probability that yes

37:42.078 --> 37:51.718
there is cancer based on that photo and then
0.96 that no, there's actually no cancer

37:54.998 --> 38:07.578
But then on this side where we have it saying that, yes, it
is cancer, some of these will be actually true positives

38:09.078 --> 38:15.358
So it will say that, yes, it is
cancer, and it actually is cancer

38:17.178 --> 38:26.358
So let's say that this is 0.8. and
then we have like a false positive

38:30.858 --> 38:36.298
So it is actually then when a test
is done, it is not actually cancer

38:36.298 --> 38:41.858
And let's say that is 0.2.
And then on the null side

38:41.858 --> 38:48.838
we're also going to have some probabilities. So
we're again going to have kind of the true positive

38:48.838 --> 38:56.458
but in this case it will
be for the no. So let's..

39:02.038 --> 39:14.418
Well, true negative actually, that's why I got confused.
Negative. And let's say that the probability for that is 0.05

39:14.418 --> 39:29.418
And then the false negative
then that one will be 0.95

39:31.538 --> 39:38.838
So to really understand then probabilities,
we can use the Bayes' theorem here

39:39.518 --> 39:47.418
So we can, for example, calculate
that, yes, the patient has cancer

39:47.418 --> 39:54.018
when they have gotten the positive test
based on these results that we have

39:56.558 --> 40:09.858
So we need to be calculating the true positives
against then the true negatives plus the false

40:09.858 --> 40:16.498
negatives as well. So we kind of have to take
different parts from this graph to calculate

40:16.498 --> 40:33.858
these all together. So we need to take the true
positives and then calculate the true negatives

40:41.778 --> 40:55.638
and then the false positives. No, I mean the
false negatives. But this looks kind of tricky

40:55.878 --> 41:02.398
So how are we actually going to go about
it? So if we look at this graph on the right

41:03.058 --> 41:11.938
of course, the situation that we're looking for
the probability for is, well, this branch here

41:16.498 --> 41:23.498
So the test has been positive
and they actually do have cancer

41:23.498 --> 41:34.498
So that is the ones that we're looking at. So those are the
scenarios that we know are the ones that we want to look at

41:34.498 --> 41:45.498
And so to calculate this kind of wanted
scenarios would be to take 0.04 times 0.8

41:45.498 --> 41:56.238
but since we're looking at well the test
is positive but the patient actually

41:56.238 --> 42:04.238
doesn't have cancer those are the all the
scenarios so we need to add both these

42:04.238 --> 42:12.478
scenarios where it's a true positive
so those are part of the set

42:12.478 --> 42:31.938
Oh, sorry, I completely miswrote this at the top. Excuse me.
So this is actually the true positives plus false negatives

42:32.038 --> 42:41.998
because the false negatives will give a positive
result, even though they do not actually have cancer

42:41.998 --> 42:55.598
So that's what we want to have down here. All the situations where there is a
positive test result, but there isn't actually, there either is cancer or there isn't

42:55.598 --> 43:11.418
So to do that, we want to then take the 0.96 times
0.05. So I have to do now some cleaning up because

43:11.418 --> 43:20.198
I actually wrote some things wrong here. So this is
the... Sorry about that. So to walk through this

43:20.198 --> 43:27.938
one more time to erase any confusion. This was
meant to be so that there is actually a positive

43:27.938 --> 43:39.318
test result. That's what I was meaning with
this. And this was to be a negative test result

43:39.778 --> 43:47.058
And again, we have a positive test result and
a negative test result. So sorry about that

43:50.198 --> 43:56.658
So we have the, yes, there is
actually cancer, no, there is not

43:56.658 --> 44:01.638
Plus then we have the layer of what
have the test results actually been

44:01.638 --> 44:08.718
whether it has been positive or whether it has been negative.
So those test results have been then used to confirm this

44:08.718 --> 44:15.698
So whenever we get a result of yes, so this is
our algorithm here saying that yes, it is cancer

44:16.898 --> 44:23.198
This is what the algorithm says. But then
we have some data, we get some results

44:23.198 --> 44:31.178
and we find out that the positive test results are
the probability for that from that group is 0.8

44:31.178 --> 44:37.158
but there is still a possibility of
getting a negative test results by 0.2

44:37.158 --> 44:41.558
And then even when our algorithm
says that no, there is no cancer

44:41.558 --> 44:49.558
it's still possible to get a positive test
result by 0.05, but a negative by 0.95

44:49.558 --> 45:04.396
So that is what we're calculating here. So we taking the rightmost branch
there is the desired outcomes We want to know when these both fit together

45:05.116 --> 45:12.676
And then the ones that we want to compare this
to is those who still got a positive result

45:12.676 --> 45:17.916
So both also from the no branch where
there is a positive result as well

45:19.536 --> 45:28.516
And then when we have these numbers, The only thing that is left is
just to calculate these out. So that's all we need to do in this case

45:29.796 --> 45:35.376
So for this one, we get, let's get back to
our blue so we don't get too many colors

45:35.376 --> 45:59.776
we get 0.32 divided by 0.32 plus 0.048.
And so based on this, we know that

45:59.776 --> 46:15.616
actually the probability that that result is
correct is actually pretty high because it is 0.87

46:15.616 --> 46:26.696
here. So if we again present this as a probability,
it is 87%. So that's how we can go about it. So

46:26.696 --> 46:33.336
But probabilities are used a lot in these kind
of probability trees and things like that

46:33.336 --> 46:41.696
that we might be using. So for today, we are
ending the near end of probability section

46:41.696 --> 46:47.196
And so really know that you should,
there is more to know about probabilities

46:47.196 --> 46:51.196
We don't unfortunately have the time
to go through every single detail

46:51.196 --> 47:00.956
I wanted you to get started on understanding the basic probabilities. And then
also understanding these scenarios where we have two dependent events happening

47:00.956 --> 47:07.956
from each other. And that is where we get to this
conditional probability, and then also to the Bayes' theorem

47:07.956 --> 47:16.456
as well. And so in this case, I am going to start
wrapping up and just reminding you what we've been

47:16.456 --> 47:21.376
going through in the previous sessions
and how this all fits together

47:21.376 --> 47:28.976
So because we've been going through all this math
and we're not just going through it pointlessly

47:29.416 --> 47:35.496
it's not, well, it is fun in my opinion, but
for you, it might be that you're going through

47:35.496 --> 47:40.176
the sessions to really take something to
your machine learning and data science

47:40.176 --> 47:48.876
endeavors that you have ahead. So really what
I want to come to here in the very end is to

47:48.876 --> 47:55.756
try to help you tie together all this. So
as we've been going through these sessions

47:55.756 --> 47:59.456
if you remember, as I kind of
stated in the beginning as well

48:00.516 --> 48:06.096
we have started here from basic algebra.
We built on top of that with calculus

48:06.096 --> 48:10.756
Then we went into linear algebra.
And then in these two last sessions

48:10.756 --> 48:17.416
we have been looking at statistics and
probabilities. And these two all fit together

48:17.416 --> 48:22.956
with data science and machine learning. But if
we look at data science and machine learning

48:22.956 --> 48:27.516
it can be kind of a vast area and
it can be very difficult to know

48:27.516 --> 48:33.936
which of these to use where. And to help
you out at least hopefully a little bit

48:33.936 --> 48:39.816
to get a sense of that is that a lot of times
when we look at data science and machine learning

48:39.816 --> 48:46.676
or artificial intelligence, they might be
described as these two overlapping spheres

48:46.676 --> 48:55.116
where actually the overlapping part is quite large, but there is more
to data science than just the things within artificial intelligence

48:55.396 --> 49:06.516
and there's more to AI than is contained within data science. And most of the
time, then machine learning is thought as a sub-area of artificial intelligence

49:06.836 --> 49:14.456
That is how it's mostly presented in a lot of sources. So
that will just kind of help you set the context of all this

49:14.456 --> 49:22.956
So we've been going through all these areas. So
really to be able to work within these two areas

49:22.956 --> 49:30.976
we need to have the basic algebra in place in the
ground underneath all the other math. Without that

49:31.056 --> 49:35.976
it's going to get really tricky quite soon. So
really try to get that foundation with basic

49:35.976 --> 49:45.156
algebra really high. And then since these areas
overlap and a lot of these methods are used

49:45.156 --> 49:53.016
interchangeably and kind of across both areas, this
is just kind of a best attempt at approximating

49:53.016 --> 50:01.456
So really statistics leans more towards the data
science side and also, oops, wrong directions

50:01.456 --> 50:07.856
statistics leads towards the data science side,
but also probabilities. But probabilities already

50:07.856 --> 50:15.776
starts to move towards also the AI and machine
learning needs as well. And the more we go to the

50:15.776 --> 50:21.716
side of artificial intelligence, the more we're
going to need calculus and linear algebra as well

50:22.916 --> 50:30.116
But if we look at even one area of a task that
you might be doing within these areas, let's say

50:30.116 --> 50:37.516
that you're, for example, just starting to look into your data, you
want to understand it, you try to find valuable insights from that data

50:38.076 --> 50:51.416
For that, you might, for example, use statistics and probabilities. On the other hand, if you're
starting to do linear regression, for you to do that, you're going to need some linear algebra

50:51.836 --> 50:55.816
you're going to need some calculus, but
you're also going to need some probabilities

50:56.776 --> 51:03.216
So in a lot of the cases when you're working with these
areas, it is not just one of these areas that you need

51:03.716 --> 51:08.396
It is that you need pieces and
portions out of many of these areas

51:09.816 --> 51:15.796
But the level at which you need to understand
it depends, I would say, purely on you

51:16.236 --> 51:22.336
It will become easier to understand how things
work if you do have that very deep knowledge

51:22.336 --> 51:29.476
but also we have a lot of tools that do the work
for you but when it becomes really essential to

51:29.476 --> 51:35.416
know these things behind the scenes is when
something goes wrong when we get some unexpected

51:35.416 --> 51:43.316
results then we might be white might have the
need to have the ability to really look behind

51:43.316 --> 51:50.016
and see what has been happening to map out what
has happened and why did we end up with the result

51:50.016 --> 51:56.976
we got. And of course, it might be that, yes, the
unexpected result was correct, but we need to have

51:56.976 --> 52:03.376
some kind of way to verify and not just blindly
trust, for example, the algorithms that we built

52:03.836 --> 52:10.756
but also we need to have some understanding of the
mathematics that go to making that algorithm work

52:12.636 --> 52:18.636
So I really hope these sessions have given you a
general understanding of these different topics

52:18.636 --> 52:37.915
There is definitely more to know and don feel discouraged if you feel like you don know everything yet That is completely reasonable
There is more to know I hope you inspired to find out more But also don be afraid to get into the actual practical implementations and get

52:37.915 --> 52:43.555
started on those, because then looking at those
practical implementations, you will get motivation

52:43.555 --> 52:49.095
to look deeper into the math as well, once
you see how things work on the practical sense

52:49.095 --> 52:58.095
So I really hope you have enjoyed it, and I have really had a fun
time going through these five different mathematics sessions with you

52:58.095 --> 53:16.855
Hi again

53:17.175 --> 53:21.155
Heine, you are doing great again.
Thank you a lot. Thank you

53:21.955 --> 53:27.295
You're welcome. And yes, the Bayes theorem
always gets me confused. Every single time

53:28.095 --> 53:37.075
And now that you say that we actually got
some questions, whether you could try to work

53:37.075 --> 53:42.275
Yeah, well then look at that first. Okay. So
could you give some example of how bias theorem

53:42.275 --> 53:50.755
is used in practice in machine learning and data
science? So this is for example, used in decision trees

53:50.755 --> 53:57.735
when we're trying to find the best possible option
for example. So that's one place where it's used

53:58.095 --> 54:02.755
And feel the two of you can feel free to add
anything that comes to mind right on the spot

54:03.635 --> 54:07.535
I do have something in my mind. You
know what I was thinking about this

54:07.835 --> 54:13.635
This confusion metrics, for example, because it's
not just it's not just when it's decision making

54:13.635 --> 54:19.895
It is also really good at making evaluation
of models. So, yeah, that's not true

54:21.055 --> 54:27.295
Yeah. Very good. about when we will talk
about these things on later sessions

54:27.475 --> 54:31.115
and that's why I don't want to shoot
out all the cool information now

54:32.375 --> 54:38.375
So, yeah, let's have just this, that it is
useful in building machine learning algorithms

54:38.375 --> 54:46.435
and to evaluate these as well. So it has a
lot of useful approaches that you can go with

54:46.435 --> 54:52.755
So, and how much statistics is it
necessary to know on an everyday basis

54:55.275 --> 55:03.015
Hmm, very, very interesting question.
Depends what you mean with everyday basis

55:04.675 --> 55:20.095
Yes, especially nowadays, right? Yeah, exactly. I would say just have at least some general
understanding of calculating averages and the different ways to do that and what it actually tells you

55:20.695 --> 55:25.635
And I think it is very useful to also have some
basic understanding of probabilities as well

55:26.115 --> 55:37.675
Because really with probabilities, I think the one most misunderstood aspect
is that then we try to rely on the probability for one particular outcome

55:38.155 --> 55:44.335
where actually probabilities look at the mass of
events and can really give an accurate answer

55:44.335 --> 55:53.295
for when you have multiple repetitions of that one
measurement. I think also if you know some probability

55:53.515 --> 55:58.995
it can be easier to actually set up a problem
and to realize is this problem actually solvable

55:58.995 --> 56:03.575
with the information that we have? Do we
have enough information to solve the problem

56:04.335 --> 56:11.955
And also what you mentioned, Heine, that when things
go right, it's okay, but then when things go wrong

56:12.435 --> 56:18.315
it's even more important to be able to dig down and
see what is the reason why things didn't work out

56:19.035 --> 56:24.575
Exactly. And I think we can easily
say, and I can say it for myself

56:24.575 --> 56:31.775
that it's very often that I try to make
decisions based on the information we have

56:32.535 --> 56:38.955
And I'm not talking about the information I have only, but I'm
talking about all the information I can gather all around and

56:38.955 --> 56:46.275
and including all these to, to make a decision,
especially if it's something big, don't have to look far

56:46.415 --> 56:52.035
just look at the situation we have
right now. So, yeah. So, um, and yeah

56:52.035 --> 56:55.855
there were a few questions about whether
we could take a look again at this

56:55.855 --> 57:01.055
uh, this, uh, theorem. I think the most
important part that was a bit crazy when

57:01.055 --> 57:13.895
when we talked about this true positive and true negative, And if the person who asked
about it is still with us, please feel free to shoot more questions if you have any

57:13.995 --> 57:18.175
So let's take a look at that again.
The last calculation. That's perfect

57:18.975 --> 57:30.035
Yes. Yes, that's a perfect clarification.
Let me just roll on to the right slide here

57:30.035 --> 57:33.675
I think this is the easiest.
If I just back up a little bit

57:34.195 --> 57:43.195
Sorry, oops, there we go. So, actually.
Yeah, one more time, I'm just gonna

57:43.195 --> 57:53.195
Yeah, so we shared the screen as well, there we go. All right,
so if we just start with our problem that we're trying to solve

57:53.195 --> 58:01.195
So our scenario is that we have this, let's say,
an algorithm that is able to, from a picture

58:01.195 --> 58:08.315
picture see whether somebody has cancer or not.
And then we want to know that whether this is

58:08.315 --> 58:15.515
actually accurate. So we have this test data set,
we have all the results from this algorithm, but we

58:15.515 --> 58:21.755
also then have the actual test results from all
the patients, whether they actually tested positive

58:21.755 --> 58:35.795
for cancer or not. So to do a little more cleanup
here. So these negative, positive, negative

58:35.795 --> 58:42.955
positive, those are actually referencing to the
test results. So let's just leave them like that

58:43.055 --> 58:48.575
We have a negative result and a positive result
from both of these scenarios, whether there is

58:48.575 --> 58:55.415
cancer or whether there isn't. And so really,
if we did want to name these with the true

58:55.415 --> 59:02.035
positives and the true negatives, this here
on the right, when there is a positive test

59:02.035 --> 59:12.455
result plus our algorithm said that it's
positive, this is the true positive here, actually

59:12.455 --> 59:16.615
So sorry, I got my terms mixed
a little bit in the explanation

59:16.615 --> 59:21.735
And it is also getting mixed because when
we are talking about cancer and such things

59:21.855 --> 59:27.195
that is, we are talking about like
healthcare situations and other way around

59:27.555 --> 59:32.435
So it is positive and it's not
that good, right? Yeah, exactly

59:32.435 --> 59:36.315
It's a good result. And that's why
it is a bit confusing at this point

59:37.015 --> 59:42.635
Yeah, exactly. So the positive is in this case
now referencing that to, yes, there is cancer

59:42.795 --> 59:48.115
This algorithm is working. So the true positive
reference is to yes, the algorithm works

59:48.975 --> 59:53.215
So then this, for example, here
would be the false positive here

59:55.795 --> 01:00:11.600
And then on this side, this would be a false positive. negative. And then
this would be a true negative because actually they didn't have cancer

01:00:12.640 --> 01:00:20.160
So what we're calculating here is when we want
to calculate what is the probability of somebody

01:00:20.160 --> 01:00:28.400
having cancer when their test result is
positive, we need to look at the true positives

01:00:28.400 --> 01:00:38.080
of when they... So let me
just do one more step here

01:00:40.480 --> 01:00:44.540
Let's take that color. So if
you think about it this way

01:00:45.320 --> 01:00:49.540
this is our A and this is
our B from here, A and B

01:00:50.660 --> 01:00:56.180
And then so for the true positives,
we want to take the probability of

01:00:56.300 --> 01:01:08.740
yes, there is cancer. So that is this one here, that one.
So this one. And then we want to take the probability of

01:01:08.740 --> 01:01:16.780
the test being positive when they have cancer
and that we have here. So we get it over here

01:01:17.300 --> 01:01:33.866
And then the probability of B of there being positive then there we do need to take all the test results where
we get positive So we need to find these ones Here a positive test result and here is a positive test result

01:01:33.866 --> 01:01:42.386
So for this one, we get first these two again, and
then for this one on the left, we get these two

01:01:42.386 --> 01:01:48.426
So that's how it builds up. So that's
how it's using the Bayes' theorem

01:01:48.426 --> 01:02:00.906
behind the scenes. We just worded it a little differently. Yeah. And I think now that
you made circles and lines here and there, I really hope it made a bit more sense

01:02:01.506 --> 01:02:20.886
Yes, I hope so as well. Otherwise, I think since now it is over with the mathematics sessions, I think we are
going to put together basically a collection of resources and some of the things Heine talked about and shown

01:02:20.886 --> 01:02:25.306
and that is going to be
available at our webpage as well

01:02:25.306 --> 01:02:34.306
So you can find even more details, hopefully.
And maybe some practical exercises as well

01:02:35.126 --> 01:02:39.646
Exactly. So you can play around with
all the things we learned already

01:02:40.346 --> 01:02:47.306
And I think we answered the questions
and we got a lot of nice feedbacks

01:02:47.306 --> 01:03:02.293
feedbacks and thank you a lot everyone for joining Maybe we can show
the one that Jean wrote us Yes I hope I correctly said his name

01:03:03.273 --> 01:03:08.033
And yeah, so I also did
have a lot of fun today

01:03:08.693 --> 01:03:14.213
And I have the feeling that I'm sort of going
to miss these mathematical sessions a lot

01:03:14.293 --> 01:03:26.033
Yeah. Because it is actually a lot of fun. Exactly. and it is always nice
to go back to the basics a bit and and refresh these things in our head as

01:03:26.033 --> 01:03:33.573
well so i really i really enjoyed it so how did
you guys feel about it i thought it was really

01:03:33.573 --> 01:03:39.473
really interesting and as eve said you know we we
will miss you because now we've had five sessions

01:03:39.473 --> 01:03:45.533
which has been really great exactly and thank
you so much for having me for this part it was

01:03:45.533 --> 01:03:51.433
really fun for me to prepare for this and I'm
glad I got to go back to the Bayes theorem to

01:03:51.433 --> 01:03:57.033
make some circles and make it clearer I was
hurrying through it a little bit and I'm like

01:03:57.033 --> 01:04:06.173
never hurry that is never the answer in math no
not in math at least exactly you put in some time

01:04:06.173 --> 01:04:14.033
and make sure that you enjoy it also like how did
you say last time like having a walk walk in the

01:04:14.033 --> 01:04:18.073
In the park. A walk in the park,
yeah. Right, that's exactly. Exactly

01:04:18.073 --> 01:04:30.880
Yeah so that how it feels every time we talk about mess And well Heidi thank you again
for your time and for the awesome sessions and all the knowledge that you shared with us

01:04:30.880 --> 01:04:35.800
And I hope we can welcome you
at other times as well at AI42

01:04:37.160 --> 01:04:46.240
And I think it is time to say goodbye to you.
And let's start and move on to our next event

01:04:46.240 --> 01:04:51.440
which is going to be in two
weeks on the 24th of March

01:04:52.100 --> 01:04:57.980
which is March. Sorry, I can't talk anymore.
And that is going to be about Transact SQL

01:04:58.660 --> 01:05:02.660
So you can see we go a bit
into the world of programming

01:05:02.660 --> 01:05:13.760
and learn a bit more about technologies as well.
And I hope you will join us that time as well

01:05:13.760 --> 01:05:21.220
yep so with that said we just want to thank all
the people who have tuned in and all of those of

01:05:21.220 --> 01:05:27.120
you who looks at this afterwards on our youtube
channel and looking forward to seeing you next

01:05:27.120 --> 01:05:34.440
time yes and don't forget to follow us on
twitter instagram or facebook or all of them

01:05:34.440 --> 01:05:39.760
yes yes thank you see you soon thank you
