Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
mathematics for machine learning
my name is richard kirschner with the
simply learn team that's get certified
get ahead
we're going to cover mathematics for
machine learning so today's agenda is
going to cover data and its types then
we're going to dive into linear algebra
and its concepts
calculus statistics for machine learning
probability for machine learning
hands-on demos
and of course thrown in there in the
middle is going to be your matrixes and
a few other things to go along with all
this
data in its types
data denotes the individual pieces of
factual information collected from
various sources it is stored processed
and later used for analysis
and so we see here just a huge grouping
of information a lot of tech stuff money
dollar signs numbers
and then you have your performing
analytics to drive insights and
hopefully you have a nice share your
shareholders gather it at the meeting
and you're able to explain it in
something they can understand
so we talk about data types of data
we have in our types of data we have a
qualitative categorical
you think nominal or ordinal
and then you have your quantitative or
numerical which is discrete or
continuous
and let's look a little closer at those
data type vocabulary always people's
favorite is the vocabulary words okay
not mine
but let's dive into this what we mean by
nominal
nominal they are used to label various
uh label our variables without providing
any measurable value
country gender race hair color etc
it's something that you either mark true
or false this is a label it's on or off
either they have a red hat on or they do
not
so a lot of times when you're thinking
nominal data
labels
think of it as a true false kind of
setup and we look at ordinal this is
categorical data with a set order or a
scale to it
and you can think of salary range as a
great one
movie ratings etc you can see here the
salary rates if you have 10 000 to 20
000 number of employees earning that
rate is 150 20 000 to 30
100 and so forth some of the terms
you'll hear is bucket
this is where you have 10 different
buckets and you want to separate it into
something that makes sense into those 10
buckets
and so when we start talking about
ordinal a lot of times when you get down
to the brass bones again we're talking
true false
so if you're a member of the 10 to 20k
reigns
so forth those would each be either part
of that group or you're not but now
we're talking about buckets so we want
to count how many people are in that
bucket quantitative numerical data
falls into two classes discrete or
continuous
and so data with a final set of values
which can be categorized class strength
questions answered correctly and runs
hit and cricket a lot of times when you
see this you can think integer
and a very restricted integer i.e
you can only have 100 questions
on a test so you can it's very discreet
i only have 100 different values that it
can attain so think usually you're
talking about integers but within a very
small range they don't have an open in
or anything like that
so discrete is very solid
simple to count
set number
continuous on the other hand uh
continuous data can take any numerical
value within a range so water pressure
weight of a person etc usually we start
thinking about float values where they
can get phenomenally small and they're
in what they're worth
and there's a whole series of values
that falls right between discrete and
continuous
you can think of the stock market you
have dollar amounts it's still discrete
but it starts to get complicated enough
when you have like you know jump in the
stock market from
525.33 cents to
580.67
there's a lot of point values in there
it'd still be called discrete but you
start looking at it as almost continuous
because it does have such a variance in
it now uh we talked about no we did we
went over nominal and ordinal
almost true false charts and we looked
at quantitative and numerical data which
will start to get into numbers discrete
you can usually a lot of times discrete
will be put into it could be put into
true false but usually it's not uh so we
want to address this stuff and the first
thing you want to look at is the very
basic which is your algebra so we're
going to take a look at linear algebra
you can remember back when your
euclidean geometry we have a line well
let's go through this we have a linear
algebra is the domain of mathematics
concerning linear equations
and the representations in vector spaces
and through matrixes i told you we're
going to talk about matrix is
uh so a linear equation
is simply
2x plus 4y minus 3z equals 10. very
linear 10x plus 12.4 y equals z and now
you can actually solve these two
equations by combining them
and that's we're talking about a linear
equation
in the vectors we have a plus b equals c
now we're starting to look at a
direction
and these values usually think of an x y
z plot
so each one is a direction
and the actual
distance of like a triangle a b is c
and then your matrix can describe all
kinds of things
i find matrixes
confuse a lot of people
not because they're particularly
difficult but because of the magnitude
and the different things they're used
for and a matrix is a chart
or a you know think of a spreadsheet but
you have your rows and your columns
and you'll see here we have a times b
equals c
very important to know your counts
so depending on how the math is being
done what you're using it for making
sure you have the same rows and number
of columns or a single number there's
all kinds of things that play in that
that can make matrixes confusing
but really has a lot more to do with
what domain you're working in are you
adding in
multiple polynomials where you have like
a x squared plus b y plus you know you
start to see that it can be very
confusing versus a very straightforward
matrix
and let's just go a little deeper into
these because these are such primary
this is what we're here to talk about is
these different math uh mathematical
computations that come up
so we're looking at linear equations
let's dig deeper into that one an
equation having a maximum order of one
is called a linear equation
so it's linear because when you look at
this we have ax plus b equals c which is
a one variable
we have two variable a x plus b y equals
c a x plus b y plus z c z equals d
and so forth but all of these
are to the power of one you don't see x
squared you don't see x cubed so we're
talking about linear equations that's
what we're talking about in their
addition
if you have already dived into say
neural networks you should recognize
this ax plus by plus cz
setup plus the intercept
uh which is basically your your neural
network each node adding up all the
different inputs and we can drill down
into that most common formula is your y
equals mx plus c
so you have your y
equals the m which is your slope
your x value plus c
which is your
y-intercept you kind of labeled it wrong
here
threw me for a loop but the the c would
be your y-intercept so when you set x
equal to zero y equals c and that's
that's your y-intercept right there
uh and that's they just had a reverse
value of y when x equals zero equals the
y-intercept which is c and your slow
gradient line which is your m so you get
your y equals two x plus three
and there's lots of easy ways to compute
this this way this is why we always
start with the most basic one when we're
solving one of these problems and then
of course the
one of the most important takeaways is
the slope gradient of the line
so the slope is very important that m
value
in this case we went ahead and solved
this
if you have y equals 2x plus 3 you can
see how it has a nice line graph here on
the right
so matrixes a matrix refers to a
rectangular representation of an array
of numbers arranged in columns and rows
so we're talking m rows by n columns
here a11 is denotes the element of the
first row in the first column similarly
a12 and it's really pronounced a11 in
this particular setup so it's a row one
column one a 12 is a
row one column two
first row and second column and so on
and there's a lot of ways to denote this
i've seen these as like a capital letter
a smaller case a for the top row or i
mean you can see where they can go all
kinds of different directions as far as
the value
you just take a moment to realize
there's need to be some designation as
far as what row it's in and what column
it's in
and we have our basic operations we have
addition so when you think about
addition you have uh
two matrixes of two by two and you just
add each individual number in that
matrix and then when you get to the
bottom you have uh in this case the
solution is twelve 10 plus 2 is 12 5
plus 3 is 8 and so on and the same thing
with subtraction
now again your counting matrix is you
want to check your
dimensions of the matrix
the shape you'll see shape come up a lot
in programming so we're talking about
dimensions we're talking about the shape
if the two shapes are equal
this is what happens when you add them
together or subtract them
and we have multiplication when you look
at the multiplication you end up with a
very uh a slightly different setup going
now
if we look at our last one we're uh uh
we're like why
this always gets to me when we get to
matrixes they don't really say why you
multiply matrixes
you know my first thought is one times
two four times three but if you look at
this we get one times two plus four
times three
one times three plus four times five
uh six times two plus three times three
six times three plus three times five if
you're looking at these matrixes uh
think of this more as an equation
and so we have if you remember we went
back up here for our multiple line
equations let's just go back up a couple
slides where we were looking at
two variables so this is a two variable
equation a x plus b y equals c
and this is a way to make it very quick
to solve these variables and that's why
you have the matrix and that's why you
do
the multiplication the way they do
and this is the dot product of uh one
times two
plus four times three
one times three plus four times five
six times two plus three times three
six times three plus three times five
and it gives us a nice little
14 23 21 and 33 over here which then can
be used and reduced down to a sample
formula as far as solving the variables
as you have enough inputs
and then in matrix operations when
you're dealing with a lot of matrixes
now keep in mind multiplying matrixes is
different than finding the product of
two matrixes okay so we're talking about
multiplication we're talking about
solving uh for equations when you're
finding the product you are just finding
one times two keep that in mind because
that does come up i've had that come up
a number of times where i am altering
data and i get confused as to what i'm
doing with it
uh transpose flipping the matrix over is
diagonal comes up all the time where you
have you still have 12 but instead of it
being 12 8 it's now 12 14
8 21 you're just flipping the columns
and the rows
and then of course you can do an inverse
changing the signs of the values across
this main diagonal
and you can see here we have the inverse
a to the minus 1 and ends up with
instead of 12 8 14 12 is now minus 22
minus 12.
vectors
vector just means we have
a value and a direction
and we have down four numbers here on
our vector
uh in mathematics a one dimensional
matrix is called a vector uh so
if you have your x plot and you have a
single value that values along the x
axis and it's a single dimension
if you have two dimensions you can think
about putting them on a graph you might
have x and you might have y and each
value denotes a direction and then of
course the actual distance is going to
be the hypothesis of that triangle and
you can do that with three dimensionals
x y and z
and you can do it all the way to nth
dimensions so when they talk about the k
means
for categorizing and how close data is
together they will compute that based on
the pythagorean theorem so you would
take
the square of each value add them all
together and find the square root and
that gives you a distance
as far as where that point is where that
vector exists or an actual point value
and then you can compare that point
value to another one it makes a very
easy comparison versus comparing 50 or
60 different numbers
and that brings us up to i gene vectors
and i gene values
hygiene vectors the vectors that don't
change their span while transformation
and i gene values the scalar values that
are associated to the vectors
conceptually
you can think of the vector as your
picture you have a picture it's uh
two dimensions x and y
and so when you do those two dimensions
and those two values or whatever that
value is
that is that point but the values change
when you skew it and so
if we take and we have a vector a
and that's a set value uh
b is um your is your you have a and b
which is your i gene vector two is the i
gene value so we're altering
all the values by two that means we're
maybe we're stretching it out one
direction making it tall uh if you're
doing picture editing
that's one of the places this comes in
but you can see when you're transforming
uh your different information how you
transform it is then your hygiene value
and you can see here vector after line
transit transition uh we have 3a a is
the hygiene vector 3 is the aging value
so a doesn't change that's whatever we
started with that's your original
picture and 3
is skewing it one direction and maybe
a b is being skewed another direction
and so you have a nice tilted picture
because you altered it by those by the
hygiene values
so let's go ahead and pull up a demo on
linear algebra and to do this i'm going
to go through my trusted anaconda into
my jupiter notebook
and we'll create a new
notebook called linear algebra
since we are working in python we're
going to use our numpy i always import
that as np or numpy array probably the
most popular
module for doing matrixes and things in
given that this is part of a series i'm
not going to go too much into numpy we
are going to go ahead and create two
different variables a for a numpy array
10 15 and b 29
we'll go ahead and run this and you can
see there's our two arrays 10 15 29 and
i went and added a space there in
between
so it's easier to read
and since it's the last line we don't
have to put the print statement on it
unless you want we can simply but we can
simply do a plus b so when i run this uh
we have 10 15 29 and we get 30 24 which
is what you expect 10 plus 20 15 plus 9
you could almost look at this addition
as being
just adding up the columns on here
coming down and if we wanted to do it a
different way we could also do a dot t
plus b dot t
remember that t flips them and so if we
do that we now get them uh we now have
30 24 going the other way
we could also do something kind of fun
there's a lot of different ways to do
this
as far as a plus b i can also do a plus
b
dot t
and you're going to see that that will
come out the same the 30 24 whether i
transpose a and b or transpose them both
at the end
and likewise we can very easily subtract
two vectors i can go a minus b
and we run that and we get minus 10 6
now remember this is the last line in
this particular section that's right not
to put the print around it
and just like we did before
we can transpose either the individual
or we can transpose the main setup and
then we get a minus 10 6 going the other
way
now we didn't mention this in our notes
but you can also do a scalar
multiplication
and just put down the scalar so you can
remember that
uh what we're talking about here is i
have
this
array here u
and if i go a
times u
we'll take the value 2 we'll multiply it
by every value in here so 2 times 30 is
60 2 times 15
and just like we did before
this happens a lot because when you're
doing matrixes you do need to flip them
you get 60 30 coming this way
so in numpy uh we have what they call
dot product
and uh with this this is in a two
dimensional vectors it is equivalent of
two matrix multiplication remember we
were talking about matrix multiplication
uh where it is the
well let's walk through it
we'll go ahead and start by defining two
numpy arrays we'll have uh 10 20 25 6 or
our u and our v uh and then we're going
to go ahead and do
if we take
the values
and if you remember correctly
an array like this would be 10 times 25
plus 20 times 6.
we'll go ahead and
print that
there we go
and then we'll go ahead and do the np
dot dot
of u comma
v
and we'll find when we do this we go and
run this
we're going to get 370
370. so this is a strain multiplication
where they use it to solve
linear algebra when you have multiple
numbers going across and so this could
be very complicated we could have a
whole string of different variables
going in here but for this we get a nice
value for our dot multiplication
and we did
addition earlier which is just your
basic addition
and of course the matrix you can get
very complicated on these or
in this case we'll go ahead and do
let's create two
complex matrixes
this one is a matrix of
you know 12 10 4 6 4 31. we'll just
print out a so you can see what that
looks like here's print
a
we print a out you can see that we have
a
2 by 3 layer matrix for a
and we can also put together
always kind of fun when you're playing
with print values
we could do something like this we could
go in here
there we go
we could print a we have it end with
equals a
run
and this kind of gives it a nice look
here's your matrix that's all this is
comma n means it just tags it on the end
that's all that is doing on there
and then we can simply add in what is a
plus b and you should already guess
because this is the same as what we did
before there's no difference
we do a simple vector addition we have
12 plus 2 is 14 10 plus 8 is 18 and so
on
and just like we did the matrix addition
we can also do a minus b
and do our matrix subtraction
and we look at this we have what 12
minus 2 is 10 10 minus 8 um where are we
oh there we go eight minus uh
confusing what i'm looking at i should
have reprinted out the original numbers
uh but we can see here 12 minus 2 is of
course 10 10 minus 8 is 2
4 minus 46 is minus 42 and so forth so
same as a subtraction as before we just
call it matrix subtraction it's
identical
now if you remember up here we had
scalar addition we're adding just one
number
to a matrix you can also do scalar
multiplication
and so simply if you have a single value
a and you have b which is your array we
can also do a times b when we run that
you can see here we have 2 times 4 is 8
5 times 4 is 20 and so forth you're just
multiplying the 4 across each one of
these values
and this is an interesting one that
comes up a little bit of a brain teaser
is matrix and vector multiplication
and so when we're looking at this
we are
just doing regular arrays it doesn't
necessarily have to be a numpy array we
have a
which has our
array of arrays and b which is a single
array and so we can from here
do the dot
a b
and this is going to return two values
and the first value is that is you could
say it's like
we're doing the
this array b array
first with a and then with a second one
and so it splits it up so you have a
matrix of vector multiplication and you
can mix and match
when you get into really complicated uh
back end stuff this becomes more common
because you're now you've got layers
upon layers of data and so you'll end up
with a matrix and a set of bolt uh
vector matrices do you want to multiply
now keep in mind
that if you're doing data science a lot
of times you're not looking at this this
is what's going on behind the scenes so
if you're in the scikit looking at sk
learn where you're doing linear
regression models
this is some of the math that's hidden
behind the scenes that's going on
other times you might find yourself
having to do part of this and manipulate
the data around so it fits right and
then you go back in and you run it
through the psi kit and if we can do
up here where we did a
matrix and vector multiplication we can
also do matrix two matrix multiplication
and if we run this where we have the two
matrixes
you can see we have a very complicated
array that of course comes out on there
for our dot
and just to reiterate it we have our
transpose a matrix which is your dot t
and so if we create a matrix a and we do
uh transpose it you can see how it flips
it from
5 10 15 20 25 30 to 5 15 25
10 20 30
rows and columns
and certainly with the math uh this
comes up a lot um it also comes up a lot
with xy plotting when you put in the pi
plot you have one format where they're
looking at pairs and numbers and then
they want all of x's and all y's so you
know the transpose is an important tool
both for your math and for plotting and
all kinds of things
another tool that we didn't discuss uh
is your identity matrix
uh and this one is more definition
the identity matrix
we have here one where we just did two
so it comes down as one zero zero one
one zero zero zero one zero it creates a
diagonal of one and what that is is when
you're doing your identities you could
be comparing
all your different features to the
different features and how they
correlate
and of course when you have feature one
compared to feature one to itself it is
always
one
where
usually it's between zero one depending
on how well correlates so when we're
talking about identity matrix that's
what we're talking about right here is
that you create this preset matrix and
then you might adjust these numbers
depending on what you're working with
and what the domain is
and then another thing we can do
to kind of wrap this up we'll hit you
with the most complicated
piece of this
puzzle here is an inverse
a matrix
and let's just go ahead and put the um
it's a lengthy description
let's go and put the description this is
straight out of the uh
the website for
numpy so given a square matrix a here's
our square matrix a which is 2 1 0 0 1 0
1 2 1. keep in mind 3 by 3 is square
it's got to be equal it's going to
return the matrix a inverse satisfying
dot a
a inverse so here's our matrix
multiplication
and then of course it equals the dot
yeah a inverse of a
with an identity shape of
a dot shaped zero this is just reshaping
the identity
that's a little complicated there uh so
we're going to have our here's our array
we'll go ahead and run this
and you can see what we end up with
is we end up with uh an array 0.5 minus
0.5 and so forth with our 2 1 1 going
down 2 1 0 0 1 0 1 2 1.
getting into a little deep on the math
understanding
when you need this is probably really is
is what's really important when you're
doing data science
versus
handwriting this out and looking up the
math and handwriting all the pieces out
you do need to know about the linear
algorithm inverse of a
so if it comes up you can easily pull it
up or at least remember where to look it
up we took a look at the algebra side of
it let's go ahead and take a look at the
calculus side of what's going on here
with the machine learning so calculus oh
my goodness and differential equations
you got to throw that in there because
that's all part of the
bag of tricks especially when you're
doing large neural networks but also
comes up in many other areas the good
news is most of it's already done for
you in the back end uh so when it comes
up you really do need to understand from
the data science not data analytics data
analytics means you're digging deep into
actually solving these math equations
and a neural network is just a giant
differential equation
so we talk about calculus
we're going to go ahead
and understand it by talking about cars
versus time and speed
so helps to calculate the spontaneous
rate of change
so suppose we plot a graph of the speed
of a car with respect to time
so as you can see here going down the
highway probably merged into the highway
from an on-ramp so i had to accelerate
so my speed went way up
uh stuck in traffic merged into the
traffic traffic opens up and i
accelerate again up to the speed limit
and uh maybe peter's off up there so you
can look at this as as
the speed versus time i'm getting faster
and faster because i'm continually
accelerating and if i hit the brakes you
go the other way
so the rate of change of speed with
respect of time is nothing but
acceleration how fast are we
accelerating
the acceleration is the area between the
star point of x and the end point of
delta x
so we can calculate a simple
if you had x and delta x we could put a
line there and that slope of the line is
our acceleration
now that's pretty easy when you're doing
linear algebra but i don't want to know
it just for that line in those two
points i want to know what across
the whole of what i'm working with
that's where we get into calculus
so we talk about the distance between x
and delta x it has to be the smallest
possible near to zero in order to
approximate the acceleration
uh so the idea is instead of i mean if
you ever did took a basic calculus class
they would draw bars down here and you
would divide this area up
let's go back up the screen you divide
this area of this time period up into
maybe 10 sections and you'd use that and
you could calculate the acceleration
between each one of those 10 sections
kind of thing
and then we just keep making that space
smaller and smaller until delta x is
almost
infinitesimally small
and so we get a function of a
equals a limit as h goes to 0 of a
function of a plus h minus a function of
a over h and that is you're
computing the slope of the line
we're just computing that slope and
they're smaller and smaller and smaller
samples
and that's what calculus is calculus is
the integral you can see down here we
have our nice uh integral sign looks
like a giant s
and that's what that means is that we've
taken this down to as small as we can
for that sampling
so we're talking about calculus we're
finding the area under the slope is the
main process in the integration
similar small intervals are made of the
smallest possible length of x plus delta
x where delta x approaches almost an
infinitesimally small space
and then it helps to find the overall
acceleration by summing up all the links
together
so we're summing up all the
accelerations from the beginning to the
end
and so here's our integral we sum of a
of x times d of x
equals a plus c
uh that is our basic calculus here
so when we talk about multivariate
calculus
multivariate calculus deals with
functions that have multiple variables
and you can see here we start getting
into some very complicated equations um
changing w over change of time
equals change of w over change of z
the differential of z to dx differential
of x to dt it gets pretty complicated uh
and it really translates into the
multivariate integration using double
integrals and so you have the the sum of
the sum of f of x of y of d of a equals
the sum from c to d and a to b of f of x
y d x d y equals
uh the sum of a to b sum of c to d of f
x y d y d x
understanding the very specifics of
everything going on in here and actually
doing the math is usually calculus 1
calculus 2 and differential equations so
you're talking about three full length
courses to dig into
and solve these math equations
what we want to take from here is we're
talking about calculus
we're talking about summing of all these
different slopes and so we're still
solving a linear
expression we're still solving
y equals m x plus b
but we're doing this for infinitesimally
small x's and then we want to sum them
up that's what this integral sign means
the sum of a of x d of x equals a plus c
and when you see these very complicated
multivariate differentiation using the
chain rule
when we come in here and we have the
change of w to the change of t equals
the change of w dz
uh and so forth
that's what's going on here that's what
these means we're basically looking for
the area under the curve which really
comes to
how is the change changing speeds going
up how is that changing and then you end
up with a multiple layer so if i have
three layers of neural networks how is
the third layer changing based on the
second layer changing which is based on
the first layer changing and you get the
picture here that now we have a very
complicated
multivariate integration
with integrals
the good news is we can solve this
mathematically and that's what we do
when you do neural networks and reverse
propagation
so the nice thing is that you don't have
to solve this on paper unless you're a
data analysis and you're working on the
back end of integrating these formulas
and building the script to actually
build them so we talk about applications
of calculus it provides us the tools to
build an accurate predictive model
so it's really behind the scenes we want
to guess at what the change of the
change of the change is
that's a little goofy i know i just
threw that out there it's kind of a meta
term but if you can guess how things are
going to change then you can guess what
the new numbers are
multivariate calculus explains the
change in our target variable in
relation to the rate of change in the
input variables
so there's our multiple variables going
in there
if one variable is changing how does it
affect the other variable
and then in gradient descent calculus is
used to find the local and global maxima
and this is really big
we're actually going to have a whole
section here on gradient descent because
it is
really i mean i talked about neural
networks and how you can see how the
different layers go in there but
gradient descent is one of the most key
things for trying to guess the best
answer to something
so let's take a look at the code behind
gradient descent
and uh before we open up the code let's
just do real quick
uh gradient descent
let's say we have a curve like this and
most common
is that this is going to represent your
error oops
error there we go error
hard to read there and i want to make
the error as low as possible
and so what i'm looking at it is i want
to find this line here
which is the
minimum value so we're looking for the
minimum and it does that by uh sampling
there
and then based on this it guesses it
might be someplace here and it goes hey
this is still going down
it goes here and then goes back over
here and then goes a little bit closer
and it's just playing a high low until
it gets to that spot that bottom spot
and so we want to minimize the error in
on the flip note you could also want to
be maximizing something you want to get
the best output of it uh that's simply
uh minus the value
so if you're looking for where the peak
is
this is the same as a negative
for where the valley is looking for that
valley
that's all that is and this is a way of
finding it so
the cool thing is all the heavy lifting
is done i actually
ended up putting together one of these a
while back is when i didn't know about
sidekick and it was just starting
boy it's a long while back
and uh
is playing high low how do you play high
low not get stuck in the valleys uh
figure out these curves and things like
that well you do that and the back end
is all the calculus and differential
equations to calculate this out
the good news is you don't have to do
those
so instead we're going to put together
the code and let's go ahead
and see what we can do with that
so uh guys in the back put together a
nice little piece of code here which is
kind of fun
uh some things we're gonna note and this
is this is really important stuff
because when you start doing your data
science and digging into your machine
learning models
you're going to find
these things are stumbling blocks
the first one is current x where do we
start at
keep in mind
your
model that you're working with is very
generic so whatever you use to minimize
it the first question is where do we
start
and we started at this because the
algorithm starts at x equals three
so we arbitrarily picked five
learning rate is uh how many bars to
skip going one way or the other i'm in
fact i'm going to separate that a little
bit because these two are really
important
um if we're dealing with something like
this where we're talking about
well here's our here's the function
we're going to use our
gradient of our function
2 times x plus 5 keep it simple so
that's a function we're going to work
with so if i'm dealing with increments
of 1000.1 is going to be a very long
time and if i'm dealing with increments
of 0.001
0.1 is going to skip over my answer so i
won't get a very good answer
and then we look at precision this tells
us when to stop the algorithm so again
very specific to what you're working on
if you're working with money
and
you don't convert it into a float value
you might be dealing with 0.01 which is
a penny that might be your precision
you're working with
and then of course the previous step
size max iterations we want something to
cut out at a certain point usually
that's built into a lot of minimization
functions
and then here's our actual uh formula
we're going to be working with
and then we come in we go while previous
step size is greater than precision and
it is less than max and max iters
say that 10 times fast
um
we're just saying if it's uh if we're if
we're still greater than our precision
level we still got to keep digging
deeper
and then we also don't want to go past a
thou or whatever this is a million or 10
000
running that's actually pretty high we
almost never do max iterations more than
like 100 or 200
rare occasions you might go up to four
or 500 if it's depending on the problem
you're working with
uh so we have our previous equals our
current that way we can track time wise
the current now equals the current minus
the rate times the formula of our
previous x
so now we've generated our new version
previous step size equals the absolute
current previous
so we're looking for the change in x
errors equals iterations plus one that's
so we know to stop if we get too far
and then we're just going to print the
local minimum occurs at
x on here and if we go ahead and run
this
you can see right here it gets down to
this point and it says hey
local minimum is minus
3.3222 for this particular series we
created this is created off of our
formula here lambda x2 times x plus five
now
when i'm running this stuff you'll see
this come up a lot
in
with the sk learn kit and one of the
nice reasons of breaking this down the
way we did
is i could go over those top pieces
those top pieces are everything when you
start looking at these minimization tool
kits in built-in code and so from
we'll just do it's actually
docs
dot
scipy.org
and we're looking at
the scikit
there we go optimize minimize
you can only minimize one value
you have the function that's going in
this function can be very complicated
so we used a very simple function up
here
it could be
there's all kinds of things that could
be on there and there's a number of
methods to solve this as far as how they
shrink down
uh and your x naught there's your
there's your start value so your
function your start value
there's all kinds of things that come in
here that you can look at which we're
not going to
optimization automatically creates
constraints bounds
some of this it does automatically but
you really the big thing i want to point
out here is you need to have a starting
point you want to start with something
that you already know is mostly the
answer
if you don't then it's going to have a
heck of a time trying to calculate it
out
or you can write your own little script
that does this and does a high low
guessing and tries to find the max value
that brings us to statistics what this
is kind of all about is figuring things
out a lot of vocabulary and statistics
uh so statistics well i guess it's all
relative it's definitely not an edel
class
so a bunch of stuff going on statistics
statistics concerns with the collection
organization analysis interpretation
and presentation of data
that is a mouthful
so we have from end to end
where does it come from is it valid what
does it mean how do we organize it um
how do we analyze it and then you gotta
take those analysis and interpret it
into something that people can use kind
of reduce it to
understandable
and nowadays you have to be able to
present it if you can't present it then
no one else is going to understand what
the heck you did
so we look at the terminologies
there is a lot of terminologies
depending on what domain you're working
in
so clearly if you're working in
a domain that deals with
viruses and t cells and and
how does you know where does that come
from you're studying the different
people that you can have a population
if you are working with um
mechanical gear
you know a little bit different if
you're looking for the wobbling
statistics uh to know when to replace a
rotor on a machine or something like
that
that can be a big deal you know we have
these huge fans that turn
in our sewage processing systems and so
those fans they start to wobble and hum
and do different things that the sensors
pick up at one point do you replace them
instead of waiting for it to break in
which case it costs a lot of money
instead of replacing a bushing you're
replacing the whole fan unit
an interesting project that came up for
our city a while back
so population all objects are
measurements whose properties are being
observed
so that's your population all the
objects it's easy to see it with people
because we have our population in large
but in the case of the sewer fans we're
talking about having the fan units
that's the population of fans that we're
working with
you have a parameter a matrix that is
used to represent a population or
characteristic
you have your sample a subset of the
population studied you don't want to do
them all because then you don't have a
if you come up with a conclusion for
everyone you don't have a way of testing
it so you take a sample
sometimes you don't have a choice you
can only take a sample of what's going
on you can't study the whole population
and a variable a metric of interest for
each person or object in a population
types of sampling
we have a probabilistic approach
selecting samples from a larger
population using a method based on the
theory of probability
and we'll go into a little bit more
deeper on these we have random
systematic stratified and then you have
a non-probabilistic approach selecting
samples based on the subjective judgment
of the researcher rather than random
selection
it has to do with convenience trying to
reach a quota
or snowball
and they're very biased that's one of
the reasons you'll see this big stamp on
that says biased so you gotta be very
careful on that
so probabilistic sampling uh when we
talk about a random sampling we select
random size samples from each group or
category so we it's as random as you can
get we talk about systematic sampling
we're selecting random size samples from
each group or category with a fixed
periodic interval
uh so we kind of split it up this would
be like a time set up or different
categories
and you might ask your question what is
a category or a group
if you look at i'm going to go back a
window let's say we're studying
economics of different of an area
we know pretty much that based on their
culture where they came from
they might need to be separated and so
uh and when i say separated i don't mean
separated from their
place where they live i mean as far as
the analysis we want to look at the
different groups and make sure they're
all represented
so if we had like an eighty percent uh
of a group that is uh say hispanic and
or indian and also in that same area we
have 20 20 percent who are
let's call our expatriates they left
america and they're nice and
your caucasian group we might want to
sample a group that is representative of
both uh so we're talking about
stratified sampling and we're talking
about groups those are the groups we're
talking about and it brings us to
stratified sampling selecting
approximately equal size samples from
each group or category
this way we can actually separate the
categories and give us an insight into
the different cultures and how that
might affect them in that area
so you can see these are very very
different kind of
depends on what you're working with
as far as your data and what you're
studying
and so we can see here just a little bit
more we'd have selecting 25 employees
from a company of 250 employees randomly
don't care anything about them what
groups are in which office they're in
nothing
and we might be selecting one employee
from every 50 unique employees and a
company of 250 employees
and then we have selecting one employee
from every branch in the company office
so we have all the different branches
there's our group or categories by the
branch and the category could depend on
what you're studying so it has a lot of
variation on there
you see this kind of grouping and
categorizing is also used to generate a
lot of misinformation
so if you only study one group and you
say this is what it is
then everybody assumes that's what it is
for everybody and so you've got to be
very careful of that and it's very
unethical thing to kind of do
so types of statistics uh we talk about
statistics
we're going to talk about descriptive
and inferential statistics
there are so many different terms and
statistics to break it up uh so we so
we're talking about a particular
setup
so we're talking about descriptive and
inferential uh statistics
the base of the word describe
is pretty solid you're describing the
data what does it look like with
inferential statistics we're going to
take that from the small population to a
large population so if you're working
with a drug company you might look at
the data and say these people were
helped by this drug
they did
80 percent better
as far as their health or 80 percent
better survival rate than the people
who did not have the drug so we can
infer that that drug will work in the
greater populace and will help people so
that's where you get your inferential so
we are
predicting how it's going to affect the
greater population
so descriptive statistics it is used to
describe the basic features of data and
form the basis of quantitative analysis
of data
so we have a measure of central
tendencies we have your mean median and
mode
and then we have a measure of spread
like your range your interquartile range
your variance and your standard
deviation
and we're going to look at all these a
little deeper here in a second
but one of them you can think of is
how it the data difference
differences you know what's the max min
range all that stuff is your spread and
anything that's just a single number is
usually your central uh tendencies
measure of central tendencies
so we talk about the mean it is the
average of the set of values considered
what is the average outcome of whatever
is going on
and then your median
separates the higher half and the lower
half of data
so where's the center point of all your
different data points so your mean might
have some a couple really big numbers
that skew it
so that the average is much higher than
if you took those outliers out where the
median would by separating the high from
the low might give you a much lower
number you might look at and say oh
that's that's odd why is the average so
much higher than the median well it's
because you have some outliers or why is
it so much lower
and then the mode is the most frequent
appearing value
this is really interesting if you're
studying economics and how people are
doing you might find that the most
common
income like in the us was
1.24 000 a year
where the average was closer to 80 000
and it's like wow what a difference well
there's some people have a lot of money
and so that skews that way up so the
average person is not making that kind
of money and then you look at the median
income and you're like well the median
income is a little bit closer to the
average so it does create a very
interesting way of looking at the data
again these are all uh central
tendencies single numbers you can look
at for the whole spread of the data
and we look at the measure of central
tendencies the mean is the average marks
of a students in a classroom so here we
have the mean sum of the marks of the
students total number of students and as
we talked about the median
we have
0 through 10 and we take half the
numbers and put them on one side of the
line half the numbers on the other side
of the line uh we end up with five in
the middle and then the mode what mark
was scored by most of the students in a
test
in a simple case where most people
scored like an 82 percent and got
certain problems wrong easy to figure
out uh not so easy when you have
different areas where like you have like
the um oh let's go back to economy a
little bit more difficult to calculate
if you have a large group that scores
that makes 30 000
and a slightly bigger group that makes
26 000 so what do you put down for the
mode uh certainly there's a number of
ways to calculate that and there's
actually a different variations
depending on what you're doing
so now we're looking at a measure of
spread uh range what's the difference
between the highest and the lowest value
first thing you want to look at you know
it's uh we had everybody in the test
scored between 60 and 100 so we got 100
or maybe 60 to 90 it was so hard a lot
of people could not get a hundred
percent
you have your
inter-quartile range quartiles divide a
rank ordered data set into four equal
parts
very common thing to do as part of all
the basic packages whether you're
working in
data frames with pandas whether you're
working in scala whether you're working
in r
you'll see this come up where they have
range your min your max and then it'll
have your interquartile range how does
it look like in each quarter of data
variance measures how far each number in
the set is from the mean and therefore
from every other number in the set
so you have like how much turbulence is
going on in this
data and then the standard deviation
it is to measure the variance or the
dispersion of a set of values from the
mean
and you'll usually see uh if i'm doing a
graph i might have the value graphed
and then based on the the error i might
graph graph the standard deviation in
the error on the graph as a background
so you can see how far off it is
uh so standard deviation is used a lot
so measurement of spread uh marks of a
student out of 100 we have here from 50
to 63 or 50 to 90.
so the range maximum marks minimum marks
we have 90 to 45 and the spread of that
is 45 90 minus 45. and then we have the
interquartile range
using the same marks over there you can
see here where the median is
and then there's the first quarter the
second quarter and the third quarter
based on splitting it apart by those
values
and to understand the variance and
standard deviation we first need to find
out the mean uh so here's our our you
know calculating the average there we
end up at approximately 66 for the
average and then we look at that the
variance once we know the means we can
do equals the marks minus the mean
squared
y is a squared
because one you want to make sure it's
you don't have like if you if you're
putting all this stuff together you end
up with an error as far as one's
negative one's positive one's a little
higher one's a little lower
so you always see
the squared value and over the total
observations
and so the standard deviation equals the
square root of the variance which is
approximately 16.
and if you were looking at
a predictable model you would be looking
at the deviation based on the error how
much error does it have
that's again
really important to know if your if your
prediction is predicting something
what's the chance of it being way off or
just a little bit off
now that we've looked at the
tools as far as some of the basics for
doing your statistics and we're talking
about
let's go ahead and pull up a little demo
and show you what that looks like in
python code
so you can get some little hands on here
for that let's go back into our jupiter
notebook and python now almost all of
this you can do in numpy last time we
worked in numpy this time we're going to
go ahead and use pandas
and if you remember from pandas on here
this is basically a data frame rows
columns let's just go ahead and do a
df.head
and run that
and you can see we have the name jane
michael william rosie hannah sat in
their salaries on here and of course
instead of having to do all those hand
calculations and add everything together
and divide by the total
we can do something very simple on this
like
use the command mean in pandas and so if
i go ahead and do this print df
pick our column salary because we want
to find the means of that calorie
we want to find the means of that column
and we go and print this out and you can
see that the
average income on here is 71 000.
and let's just go ahead and do this
we'll go ahead and put in
means
and if we're going to do that we also
might want to find the median
and the median is
very similar
except it actually is just median we're
used to means in average it's kind of
interesting that those are the use of
two different words
uh there can be in some computation
slight differences but for the most part
the means is the average uh and then the
median
oops let's put a
median here
do you have salary that way it displays
a little better we can see the median is
54
000 so the halfway mark is significantly
below the average why because we have
somebody in here makes 189 000. darn you
rosie for throwing off our numbers
but that's something you'd want to
notice this is this is the difference
between these is huge and so is what is
the meaning behind that when you're
studying a populace and looking at
the different data coming in and of
course we also want to find out hey
what's the most
common
income that people make
in this little tiny sample and so we'll
go ahead and do the mode and you can see
here with the mode
it's at 50 000.
so this is this is very telling that
most people are making 50 000
the middle point is at 54 000. so half
the people are making more than that
what that tells me is that if the most
common income is weight is below the
median
then
there's a few there's a skill there's a
lot of high salaries going up but
there's some really low salaries in
there and so this trend which is very
common in statistics when you're
analyzing
the economy in different people's income
is pretty common and the bigger
difference between these is also
very important when we're studying
statistics
and when you hear someone just say hey
the average income was you might start
asking questions at that point why
aren't you talking about the median
income why aren't you talking about the
mode the most common income what are you
hiding
and if you're doing these analysis you
should be looking at these saying hey
why are these discrepancies why are
these so different and of course with
any analysis it's important to find out
the minimum
and the maximum so we'll go ahead it's
just simply uh
dot min
it'll pull up your minimum and then dot
max pulls up the maximum
pretty straightforward on as far as um
translating it and knowing which you
know put the your lowest value which
your highest value is here
um which you'll use to generate like a
spread later on and real quick on no
mode uh note that it puts mode zero like
i said there's a couple different ways
you can compute the mode
although the standard one is pretty good
we can of course do the range
which is your max minus your min so now
we have a range of 149 000 between the
upper end and the lower end and you
might want to be looking up the
individual values on all of these but it
turns out there is a describe
feature in pandas
and so in pandas we can actually do df
salary describe and if we do this you
can see we have that there's seven uh
setups here's our mean
um our standard deviation which we
didn't compute yet which would just be a
dot std
and you gotta be a little careful
because when it computes it it looks for
axes and things like that
we have our minimum value and here's our
quartiles
our maximum value and then of course the
name salary
so these are the these are the basic
statistics you can pull them up and like
just describe
this is a dictionary so i could actually
do something like
in here i could actually go uh count
and run
and now it just prints the count
so because this is a dictionary you can
pull any one of these values out of here
it's kind of a quick and dirty way to
pull all the different information and
then split it up and depending on what
you need
now if i just walked in and gave you
this information
in a meeting
at some point you would just kind of
fall asleep that's what i would do
anyway
um
so we want to go ahead and see about
graphing it here and we'll go ahead and
put it into a histogram and plot that
graph on it
of the salaries and let's just go ahead
and put that in here so
we do our map plot inline remember
that's a jupiter's notebook thing
a lot of the new version of the matte
plot library does it automatically
but just in case i always put it in
there import matplot library pi plot is
plt that's my plotting
and then we have our data frame i don't
i guess i really don't need to respell
the data frame
maybe we could just remind ourselves
what's in it so we'll go ahead and just
df
that way we still have it
and then we have our salary df salary
salary.plot history title salary
distribution color gray
uh plot ax v line salary the mean value
so we're going to take the mean value
color violet
line style dash this is just all making
it pretty
uh what color dashed line line width of
2 that kind of thing
and the median and let's go ahead and
run this just so you can see what we're
talking about
and so up here we are taking on our plot
um so here's the data here's our our
data frame print it out so you can see
it with the salaries we'll look at the
salary distribution and just look at
this the way the salary is distributed
you have our
in this case we did
let's see we had red for the median
we have violet
for our average or mean
and you can just see how it really
i mean here's our outlier here's our
person who makes a lot of money here's
the
average and here's the median
and so as you look at this you can say
wow
based on the average it really doesn't
tell you much about what people are
really taking home all it does is tell
you
how much money is in this you know what
the average salary is
so
some of the things you want to take away
in addition to this is that it's very
easy to plot
an ax v line
these are these up and down lines for
your markers
and as you just display the data i mean
you can add all kinds of things to this
and get really complicated keeping it
simple is pretty straightforward i look
at this and i can see we have a major
outlier out here we can definitely do a
histogram and stuff like that
but you know pictures worth a thousand
words
what you really want to make sure you
take away is that we can do a basic
describe
which pulls all this information out and
we can print any of the individual
information from the describe
because this is a dictionary
and so if we want to go ahead and look
up
the mean value we can also do describe
mean so if you're doing a lot of
statistics
being able to
doesn't have the print on there so it's
only going to print the last one which
happens to be the mean
you can very easily reference any one of
these and then you can also if you're
doing something a little bit more
complicated and you don't need just the
basics you can come through and pull any
one of the individual
references from the from the pandas on
here so now we've had a chance to
describe our data
let's get into inferential statistics
inferential statistics allows you to
make predictions or inferences from data
and you can see here we have a nice
little picture movie ratings and
if we took this group of people and said
hey how many people like the movie
dislike it can't say and then you ask
just a random person who comes out of
the movie who hasn't been in this study
you can infer that 55 percent chance of
saying liked
35 chance of saying disliked or a 10 or
11 chance of can't say
so that's real basics of what we're
talking about is you're going to infer
that the next person is going to follow
these statistics
so let's look at point estimation
it is a process of finding an
approximate value for a population's
parameter like mean
or average from random samples of the
population let's take an example of
testing vaccines for covid19
vaccines and flu bugs all that it's a
pretty big thing of how do you test
these out and make sure they're going to
work on the populace
a group of people are chosen from the
population medical trials are performed
results are generalized for the whole
population so here's a protected there's
our small group up here where we've
selected them we run medical trials on
them and then the results work for the
population
nice diagram with the arrows going back
and forth and the very scary coveted
virus in the middle of one
and let's take a look at the
applications of inferential statistics
very central is what they call
hypotheses testing
and the confidence interval which go
with that and then as we get into
probability we get into our binomial
theorem our normal distribution in
central limit theorem
hypothesis testing hypothesis testing is
used to measure the plausibility of a
hypothesis
assumption by using sample data
now
when we talk about theorem's
theory
hypothesis uh keep in mind that if you
are in a philosophy class
theory
is the same as hypothesis where theorem
is a scientific uh statement that is
something that has been proven
although it is always up for debate
because in science we always want to
make sure things are up to debate so
hypothesis is the same as a
philosophical class calling a theory
where theory in science is not the same
theory in science says this has been
well proven gravity is a theory uh so if
you want to debate the theory of gravity
try jumping up and down if you want to
have a theory about why the economy is
collapsing in your area
that is a philosophical debate
very important i've heard people mix
those up and it is a pet peeve of mine
when we talk about hypotheses testing
the steps involved in hypotheses testing
is first we formulate a hypothesis
we figure out the right test to test our
hypothesis we execute the test and we
make a decision and so when you're
talking about hypothesis you're usually
trying to disprove it if you can't
disprove it
and it works for all the facts then you
might call that a theorem at some point
so in a use case uh let's consider an
example we have four students were given
a task to clean a room every day
sounds like working with my kids they
decided to distribute the job of
cleaning the room among themselves they
did so by making four chits which has
their names on it and the name that gets
picked up has to do the cleaning for
that day
rob took the opportunity to make chits
and wrote everyone's name on it so
here's our four people nick rob emlia
imlia and summer
now rick emilia and summer are asking us
to decide whether rob has done some
mischief in preparing the chits i.e
whether rob has written his name on one
of the chit
for that we will find out the
probability of rob getting the cleaning
job on first day second day third day
and so on till 12 days
the probability of rob getting the job
decreases every day i.e his turn never
comes up then definitely he has done
some mischief while making the chits
so the probability of rob not doing work
on day one is uh three out of four
there's a 0.75 chance that he didn't do
work
uh two days three fourths times three
fourths equals point five six
three days you have three fourths three
fourths three fourths which equals 0.42
when you get to day 12 it's 0.032 which
is less than 0.05
remember this .05 that comes up a lot
when we're talking about
certain values when we're looking at
statistics
rob is cheating as he wasn't chosen for
12 consecutive days that's a very high
probability when on day 12 he still
hasn't gotten the job cleaning the room
so we come up to our important important
terminologies
we have null hypothesis
a general statement that states that
there is no relationship between two
measured phenomena or no association
among the groups
alternative hypothesis
contrary to the null hypothesis it
states whenever something is happening a
new theory is preferred instead of an
old one and so the two hypotheses go
hand in hand uh so your null this is
always interesting in in talking about
data science and the math behind it
it's about proving that the things have
no correlation
null hypothesis says these two have zero
relation to each other where the
alternative hypothesis says hey we found
a relation this is what it is
we have p-value the p-value is a
probability of finding the observed or
more extreme results when the null
hypothesis of a study question is true
and the t value it is simply the
calculated difference represented in
units of standard error the greater the
magnitude of t the greater the evidence
against the null hypothesis and you can
look at the t values being specific to
the test you're doing
where the p value is derived from your t
value and you're looking for what they
call the five percent or the 0.05
showing that it has a high correlation
so
digging in deeper let's assume that a
new drug is developed with the goal of
lowering the blood pressure more than
the existing drug
and this is a good one because the null
value here isn't that you don't have any
drug the null value here is that it's
better than the existing drug
the new drug doesn't lower the blood
pressure more than the existing drug
now if we get that
that says our null hypothesis is correct
there is no correlation and the new drug
is not doing its job the alternative
hypothesis the new drug does
significantly lower the blood pressure
more than the existing drug uh yay we
got a new drug out there and that's our
alternative hypothesis or the h1 or ha
and we look at the p-value results from
the evidence like medical trial showing
positive results which will reject the
null hypothesis
and again they're looking for
a 0.05 or 5 percent and the t value
comparing all the positive test results
and finding means of different samples
in order to test hypothesis
so this is specific to the test how what
percentage of increase did they have
and this leads us to the confidence
intervals
a confidence interval is a range of
values we are sure our true values of
observations lie in
let's say you asked a dog owner around
you and asked them how many cans of food
do you buy for your per year for your
dog
through calculations you got to know
that the on an average around 95 percent
of the people bought around 200 to 300
cans of food hence we can say that we
have a confidence interval of two 300
where 95 percent of our values lie in
that sprint data spread
and this the graph really helps a lot so
you can start seeing what you're looking
at here we have the 95 percent you have
your peak in this case it's a normal
distribution so you have a nice bell
curve equal on both sides it's not
asymmetrical and 95 of all the values
lie within a very small range and then
you have your outliers the 2.5 percent
going each way
so we touched upon hypothesis uh we're
going to move into probability so you
have your hypothesis once you've
generated your hypothesis we want to
know the probability of something
occurring probability is a measure of
the likelihood of an event to occur any
event can be predicted with total
certainty
and can only be predicted as a
likelihood of its occurrence so any
event cannot be predicted with total
certainty can only be predicted as a
likelihood of its occurrence
score prediction how good you're going
to do in whatever
sport you're in weather prediction stock
prediction
if you've studied physics and chaos
theory even the location of the chair
you're sitting on has a probability that
it might move three feet over
granted that probability is one in like
uh i think we calculated as under one in
trillions upon trillions so it's
the better the probability the more
likely it's going to happen there are
some things that have such a low
probability
that we don't see them so we talk about
a random variable a random variable is a
variable whose possible values are
numerical outcomes of a random phenomena
so uh we have the coin tossed how many
heads will occur in the series of 20
coin flips probably you know the on
average they're 10 but you really can't
know because it's very random how many
times a red ball is picked from a bag of
balls if there's equal number of red
balls and blue balls and green balls in
there how many times the sum of digits
on two dice
results are five each
so you know there's how often you're
gonna roll two fives on your paradigms
so in a use case uh let's consider the
example of rolling two dice we have a
random variable outcome equals y you can
take values two three four five six
seven eight nine ten eleven twelve
so we have a random variable and a
combination of dice
and instead of looking at how many times
both dice for roll five let's go ahead
and look at uh total sum of five and you
have in as far as your random variables
you can have a one four equals five four
one two three three two
so four of those rolls can be four if
you look at all the different options
you have four of those random rolls can
be a five
and if we look at the total number
which happens to be 36 different options
you can see that we have four out of 36
chance every time you roll the dice that
you're gonna roll a total of five you
can have an outcome of five
and uh we'll look a little deeper as to
what that means but you could think of
that at what point if someone never
rolls a five or they always roll a five
can you say hey that person's probably
cheating
we'll look a little closer at the math
behind that but let's just consider this
is one of the cases is rolling two dice
and gambling
there's also binomial distribution is
the probability of getting success or
failure as an outcome in an experiment
or trial that is repeated multiple times
and the key is is by meaning two
binomial so passing or failing an exam
winning or losing a game and getting
either head or tails so if you ever see
binomial distribution it's based on a
true false kind of setup you win or lose
let's consider a
use case and let's consider the game of
football between two clubs
barcelona and dortmund the teams will
have to play a total of four matches and
we have to find out the chances of
barcelona winning the series so we look
at the total games we're looking at five
different games or matches
let's say that the winning chance for
barcelona is 75 percent or 0.75
that means that each game they have a 75
chance that they're going to win that
game and losing chances are 25 percent
or 0.25 clearly 0.75 plus 0.25 equals 1.
so that accounts for 100 of the game
probability for getting k wins in in
matches is calculated
and we we're talking like so if you have
five games and you want to know if i
play
how many wins in those five games should
i get what's a percentage on those and
the probability for getting k wins and
in matches is calculated by p x equals k
equals nc k p to the k q to the n minus
k
here p is the probability of success and
q is the probability of failure and so
we can do total games of n equals 5
where k equals 0 one two three four five
p which is the chance of winning is
point seven five q the chance of losing
equals one minus p
which equals one minus point o seven
five which equals point two five the
probability that barcelona will lose all
of the matches can then just plug in the
numbers
and we end up with a .0009765625
so very small chance they're going to
lose all their matches
and we can plug in the value for two
matches probability that barcelona will
win at least two matches is 0.0878 and
of course we can go on to the
probability that barcelona will win
three matches the 0.26 and course four
matches and so on and it's always nice
to take this information
and let's find the accumulated discrete
probabilities for each of the outcomes
where barcelona has won three or more
matches x equals three x equals four x
equals five
and we end up with the p equals point
two six four plus point three nine five
plus two three seven which equals point
eight nine
in reality
the probability of barcelona winning the
series is much higher than 0.75
and it's always nice to
put out a nice graph so you can actually
see the number of wins to the
probability and how that pans out with
our binomial case
continuing in our important terminology
location the location of the center of
the graph depends on the mean
value and this is some very important
things so much of the data we look at
and when you start looking at
probabilities almost always has a
normalized look like the graph in the
middle
but you do have left skewed where the
data is skewed off to the left and you
have more stuff happening off to the
left and you have right skewed data
and so when this comes up and these
probabilities come up where they're
skewed it's really important to take a
closer look at that
mostly you end up with a normalized set
of data but you got to also be aware
that sometimes it's a skewed data
and then the height height of the slope
inversely depends upon the standard
deviation
so you can see down here the standard
deviation is really large it kind of
squishes it out and if the standard
deviation is small then most of your
data is going to hit right there in the
middle you can have a nice peak
and so being aware of this that you
might have a probability that fits
certain data but it has a lot of
outliers so you're if you have a really
high standard deviation
if you're doing stock market analysis
this means your predictions are probably
not going to make you much money
where if you have a very small deviation
you might be right on target and set to
become a millionaire
which leads us to the z-score z-score
tells you how far from the mean a data
point is it is measured in terms of
standard deviations from the mean around
68 percent of the results are found
between one standard deviation
around 95 percent of the results are
found between two standard deviations
and you read the symbols of course they
love to throw some greek letters in
there we have mu minus two sigma
mu is just a quick way it's a kind of
funky u it just means the mean
uh and then the sigma is the standard
deviation and that's the o with the
little arrow off to the right or the
little
wagy tail going up the o with it with
the line on it uh so mu minus two sigma
is your
uh 95 percent of the results are found
between two standard deviations
central limit theorem
this goes back to the skew if you
remember we were looking at the skew
values on this previous slide have left
skewed normalized and right skewed when
we're talking about it being skewed or
not skewed the distribution of the
sample means will be approximately
normally distributed evenly distributed
not skewed
if you take large random samples from
the population with the mean mu
and the standard deviation sigma with
replacement
and you can see here
of course we have our
mu minus two sigma and the spread down
here the mean the median and the mode
and so you're talking about very large
populations
these numbers should come together and
you shouldn't have a skewed value if you
do that's a flag that something's wrong
that's why this is so important to be
aware of what's going on with your data
where your samples are coming from
and the math behind it
and if we're going to do all this we got
to jump into conditional probability
the conditional probability of an event
a is a probability that the event will
occur given the knowledge that an event
to be has already occurred
and you'll see this as bayes theorem
b-a-y-e-s base
and this is red
i mean you have these funky looking
little
p
brackets a b
this is the probability of a being true
while b is already true
and you have the probability of b being
true when a is already true so p
b of a
probability of a being true divided by
the probability of b being true
and we talk about bayes theorem which
occurred back in the 1800s when he
discovered this this is such an
important formula and it's really it's
not if you actually do the math you
could just kind of do
x y equals j k and then you divide them
out and you're going to see the same
math but it works with probabilities
which makes it really nice
and so if you have a set you might have
uh eight or nine different studies going
on in different areas different people
have done the studies they brought them
together
if we look at today's covet virus the
virus spread
certainly the studies done in china
versus the studies the way they're done
in the us
that data is different in each of those
studies but if you can find a place
where it overlaps where they're studying
the same thing together you can then
compute the changes that you need to
make in one study to make them equal
and this is also true if you have a
study of
one group and you want to find out more
about it so this formula is very
powerful and it really has to do with
the data collection part of the math and
data science and understanding where
your data is coming from and how you're
going to combine different studies in
different groups
and we're going to go into a use case
let's find out the chance of a person
getting lung disease due to smoking
this is kind of interesting the way they
word this
let's say that according to medical
report provided by the hospital states
that around 10 percent of all patients
they treated suffered lung disease
so we have kind of a generic medical
report
they further found out
by a survey that 15 percent of the
patients that visit them smoke
so we have 10 percent that are lung
disease and
15 of the patients smoke
and finally five percent of the people
continued smoke even when they had lung
disease uh not the brightest choice um
but you know it is an addiction so it
can be really difficult to kick and so
we can look at the probability of a uh
prior probability of 10 people having
lung disease
and then probability b probability that
a patient smokes is 15 percent
uh and the probability of b
if b then a the probability of a patient
smokes even though they have lung
disease is five percent
and probability of a is b probability
that the patient will have lung disease
if they smoke and then when you put the
formulas together you get a nice
solution here you get the probability of
a of b probability that the patient will
have lung disease if they smoke
and you can just plug the numbers right
in and we get a 3.33 percent chance
hence there is a 3.33 chance that a
person who smokes will get a lung
disease
so we're going to pull up a little
python code i'm always my favorite roll
up the sleeves
keep in mind we're going to be doing
this um kind of like the back end way
so that you can see what's going on and
then later on we're going to create
we'll get into another demo which shows
you some of the tools are already
pre-built for this
let's start by creating a set so we're
going to create a set with curly braces
this means that our set has
only unique values so you have a list
you have your tuples which can never
change and then you have
in this case the the set so four seven
you can't create a four seven comma four
it'll delete the four out so it's only
unique values
and if you use dictionaries
quick reminder this should look familiar
because it is a dictionary we have a
value and that value is assigned to or
that key is assigned to a value
so you could have a key value set up as
a dictionary so it's like a dictionary
without the value it's just the keys and
they all have to be unique
and if we run this we have a
set of four seven
we can also take a list a regular
setup and i'm going to go ahead and just
throw in another number in here four
and run it uh and you can see here if i
take my list one two three four four
and i convert it to a set and here it is
my set from list equals set my list
the result is one two three four so it
just deletes that last four right out of
there
and with the sets you can also go in
there and
print here is my set my set
uh three is in the set and then if you
do three in my set
that's going to be a logic function
uh and one in my set six is not in the
set and so forth if we run this
we get three is in the set true one is
in the set false because three five
seven is another one six is in the set
six is not in the set so not in my set
you can also use this with the list we
could have just used three five seven
and it would have
the same response on there is three and
usually do if three is in but three in
my set is still works on just a regular
list
then we'll go ahead and do a little
iteration we're going to do kind of the
dice one remember
one two three four five six and so we're
going to bring in the iteration tool and
import product as product
and i'll show you what that means in
just a second so we have our two dice we
have dice a
and it's going to be a set of values
they can only have one value for each
one that's why they put it in a set and
if you remember from range it is up to
seven so this is going to be one two
three four five six it will not include
the seven and the same thing for our
dice b
and then we're gonna do is we're gonna
create a list which is the product
of a and b so what's a plus b
and if we go ahead and run this it'll
print that out and you'll see
in this case when they say product
because it's an iteration tool
we're talking about creating a tuple of
the two
so we've now created a tuple of all
possible outcomes of the dice where dice
a is one two three one to six and dice b
is one to six and you can see one to one
one to two one to three and so forth
you remember we had a slide on this
earlier where we talked about
the different all the different outcomes
of a dice
we can play around with this a little
bit we can do in dice equals two
dice faces one two three four five six
uh another way of doing what we did
before and then we can create an event
space where we have a set which is the
product of the dice faces
repeat equals indice and we'll go ahead
and just run this
and you can see here it just again puts
it through all the different possible
variables we can have
and then if we wanted to take the same
set on here and print them all out like
we had before
we can just go through for outcome and
event space outcome and equals
so the event space is creating
a sequence and as you can see here when
we print it out it stacks them versus
going through and putting them in a nice
line
and we'll go ahead and do something
let's go print
since we have the end printing with a
comma that just means it's just gonna
it's not gonna hit the return going down
to the next line
and we'll go ahead and do the length
of our event space that'll be an
important variable we're going to want
to know in a minute
and of course if i get carried away with
my typing of length uh we'll print it
twice and it'll give me an error
so we have 36 different possible
variations here
and we might want to calculate something
like
what about the multiple of three what if
we want to have
uh the probability of the multiple three
in our setup
and so we can put together the code for
the outcome and event space of x y
equals outcome
if x plus y
remainder 3 so we're going to divide by
3 and look at the remainder and it
equals 0
then it's a favorable outcome we're
going to pop that outcome on the end
there
and we'll turn it into a set so the
favor outcome equals a set
not necessary
because we know it's not going to be
repeating itself but just in case we'll
go ahead and do that
and if we want to print out the outcome
we can go ahead and see what that looks
like and you can see here these are all
multiples of three uh one plus two is
three five plus four is nine which
divided by three is three and so forth
and just like we looked up the length of
the one before let's go ahead and print
the length
of our
f outcome
so we can see what that looks like
there we go
and of course i did forget to add the
print in the middle because we're
looping through and putting an end on
the on the setup on there so we're going
to put the print in there and if i run
this you can see
we end up with 12. so we have 36 total
options
we have 12 that are multiple that add up
to a multiple of three
and we can easily conver compute the
probability of this
by simply taking the length
of our favorable outcome of the length
of the event space
if we print it out let me put that in
there
probability
last line so we just type it in we end
up with the 0.3333 chance
that's roughly a third
and we want to make this look nice so
let's go ahead and put in another line
there the probability of getting the sum
which is a multiple of 3 is
0.3333
we can compute the same thing for five
dice
and if we do this for five dice and go
and run it uh you can see we just have a
huge amount of choices
so just goes on and on down here and we
can look at
the
length of the event space
and we have over 7776
choices that's a lot of choices
and if we want to ask the question like
we did above uh
what is the sum where the sum is a
multiple of five but not a multiple of
three
we can go through all of these different
options and then
you can see here
d1 d2 d3 d4 d5 equals the outcome
and if you add these all together and
the
division by five does not have a
remainder of zero
but the remainder is also of a division
by three is not equal to zero
so the multiple of five is equal to zero
but the multiple three is not we can
just append that on here and then we can
look at that uh favorable outcome
we'll go ahead and set that and we'll
just take a look at this what's our
length
of our favorable outcome
it's always good to see what we're
working with and so we have 904 out of
70
6 and then of course we can just do a
simple division to get the probability
on here what's the probability that
we're going to roll
a multiple of 5 when you add them
together
but not a multiple of three
and so we're just going to divide those
two numbers and you can see here we get
point one one six two five five or
eleven point six two percent
and so you can really have a nice visual
that this is not really complicated math
right here on probabilities
it's just how many options do you have
and how many of those are you possibly
going to be able to come up with with
the solution you're looking for
and this leads us to a confusion matrix
a confusion matrix is a table which is
used to describe the performance of a
classification model on a set of test
data for which the true values are known
and so you'll see in the left we have
the predicted and the actual
and we have a negative uh false negative
positive true positive
and then we have false positive and true
negative and you can think of this as
your predicted model what does that mean
that means if you divided your data and
you use two-third of this to create the
model
you might then test it against an actual
case for the last third to see how well
it comes out how many times was it
true positive versus a
false positive it gave a false positive
response
and you can imagine in medical
situations this is a pretty big deal you
don't want to give a false positive so
you might adjust your model accordingly
so you don't have a false positive say
with a covavirus test it'd be better to
have a false negative and they go back
and get re-tested than to have 30 false
positives where then the test is pretty
much invalid
so in a use case like cancer prediction
let's consider an example where a cancer
prediction model is put to the test for
its accuracy and precision
actual result of a person's medical
report is compared with the prediction
made by the machine learning model
and so you can see here here's our
actual predicted whether they have
cancer or not you know cancer a big one
you don't want to have a
false positive i mean a false negative
in other words you don't want to have it
tell you that you don't have cancer when
you do so that would be something you'd
really be looking for in this particular
domain you don't want a false negative
and this is again you know you've
created a model you have hundreds of
people or thousands of pieces of data
that come in
there's a real famous case study where
they have the imagery and all the
measurements they take and there's about
36 different measurements they take
and then if you run the a basic model
you want to know just how accurate it is
how many negative results do you have
that are either telling people they have
cancer that don't or telling people that
don't have cancer that they do and then
we can take these numbers and we can
feed them into our accuracy our
precision and our recall
so accuracy precision and recall
accuracy metric to measure how
accurately the results are predicted
and this is your
total
true where you got the right results you
add them together the true positive the
true negative
over all the results so what percentage
of them were accurate versus what were
wrong
we talked about precision is a metric to
measure how many of the correctly
predicted cases are actually turned out
to be positive
uh so we have a precision on
true positive
again if you're talking about like uh
covid testing with the viruses uh you
really want this to be a high number you
want this true
that to be the center point where you
might have the opposite if you're
dealing with a cancer where you want no
false negatives
so this is your metric on here precision
is your test positive
true positive plus
false positive
and then your recall how many of the
actual positive cases we were able to
predict quickly with our model
so test positive is the test positive
plus the false negative on there and
we'll want to go ahead and do a demo on
the naive bayes classifier before i get
too far into a naive bayes classifier
because we're going to pull it from the
sk learn or the site kit
let's go ahead kind of an interesting
page here for classifiers when you go
into the sk learn kit there's a lot of
ways to do classification and i'll just
zoom up in here so you can see some of
the titles
there's everything from the nearest
neighbor linear
but we're going to be focusing on the
naive bayes over here
and this is just a sample data set that
they put together and you can see how
some of these have a very different
output
the naive bayes remember is set up as
probably the most simplified uh
calculator or set of predictions out
there
and so what we've been talking about
with the true false and stuff like that
where there's a
and then a belief that there is a
independent assumption between the
features where the features are very
assumed to have some kind of connection
uh then we can go ahead and use that for
the prediction and so that's what we're
using is a naive bayes classifier versus
many of the other classifiers that are
out there
for this we're going to use the social
network ads it's a little data set on
here
and let me go and just open that up the
file
here we go it has user id gender age
estimated salary uh purchased
and so we have you can see the user id
male 19
estimated salary 19 000
and purchased zero so it's either gonna
make a purchase or not
so look at that last one zero one we
should be thinking of binomials we
should be thinking of a simple naive
bayes classifier kind of setup
so if we close this out we're going to
go ahead and import our numpy as np
we're going to nice to have a good
visual of our data so we'll put in our
matplot library here's our pandas our
data frame
and then we're going to go ahead and
import the data set and the data set's
going to be we're going to read it from
the social network ads.csv then we're
going to print the head just so you can
see it again
even though i showed you it in the file
and x equals the data set i location
two three values and y is going to be
the four
column four let me just run this it's a
little easier to go over that
you can see right here we're going to be
looking at
0 1 2 as age
and estimated salary so 2 3
and that's what i location just means
that we're
looking at the number versus a regular
location a regular location you'd
actually say age and estimated salary
and then column four is did they make a
purchase they purchased something
so those are the three columns we're
going to be looking at when we do this
and we've gone ahead and imported these
and
imported the data so now our data set is
all set with this information in it
and we'll need to go ahead and split the
data up so we need our from the sk learn
model selection we can import train test
split
this does a nice job we can set the
random state so randomly picks the data
and we're just going to take uh 25 of
it's going to go into the test our x
test and our y test
and the 75 will go to x train and y
train
that way once we
create our model we can then have data
to see just how accurate or how well it
has performed with our prediction
the next step in pre-processing our data
is to go ahead and do feature scaling
now a lot of this is start to look
familiar if you've done a number of the
other modules and setup you should start
noticing that we
bring in our data we take a look at what
we're working with
we go ahead and split it up into
training and testing
in this case we're going to go ahead and
scale it scale it means we're putting it
between a value of minus 1 and 1
or or someplace in the middle ground
there
this way if you have any huge set you
don't have this huge um
setup if we go back up to here where
salary the salary is
20 000 versus age 35.
well there's a good chance with a lot of
the back end math that 20 000 will skew
the results and the estimated salary
will have a higher impact than the age
instead of balancing them out and
letting the calculations weigh them
properly
and finally we get to actually create
our naive bayes model
um and then we're going to go ahead and
import the gaussian naive bayes
and the gaussian is is the most basic
one that's what we're looking at now it
turns out though if you go to the sk
learn
kit
they have a number of different ones you
can pull in there there's a
bernoulli i know i've never used that
one categorical
complement and here's our gaussian
so there's a number of different options
you can look at
gaussian when you come to the naive
bayes is the most commonly used
so we're talking about the naive bayes
that's usually what people are talking
about when they when they're pulling
this in
and one of the nice things about the
gaussian if you go to their website um
to sk learn the naive bayes gaussian
there's a lot of cool features one of
them is you can do partial fit on here
that means if you have a huge amount of
data you don't have to process it all to
want you once you can batch it into the
gaussian nb model and there's many other
different things you can do with it as
far as fitting the data and how you
manipulate it
we're just doing the basics so we're
going to go ahead and create our
classifier we're going to equal the
gaussian in b
and then we're going to do a fit we're
going to fit our training data and our
training solution so x train y train
and we'll go ahead and run this uh it's
going to tell us that it ran the code
right there
and now we have our trained classifier
model
so the next step is we need to go ahead
and run a prediction we're going to do
our y predict equals the
classifier.predict
x test
so here we fit the data and now we're
going to go ahead and predict
and now we get to our confusion matrix
so from
the sk learn matrix metrics you can
import your confusion matrix
just as saves you from doing all the
simple math that does it all for you
and then we'll go ahead and create our
confusion metrics with the y test and
the y predict so we have our actual
and we have our predicted value
and you can see from here this is the
chart we looked at here's predicted so
true positive false positive
false negative true negative
and if we go ahead and run this there we
have it 65 3 7 25
and in this particular prediction we had
65 or predicted the truth as far as a
purchase they're going to make a
purchase
and we guessed three wrong
and then we had 25 we predicted would
not purchase and seven of them did so
there's our our confusion matrix
at this point if you were with your
shareholders or a board meeting
you would start to hear some snoozing if
they were looking at the numbers and you
say hey here's my confusion
matrix so let's go ahead and visualize
the results
we're going to pull from the matplot
library colors import listed color map
and this is actually my machine is going
to throw an error because this is being
because of the way the setup is i have a
newer version on here than when they put
together the demo
and we need our x set and our y set
which is our x train and y train
and then we'll create our x1 x2
and we'll put that into a grid
uh and we set our x set minimum stop and
our x at max stop
and if you come all the way over here
we're going to step .01 this is going to
give us a nice line is what that's doing
and we're going to plot the contour
plot the x limit plot the y limit
and put the scatter plot in there let's
go ahead and run this
to be honest when i'm doing these graphs
there's so many different ways to do
that there's so many different ways to
put this code together
to show you what we're doing it's a lot
easier to pull up the graph and then go
back up and explain it
so the first thing we want to note here
when we're looking at the data
is this is the training set
and so we have those who didn't make a
purchase we've drawn a nice area for
that
that's defined by the naive bayes setup
and then we have those who did make a
purchase the green and you can see that
some of the green drops fall into the
red area and some of the red dots fall
into the green
so even our training set isn't going to
be a hundred percent uh we couldn't do
that
and so we're looking at our different
data coming down
uh we can kind of arrange our x1 x2 so
we have a nice plot going on and we're
going to create the
contour
that's that nice line that's drawn down
the middle on here with the red green
that's where that's what this is doing
right here with the reshape and notice
that we had to
uh
do the dot t if you remember from numpy
um if you did the numpy module
you end up with pairs you know x x1 x2
x1 x2 next row and so forth you have to
flip it so it's all one row you have all
your x1s and all your x2s
so this is what we're kind of looking
for right here on this setup
and then the scatter plot is of course
your scattered data across there we're
just going through all the points that
puts these nice little dots on to our
setup on here and we have our estimated
salary and our h and then of course the
dots are did they make a purchase or not
and just a quick note this is kind of
funny you can see up here where it says
x set y set equals x train y train which
seems kind of a little weird to do
this is because this is probably
originally a definition
so it was its own module that could be
called over and over again
and which is really a good way to do it
because the next thing we're going to do
is do the exact same thing
but we're going to visualize the test
set results
that way we can see what happened with
our test group our 25 percent
and you can see down here we have the
test set
and it
if you look at the two
graphs next to each other this one
obviously has
75 percent of the data so it's going to
show a lot more
this is only 25 of the data you can see
that there's a number that are kind of
on the edge as to whether they could
guess by age and income they're going to
make a purchase or not
but that said it still is pretty clear
it's pretty good as far as how much the
estimate is and how good it does
now
graphs are really effective
for showing people what's going on but
you also need to have the numbers and so
we're going to do from sklearn we're
going to import metrics
and then we're going to print our
metrics classification port from the y
test and the y predict
and you can see here we have precision
precision of zeros is 90 there's our
recall
0.96 we have an f1 score and a support
and we have our precision the recall on
getting it right
and then we can do our accuracy the
macro average and the weighted average
so you can see it pulls in
pretty good as far as
how accurate it is
you could say it's going to be about 90
percent is going to guess correctly
that it that they're not going to
purchase and we had an 89 chance that
they are going to purchase
um and then the other numbers as you get
down
have a little bit different meaning but
it's pretty straightforward on here
here's our accuracy and here's our micro
average and the weighted average and
everything else you might need and if
you forgot the exact definition of
accuracy it is the
true positive true negative over all of
the different setups
precision is your true positive overall
positives true and false
and recall is a true positive over true
positive plus false negative
and we can just real quick flip back
there
so you can see those numbers on here
here's our precision here's our recall
and here's our accuracy on this
thank you for joining us for mathematics
for machine learning my name is richard
kirschner with the simply learn team
[Music]
hi there if you like this video
subscribe to the simply learn youtube
channel and click here to watch similar
videos to nerd up and get certified
click here
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.