0:00

You now know a bunch about machine learning.

Â In this video, I like to

Â teach you a programing language,

Â Octave, in which you'll be

Â able to very quickly implement

Â the the learning algorithms we've

Â seen already, and the learning

Â algorithms we'll see later in this course.

Â In the past, I've tried to teach machine learning

Â using a large variety of different programming languages

Â including C++ Java,

Â 0:22

Python, NumPy, and also

Â Octave, and what I

Â found was that students were able

Â to learn the most

Â productively learn the most quickly

Â and prototype your algorithms most

Â quickly using a relatively

Â high level language like octave.

Â In fact, what I often

Â see in Silicon Valley is

Â that if even if you need to build.

Â If you want to build a large

Â scale deployment of a learning

Â algorithm, what people will often do

Â is prototype and the language is Octave.

Â Which is a great prototyping language.

Â So you can sort of get your learning algorithms working quickly.

Â And then only if you need

Â to a very large scale deployment of it.

Â Only then spend your time

Â re-implementing the algorithm

Â to C++ Java or some of the language like that.

Â Because all the lessons we've learned is

Â that a time or develop a time.

Â That is your time.

Â The machine learning's time is incredibly valuable.

Â And if you can

Â get your learning algorithms to work more quickly in Octave.

Â Then overall you have a

Â huge time savings by first

Â developing the algorithms in

Â Octave, and then implementing and

Â maybe C++ Java, only after we have the ideas working.

Â The most common prototyping language I

Â see people use for machine

Â learning are: Octave, MATLAB,

Â Python, NumPy, and R.

Â 1:38

Octave is nice because open sourced.

Â And MATLAB works well

Â too, but it is expensive for

Â to many people.

Â But if you have access to a copy of MATLAB.

Â You can also use MATLAB with this class.

Â If you know Python, NumPy,

Â or if you know R. I do see some people use it.

Â But, what I see is

Â that people usually end up

Â developing somewhat more slowly, and

Â you know, these languages.

Â Because the Python, NumPy syntax

Â is just slightly clunkier than the Octave syntax.

Â And so because of that, and

Â because we are releasing starter

Â code in Octave.

Â I strongly recommend that you

Â not try to do the following exercises in this class in NumPy and R.

Â But that I do recommend that

Â you instead do the programming exercises

Â for this class in octave instead.

Â What I'm going to do in

Â this video is go through

Â a list of commands very,

Â very quickly, and its goal

Â is to quickly show you the

Â range of commands and the range of things you can do in Octave.

Â The course website will have

Â a transcript of everything I

Â do, and so after

Â watching this video you

Â can refer to the transcript

Â posted on the course website

Â when you want find a command.

Â Concretely, what I recommend

Â you do is first watch the tutorial videos.

Â And after watching to the

Â end, then install Octave on your computer.

Â And finally, it goes to

Â the course website, download the transcripts

Â of the things you see in the

Â session, and type in

Â whatever commands seem interesting

Â to you into Octave, so that it's

Â running on your own computer, so

Â you can see it run for yourself.

Â And with that let's get started.

Â Here's my Windows desktop, and I'm going to start up Octave.

Â And I'm now in Octave.

Â And that's my Octave prompt.

Â Let me first show the elementary

Â operations you can do in Octave.

Â So you type in 5 + 6.

Â That gives you the answer of 11.

Â 3 - 2.

Â 5 x 8, 1/2, 2^6

Â 3:35

is 64.

Â So those are the elementary math operations.

Â You can also do logical operations.

Â So one equals two.

Â This evaluates to false.

Â The percent command here means a comment.

Â So, one equals two, evaluates to false.

Â Which is represents by zero.

Â One not equals to two.

Â This is true.

Â So that returns one.

Â Note that a not equal sign

Â is this tilde equals symbol.

Â And not bang equals.

Â Which is what some other

Â programming languages use.

Â Lets see logical operations one and zero

Â use a double ampersand sign to

Â the logical AND.

Â 4:18

And that evaluates false.

Â One or zero is the OR operation.

Â And that evaluates to true.

Â And I can XOR one and

Â zero, and that evaluates to one.

Â This thing over on the left, this Octave 324.x

Â equals 11, this is the default Octave prompt.

Â It shows the, what, the

Â version in Octave and so on.

Â If you don't want that prompt,

Â there's a somewhat cryptic command PF

Â quote, greater than, greater

Â than and so on,

Â that you can use to change the prompt.

Â And I guess this quote a string in the middle.

Â Your quote, greater than, greater than, space.

Â That's what I prefer my Octave prompt to look like.

Â So if I hit enter.

Â Oops, excuse me.

Â Like so.

Â PS1 like so.

Â Now my Octave prompt has changed to the greater than, greater than sign.Which,

Â you know, looks quite a bit better.

Â Next let's talk about Octave variables.

Â I can take the variable

Â A and assign it to 3.

Â And hit enter.

Â And now A is equal to 3.

Â You want to assign a variable, but you don't want to print out the result.

Â If you put a semicolon, the semicolon

Â suppresses the print output.

Â So to do that, enter, it doesn't print anything.

Â Whereas A equals 3.

Â mix it, print it out,

Â where A equals, 3 semicolon doesn't print anything.

Â I can do string assignment.

Â B equals hi

Â Now if I just

Â enter B it prints out the

Â variable B. So B is the string hi

Â C equals 3 greater than colon 1.

Â So, now C evaluates the true.

Â 5:55

If you want to print

Â out or display a variable, here's how you go about it.

Â Let me set A equals Pi.

Â And if I want to print

Â A I can just type A like so, and it will print it out.

Â For more complex printing there is

Â also the DISP command which stands for Display.

Â Display A just prints out A like so.

Â You can also display strings

Â so: DISP, sprintf, two

Â decimals, percent 0.2,

Â F, comma, A. Like so.

Â And this will print out the string.

Â Two decimals, colon, 3.14.

Â This is kind of

Â an old style C syntax.

Â For those of you that

Â have programmed C before, this is

Â essentially the syntax you use to print screen.

Â So the Sprintf generates a

Â string that is less

Â than the 2 decimals, 3.1 plus string.

Â This percent 0.2 F means

Â substitute A into here,

Â showing the two digits after the decimal points.

Â And DISP takes the string

Â DISP generates it by the Sprintf command.

Â Sprintf.

Â The Sprintf command.

Â And DISP actually displays the string.

Â And to show you another

Â example, Sprintf six decimals

Â percent 0.6 F comma A.

Â And, this should print Pi

Â with six decimal places.

Â 7:22

Finally, I was saying, a like so, looks like this. There

Â are useful shortcuts that type type formats long.

Â It causes strings by default.

Â Be displayed to a lot more decimal places.

Â And format short is a

Â command that restores the default

Â of just printing a small number of digits.

Â Okay, that's how you work with variables.

Â Now let's look at vectors and matrices.

Â Let's say I want to assign MAT A to the matrix.

Â Let me show you an example: 1, 2,

Â semicolon, 3, 4, semicolon, 5, 6.

Â This generates a three by

Â two matrix A whose first

Â row is 1, 2. Second row

Â 3, 4. Third row is 5, 6.

Â What the semicolon does is

Â essentially say, go to

Â the next row of the matrix.

Â There are other ways to type this in.

Â Type A 1, 2 semicolon

Â 3, 4, semicolon, 5, 6, like so.

Â And that's another equivalent way of

Â assigning A to be

Â the values of this three by two matrix.

Â Similarly you can assign vectors.

Â So V equals 1, 2, 3.

Â This is actually a row vector.

Â Or this is a 3 by 1 vector.

Â Where that is a fat Y vector,

Â excuse me, not, this is

Â a 1 by 3 matrix, right.

Â Not 3 by 1.

Â If I want to assign

Â this to a column vector,

Â what I would do instead is do v 1;2;3.

Â And this will give me a 3 by 1.

Â There's a 1 by 3 vector.

Â So this will be a column vector.

Â Here's some more useful notation.

Â V equals 1: 0.1: 2.

Â What this does is

Â it sets V to the bunch

Â of elements that start from 1.

Â And increments and steps

Â of 0.1 until you get up to 2.

Â So if I do this, V is going to be this, you know, row vector.

Â This is what one by eleven matrix really.

Â That's 1, 1.1, 1.2, 1.3 and

Â so on until we

Â 9:31

Now, and I can also

Â set V equals one colon six,

Â and that sets V to be these numbers.

Â 1 through 6, okay.

Â Now here are some other ways to generate matrices.

Â Ones 2.3 is a command

Â that generates a matrix that

Â is a two by three matrix

Â that is the matrix of all ones.

Â So if I set that c2

Â times ones two by

Â three this generates a

Â two by three matrix that is all two's.

Â You can think of this as a

Â shorter way of writing this and

Â c2,2,2's and you can

Â call them 2,2,2, which would also give you the same result.

Â Let's say W equals one's, one

Â by three, so this is

Â going to be a row vector

Â or a row of

Â three one's and similarly

Â you can also say w equals

Â zeroes, one by

Â three, and this generates a matrix.

Â A one by three matrix of all zeros.

Â Just a couple more ways to generate matrices .

Â If I do W equals

Â Rand one by three,

Â this gives me a one

Â by three matrix of all random numbers.

Â If I do Rand

Â three by three.

Â This gives me a three by

Â three matrix of all

Â random numbers drawn from the

Â uniform distribution between zero and one.

Â So every time I do

Â this, I get a different

Â set of random numbers drawn

Â uniformly between zero and one.

Â For those of you that

Â know what a Gaussian random variable

Â is or for those of you that

Â know what a normal random variable

Â is, you can also set W

Â equals Rand N, one by three.

Â And so these are going

Â to be three values drawn from

Â a Gaussian distribution with mean

Â zero and variance or

Â standard deviation equal to one.

Â And you can set more complex

Â things like W equals minus

Â six, plus the square root

Â ten, times, lets say

Â Rand N, one by ten thousand.

Â And I'm going to put a semicolon at

Â the end because I don't really want this printed out.

Â This is going to be a what?

Â Well, it's going to

Â be a vector of, with

Â a hundred thousand, excuse me, ten thousand elements.

Â So, well, actually, you know what?

Â Let's print it out.

Â So this will generate a matrix like this.

Â Right?

Â With 10,000 elements.

Â So that's what W is.

Â And if I now

Â plot a histogram of W

Â with a hist command, I can

Â now. And Octave's print hist

Â command, you know, takes a

Â couple seconds to bring this up,

Â but this is a histogram of

Â my random variable for W.

Â There was minus 6 plus zero

Â ten times this Gaussian random variable.

Â And I can plot a histogram with

Â more buckets, with more bins, with say, 50 bins.

Â And this is my

Â histogram of a Gaussian with mean minus 6.

Â Because I have a minus

Â 6 there plus square root 10 times this.

Â So the variance of

Â this Gaussian random variable

Â is 10 on the standard deviation is

Â square root of 10, which is about what?

Â Three point one.

Â 12:41

Finally, one special command

Â for generator matrix, which is the I command.

Â So I stands for this

Â is maybe a pun on the word identity.

Â It's server set eye 4.

Â This is the 4 by 4 identity matrix.

Â So I equals eye 4.

Â This gives me a 4 by 4 identity matrix.

Â And I equals eye 5, eye 6.

Â That gives me a 6 by

Â 6 identity matrix, i3

Â is the 3 by 3 identity matrix.

Â Lastly, to

Â wrap up this video, there's one more useful command.

Â Which is the help command.

Â So you can type help i and

Â this brings up the help function for the identity matrix.

Â Hit Q to quit.

Â And you can also type help rand.

Â Brings up documentation for the rand or the

Â random number generation function.

Â Or even help help, which

Â shows you, you know help on the help function.

Â 13:36

So, those are the

Â basic operations in Octave.

Â And with this you should be

Â able to generate a few matrices, multiply, add things.

Â And use the basic operations in Octave.

Â In the next video, I'd like

Â to start talking about more

Â sophisticated commands and how

Â to use data around and start to process data in Octave.

Â