All language subtitles for HUNT-152

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified) Download
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

‫I know you are excited because you've been looking forward to this bug hunt for the entire section on

‫linear algebra, so here we go, if you haven't already.

‫Now is the time to pause the video, go through all of this code and find and fix all of the bugs.

‫All right.

‫So I can already see that we are going to need to start by importing some modules and special functions.

‫So let's see.

‫We will need import numpty as and P, we will need import simpy as SIM and we will need to import from

‫AI Python that display the display and math functions.

‫Possibly we will need.

‫Oh we will definitely need matplotlib now I see it here.

‫So also import matplotlib dot pi plot as p l t..

‫All right.

‫I think that's probably all of the modules that we will need.

‫Let's see.

‫Create a column vector and then.

‫Oh this is a lot of complicated embedded functions here.

‫Let's just see what happens.

‫Hmm.

‫All right.

‫So first of all, this looks a little awkward to have these double square brackets here, but this is

‫also clearly not a column vector.

‫It's supposed to be a column vector.

‫Well, what's going on here is that each row in The Matrix, when you specify a matrix using numpad

‫array, each row needs to be in its own square brackets.

‫So this needs to be in a square bracket and the three needs to be in a square brackets.

‫So and those other parentheses, I think we're just there to confuse us.

‫So there we go, each row in its own square bracket and then the entire matrix is in a set of square

‫brackets that gives us a column vector.

‫All right.

‫Visualize scalar vector multiplication.

‫Let's see.

‫I'm just going to run this and we get an error.

‫Now, this one is a bit tricky, actually.

‫So we say the error message claims to be on this line.

‫And if you look at the error message itself, it says string object is not callable.

‫So what is going on here?

‫There are actually no strings in this line.

‫So this is really tricky.

‫The mistake here, the the error actually happens on this line of code and what I'm doing wrong here.

‫Well, you know, I whoever wrote this code, the terrible programmer who wrote this code, what they're

‫trying to do is set the access to be square.

‫But in fact, what they've done is set the axis as a variable to be string.

‫So what we need to do is put this in parentheses like this, except now we still actually get this error.

‫And basically what's happened here is we've just done some real fundamental damage to access by setting

‫it equal to the string is square.

‫And, you know, sometimes when you really get your python code all caught up in a bundle, it's good

‫just to restart everything.

‫So I'm going to select Col up here and restart it.

‫It says, Are you sure you want to restart?

‫All the variables will be lost.

‫Now, sometimes that's problematic, but it's no problem here.

‫All we need to do is rerun this cell here to re-import all of these modules.

‫OK, and then I'm going to go back and rerun this.

‫So now the plotting part looks good, but the legend doesn't quite look right.

‫So I don't know what this percent is doing here.

‫This is actually just Vector V here in Red and S.V..

‫So I think we don't even need that percent sign.

‫OK, now let's look at what's happening here just to make sure that we're doing the right thing.

‫So we have this vector here, minus two to that is minus two comma to not minus a two.

‫And the scalar here is zero point seven.

‫Now if the vector is minus two plus two, which is this line here and a scalar is zero point seven,

‫then actually this blue line should probably come up to around here.

‫It shouldn't be the dot.

‫I think something is fundamentally wrong here.

‫Let's also check out what this variable S.V. actually is.

‫So if we print out S.V., then it's just a zero.

‫This is actually not this vector times point seven.

‫And so what's going on here?

‫I have no idea what's going on here, actually, but it looks like we are computing the DOT product

‫between Eskom.

‫S, so a vector that is point seven point seven and minus two plus two.

‫Now it actually makes sense where this result comes from.

‫Essentially what we are doing here is saying point seven times minus two plus point seven times plus

‫two and that equals zero.

‫So this is totally, totally wrong.

‫This actually is just supposed to be S times V like this.

‫And now when we print this out, we see we get what we expect.

‫So point seven times two is one point four and then we just get a scaled version of this vector.

‫Of course, now we've gotten some other errors and the errors on this line.

‫And you can actually see that this is you know, we need the first component here and the second component

‫here.

‫That should be one for the second component.

‫All right.

‫Now, this looks good.

‫I'm going to say that is the successful completion of this particular problem here.

‫All right.

‫So here we go, algorithm to compute the DOT product so we have some random vectors and then we do the

‫DOT product by setting the DOT product to be this variable, to be zero and adding to itself the corresponding

‫element in V times W and then we compare that to the function num num, pi, dot.

‫All right.

‫So we already get an error and this is related to shape.

‫So I hope that you already caught that one so you could change this to seven or you could have changed

‫that to eight.

‫Either way, it would be fine.

‫Hmm.

‫Now, these two answers are actually not equal to each other and what is going on here?

‫Well, if we look at this line of code carefully, it looks like this was a typo.

‫This probably should say I.

‫Otherwise, it was fixed to be the first or the second element in Vector W.

‫Let's see.

‫And now we get the same answer for both of these mechanisms.

‫And now I'd like to show you a little bit of a shortcut in Python for getting this to work.

‫So if you want to set a variable to be equal to itself plus something else, you can write out the line

‫of code like this totally fine.

‫I think this looks very clear.

‫However, it's possible to write it out in even more condensed language, and that's by saying plus

‫equals instead of just equals.

‫So Python will interpret this expression here as saying that the DOT product equals itself, plus whatever

‫is on the right hand side of this equation.

‫And you can see that here.

‫Now I'm running this again and you get the same answer for NPR dot and our algorithm here.

‫Now, obviously, these answers will change every time I run it because these are random numbers.

‫Very nice.

‫Let's see.

‫This doesn't exactly tell us what we're supposed to be doing here, but I can look down.

‫So here we are creating some data as a range of numbers that goes from zero to nine.

‫And then we add some normally distributed random numbers.

‫And here we are computing the correlation and confirm with the number by correlation coefficient.

‫OK, so I expect these two variables to be identical to each other.

‫And they're kind of close, I guess, but certainly not identical.

‫Let's see what's going wrong.

‫So remember from the video that I showed about computing, the correlation coefficient, that was an

‫application of the DOT product in statistics that the numerator of the correlation coefficient is the

‫DOT product between the two vectors and the denominator is the square root of the dot product of the

‫vector with itself times the square root of the dot product of the other vector with itself.

‫And then we do this division.

‫And so actually all of this is correct.

‫However, we are missing one thing.

‫What does that one thing that we're missing, the one thing that we're missing is that these data vectors,

‫these data streams need to be mean centered, so means center.

‫And that just means subtracting the mean from the data set.

‫So data one equals data one minus number, I mean of data one.

‫And now if you are already thinking that this can be simplified, then good for you.

‫We're going to do that like this.

‫And now that's for data one, and then we repeat this for data, too, and now we get exactly the same

‫correlation coefficient for both of these operations.

‫And actually, it's interesting to see that once you get down to about 10 or 12 or whatever, this is

‫degrees of precision, then eventually these algorithms do start to diverge a tiny bit.

‫And that's because kuriko of this function is actually implementing a slightly different and more efficient

‫and faster algorithm than what I'm showing here.

‫All right, here we go.

‫We are trying to compute the outer product, and this looks, again, like one of these approaches where

‫we compare the numpties function outr.

‫So the built in function outr to computing this manually, using the algorithm for computing the outer

‫product.

‫So remember that one way to compute the outer product is to set each row of the outer product matrix

‫to be the row of the right matrix.

‫So are the right vector, which is going to be this one times each element of the left vector, which

‫here looks like one.

‫So that already tells me that there's something going wrong here.

‫So let's let's just try to run this.

‫And this says could not broadcast input.

‫Right.

‫OK, so based on what I just described as the algorithm for computing the outer product matrix, I can

‫already determine that this is incorrect.

‫This should be the entire row vector on the right and each element of the column vector on the left

‫like this.

‫Hmm.

‫So now we don't get any explicit python errors.

‫But when I say the outer so this outer product matrix here, minus num outer, we get zeros for the

‫first four rows and then non zeros for these last four rows.

‫So there's clearly something strange happening here.

‫Let's try it again.

‫Hmm.

‫Again, the same thing.

‫So now we get all zeros for the first four rows and a couple of zeros here as well.

‫But it seems like the first four rows of zeros is pretty consistent.

‫I wonder what would happen if I would change the sizes of these matrices.

‫So let's say what if this is like six elements and this is eight elements?

‫Oh, now we actually do get an error message and it says index six is out of bounds for axis zero with

‫size six.

‫OK, what's actually happening is in this line here for the range.

‫Now, notice that we are what we are actually looping through is elements in one.

‫But what we are looping through here, what we are specifying is the range of the elements is actually

‫coming from the size of O2.

‫So I'm just going to replace the two with one.

‫And now we get a matrix of all zeros.

‫But this is a really tricky point because, you know, when it was this way, so how it was initially,

‫we didn't get any python coding errors because technically we haven't done anything wrong in terms of

‫programming.

‫We've done something wrong in terms of of math and indexing, but we haven't done anything illegal in

‫terms of python coding.

‫But the result is wrong.

‫And if you weren't actually comparing this, then, yeah, you probably wouldn't even notice.

‫You might not even notice that this error was in there.

‫So these are the most devious kinds of coding mistakes.

‫Anyway, let's move on.

‫OK, matrix multiplication.

‫So we have a random five by five matrix.

‫Multiply it by the five by five identity matrix.

‫And what we should see is a full matrix of random numbers, which we don't see.

‫In fact, we see a matrix that's mostly zeros.

‫So what's happening here is that the asterisk is implementing Element Y's multiplication, but we need

‫full on matrix multiplication.

‫So there you go.

‫All right, let's go on to the next cell.

‫It looks like this is a similar kind of problem.

‫So I can already see that this is a little bit weird here, multiplying a by the identity matrix.

‫So here we see the original Matrix A. Here we are doing Element Y's multiplication and this says there's

‫actually a size problem.

‫So for Element Y's multiplication, it's not possible with these two matrices because they are different

‫sizes.

‫They have a different number of elements.

‫So let's see what would happen if we would replace this with matrix multiplication.

‫And there you go.

‫We get that a on the top is the same thing as a matrix multiplying by the identity matrix on the bottom

‫here.

‫So you can see that this matrix is the same as this matrix.

‫All right here.

‫This one says Random matrices are convertible.

‫So what we do is create a matrix of random integers between minus five and plus five.

‫It's five by five and it's random.

‫So it should be convertible.

‫So I don't really see what the issue is here.

‫We should get the identity matrix because the Matrix times its inverse is the identity matrix.

‫Let's see what's going on.

‫Hmm, module number II has no attribute in the problem here is that it is not in the main PI module,

‫it's actually in the Lynn alg module or the sub module.

‫OK, so now we've multiplied a by its inverse and we get the identity matrix.

‫Let's see, so here we are plotting the Igen spectrum, so we create a matrix, multiply that matrix

‫by its own transpose, remember, that gives us a square symmetric matrix.

‫This matrix is already square, but it does give us a symmetric matrix.

‫And let's just see what's going on here.

‫So we don't get any python errors.

‫So that part seems OK.

‫But let's look at these eigenvalues.

‫You know, there's like 25 of these eigenvalues, but this is just a five by five matrix and we can

‫even confirm this.

‫So I'm going to print out num pi, the shape of M, and this is a five by five matrix.

‫So there's really only supposed to be five eigenvalues.

‫Let's see what's going on.

‫I'm going to look at the help file or the dock string for IG and let's see if this gives us some insight.

‫So this returns W is the eigenvalues and then V the second output is the Igen vectors.

‫So in fact the order of the output is wrong here.

‫This is just swopped.

‫This should be the eigenvalues and this should be the eigenvectors.

‫And now we only get five components, five things being plotted here, which is consistent.

‫That is exactly how many we expect for the eigenvalues.

‫By the way, I haven't yet introduced you to this function.

‫Flatten num pi matrix, dot flatten.

‫But essentially what that's doing is taking this matrix or whatever is the input matrix and expanding

‫it out from a matrix into one really long array, a really long vector.

‫And so for a the eigenvectors matrix, which is a five by five matrix, when you flatten it you get

‫25 total elements and that's why you get a line of twenty five here.

‫So these are just all the individual components of all the, each of the five eigenvectors.

‫OK, so set that back so that looks better.

‫By the way, you can also see here that the eigenvalues are not intrinsically sorted by magnitude,

‫so they don't come out as the largest eigenvalues first, that has to do with the estimation algorithm

‫that Python uses to compute the eigenvalues.

‫Anyway, let's move on.

‫This looks like the last exercise to work on for this bug hunt.

‫So it looks like we are creating a matrix of random integers.

‫It's a 10 by 20 matrix.

‫So actually we cannot perform an eigenvalue decomposition on this matrix.

‫But of course, we can do an SVOD.

‫So we do the DVD.

‫We create a full matrix based on a diagonal matrix based on these singular values.

‫And then we try to reconstruct that matrix and make some plots.

‫All right.

‫And we already get an error and it's related to size.

‫And this is, in fact, something that I discussed in the previous video on the singular value decomposition.

‫So what we need to do is first reconstruct as to be a Xeros matrix corresponding to the size or the

‫shape of the Matrix A and then we need to loop over the elements in S so range of length s and then

‫we say s the ith diagonal element equals the corresponding element in the little S.

‫So in vector s.

‫OK, so now let's see how this looks.

‫Oh we still get an error.

‫It's another mismatched dimension.

‫Hey.

‫But you know, looking at the order, this is not the correct order, it should be U times Sigma Times

‫V so I'm going to rewrite this like this you time Sigma Times V actually this is V transpose python

‫will automatically spit out V transpose.

‫OK, so this is looking good.

‫Here we see the Matrix A, the reconstructed matrix A and the difference between the two, which is

‫an empty plot.

‫It's all zeros.

‫And that's comforting because that means that we have reconstructed this matrix accurately.

‫I hope you enjoyed this bug hunt and more generally, I hope you enjoyed learning a little bit about

‫linear algebra from this section of the course.

‫As I mentioned in the beginning of this section, linear algebra is a beautiful, rich and really important

‫topic in mathematics.

‫I hope you feel like you got a little bit of a taste, a little bit of enthusiasm about learning linear

‫algebra from this section.

‫And maybe you are inspired to continue learning about linear algebra in more depth.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.