You now know a bunch about machine learning.

In this video, I'd like to teach you a programming language, Octave, in which

you'll be able to very quickly implement 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 live variety of

different programming languages including C+++, Java

Python NumPy, R and also Octave. And what I've found is that students were

able to learn the most productively learn the most quickly and prototype the

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 in

the language like Octave, which is a great prototyping language.

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

And then, only if you need a very large scale deployment of it,

only then spend your time reimplementing the algorithms in C+++ or Java, or some

other language like that. Because one of the lessons we've learned

is that program a time or developer time, that is your time,

you know, the machine learning experience time is incredibly valuable.

And if you can get your learning happens to work more quickly in Octave, then

overall, you have a huge time savings by first developing the algorithms in

Octave, and then implementing in like maybe C++ or Java only after we have the

ideas working. The most common prototyping languages I

see people use for machine learning are Octave,

Matlab, Python NumPy, and R. Octave is nice since it's free open

source and Matlab works well, too, but is expensive to many people.

But if you have access to a copy of Matlab, you can also use Matlab for 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 in, you know, mul, these languages because

the Python NumPy syntax is just slightly concur than the Octave syntax. and so

because of that and because we're releasing starter code in Octave I

strongly recommend that you not try to do the programming exercises in this class

and NumPy R, but that I do recommend that you instead do the programming exercises

for this class in Octave instead. What we're going to do in this video is

go through a list of commands fairly quickly, and the goal is to 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, to the transcript posted on

the course website when you want to find a command.

Briefly, what I recommend you do is first watch the tutorial videos.

And after watching, you know, to the end, then install Octave

on your computer. And finally, go to the course website,

download the transcript of the things you see in this session and type in whatever

commands seem interesting to you in to the octaves of running on your own

computer so that you can see it work for yourself.

And with that, let's get started. Here's my Windows desktop, and I'm going

to start an Octave. And I'm now in octave and, and there's my

octave prompt. Let me first show you the elementary

operations you can do in octave. So you can type in 56, + 6, that gives

you the answer of 11. 3 - 2,

5 * 8, 1/2, 2^6 is 64. So, those are the elementary math

operations. You can also do logical operations. So, 1

= 2 this evaluates to false. The percent command here is means a

comment. So, 1 = 2 evaluates to false which is represented by zero.

One not equals to two, this is true so that returns one, note that the not equal

sign is tilde equals symbol and not than equals which is what some other program

languages use. Let's see logical operations one and

zero, use a double ampersand sign to denote the logical and,

and that evaluates the false one over zero.

z 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 is octave 3.2.4.exe:11. This is the default octave

prompt. So it shows the what?

a version in Octave, and so on. if you don't want that problem, there's a

somewhat cryptic command, PS, quote, greater than, greater than, and so on,

that you can use to change the prompt. And I guess this quote of 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 is 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 three, and hit Enter. And now, a is equal to three.

If you want to assign a variable but you don't want it to print out the result, if

you put a semicolon, the semicolon suppresses the print the, the print

output. So, if we do that, Enter, it doesn't print anything.

Whereas a equals three, you know, makes it prints it out, whereas a equals three

semicolon doesn't print anything. I can do string assignments, b equals hi.

now, if I just enter b, it prints out the variable b,

so b is the string hi. c3, equals three greater than or equal to

one. So now, c evaluates to true.

If you want to print out or display a variable, here's how you go about it.

Let me set api. equals pi.

And if I want to print a, I can just type a like so, and it'll print it out.

For more complex printing, there's also the disp command which sense the

displays, when display a, just prints out a like so.

You can also display strings, so disp print f, two decimals.

The percent of 0.2f, a like so. And this print out the string, 2

decimals: 3.14. This is kind of a old, old style C syntax

for those of you that have coded in C before, this is essentially the syntax

you used to print strings. So the, sprint f generator generates a,

generates a string that is this, you know, two decimals 3.14 one for string.

This percent 0.2f means substitute a into here, sharing it with, you know, two

digits after the decimal point. And the disp takes this string that's generated

by this print f command, s print f or the string print f command, and disp actually

displays the string. And to show you another example,

sprint f six decimals percent 0.6f, a and this should print pi with six decimal to,

to six decimal places. Finally, I was explaining a like so, a

lot like this. There, there are useful short cuts that

you type format long. It causes strings to by default to be

assuage to a lot more decimal places to and format short is a command that

resources 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 a to a

matrix, let me show you an example. 12; 34; 56, this generates a three by two

matrix a whose first row is one two, second row is three, four, the third row

is five, six. What the semicolon does is essentially

say, go to the next row of the matrix. There are other ways to type this, a=12;1

34;. 56 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 = 1,2,3. this is actually a row vector,

or this is a three by one vector, right?

This is a fat y vector, as a, excuse me, not, this is

a one by three matrix, right?