1
00:00:00,000 --> 00:00:04,331
You now know a bunch about machine
learning. In this video, I'd like to teach

2
00:00:04,331 --> 00:00:08,662
you a programming language, Octave, in
which you will be able to very quickly,

3
00:00:08,662 --> 00:00:13,278
implement the learning algorithms we've
seen already and the learning algorithms

4
00:00:13,278 --> 00:00:17,837
we'll see later in this course. In the
past I've tried to teach machine learning

5
00:00:17,837 --> 00:00:22,169
using a, a large variety of different
programming languages, including C plus,

6
00:00:22,169 --> 00:00:27,826
plus, Java, Python and Pi are. And also
octave and what I've found is that

7
00:00:27,826 --> 00:00:33,062
students were able to learn the most
productively learn the most quickly and

8
00:00:33,062 --> 00:00:38,560
prototype your albums most quickly using a
relatively high level language by octave

9
00:00:38,560 --> 00:00:43,605
in fact What I often see in silicon valley
is even if you need to build if you want

10
00:00:43,605 --> 00:00:48,040
to build a large scale deployment of a
learning algorithm what people will often

11
00:00:48,040 --> 00:00:52,036
do is prototype in the language they
Octave which is a great prototyping

12
00:00:52,036 --> 00:00:56,307
language so you can get your learning
albums working quickly and then only if

13
00:00:56,307 --> 00:01:00,194
you need a very large scale deployment of
it only then spend your time

14
00:01:00,194 --> 00:01:04,793
reimplementing the algorithms [inaudible]
some other language like that because one

15
00:01:04,793 --> 00:01:09,118
of the lessons we've learned is that
programmer time or developer time that is

16
00:01:09,118 --> 00:01:13,280
your time with the machine learning
[inaudible] time is incredibly valuable.

17
00:01:13,280 --> 00:01:18,274
And if you can get your learning
algorithms to work more quickly in octave

18
00:01:18,274 --> 00:01:23,206
then overall you have a huge time savings
by first developing the algorithms in

19
00:01:23,206 --> 00:01:28,262
octave and then implementing [inaudible]
only after we have the ideas working. The

20
00:01:28,262 --> 00:01:32,948
most common prototyping languages I see
people use for machine learning are

21
00:01:32,948 --> 00:01:42,073
Octave. Mattlab-numpinr. Octave is nice
this is free open source and Mat-Lab works

22
00:01:42,073 --> 00:01:47,656
well too but is expensive to many people
but if you have access to copy Mat-Lab you

23
00:01:47,656 --> 00:01:53,371
can also use mat lab for this class if you
know [inaudible] or if you know R I do see

24
00:01:53,371 --> 00:01:59,153
some people use it but what I see is that
people usually end up developing somewhat

25
00:01:59,153 --> 00:02:04,029
more slowly in. You know more complete
languages [inaudible] syntax it's just

26
00:02:04,029 --> 00:02:09,535
slightly [inaudible] clear than the octave
syntax and so because of that and because

27
00:02:09,535 --> 00:02:14,728
we're releasing starter code in Octave I
strongly recommend that you not try to do

28
00:02:14,728 --> 00:02:20,108
the pony exercises in this class in Empire
R but that I do recommend that you instead

29
00:02:20,108 --> 00:02:25,359
do the pony exercises for this class in
octave instead. Welcome to do this video

30
00:02:25,359 --> 00:02:31,006
is go through a list of commands very,
very quickly and goes will quickly show

31
00:02:31,006 --> 00:02:36,942
you the range of commands and the range of
things you can do in office. The course

32
00:02:36,942 --> 00:02:42,516
web site we have a transcripts of
everything I do and so after watching this

33
00:02:42,516 --> 00:02:48,379
video you can refer to transcript person
in the course web site when you want to

34
00:02:48,379 --> 00:02:54,098
find a command. Our feel free whatever
recommend you do is fresh wash and after

35
00:02:54,098 --> 00:02:58,765
watching Now DDN then is [inaudible]
octave on your computer and finally it

36
00:02:58,765 --> 00:03:03,679
goes to the course website download the
transcripts of the things you see in this

37
00:03:03,679 --> 00:03:08,354
section and type in whatever commands seem
interesting to you into octaves

38
00:03:08,354 --> 00:03:13,446
[inaudible] on your own computer so that
you can see it for yourself. And, with

39
00:03:13,446 --> 00:03:19,421
that let's get started. Here's my Windows
desktop, and I'm start in Octave. And I'm

40
00:03:19,421 --> 00:03:23,849
now in Octave and, and there's my Octave
prompt. Let me first show you the

41
00:03:23,849 --> 00:03:28,458
elementary operations you can do in
Octave. So, you can type in five plus six,

42
00:03:28,458 --> 00:03:34,720
that gives you the answer of eleven. Z
minus two. Five times eight. One over two.

43
00:03:34,720 --> 00:03:41,045
Two to the power of six. Is 64. So that
the [inaudible], elementary, math

44
00:03:41,045 --> 00:03:46,426
operations. You can also do logical
operations. So one=2 of this evaluation

45
00:03:46,426 --> 00:03:52,703
that follows. The percent command here is,
means a comment. So one=2, evaluates the

46
00:03:52,703 --> 00:03:58,905
[inaudible], which is represented by zero.
One [inaudible]= to two. This is true, so

47
00:03:58,905 --> 00:04:04,866
that returns one. You know that a not
equal sign is this. To their equals symbol

48
00:04:05,098 --> 00:04:11,973
and not bang equals which some of the
[inaudible] languages use. The theological

49
00:04:11,973 --> 00:04:18,230
operations one and zero use a double
ampersand sign to denote the logical and.

50
00:04:18,230 --> 00:04:24,021
That evaluates the false, one or zero, z
or operation. And that evaluates the true.

51
00:04:24,021 --> 00:04:29,813
And I can x over one and zero, and that
evaluates the one. This thing over on the

52
00:04:29,813 --> 00:04:35,388
left, this Octive 324 [inaudible] eleven,
this is the default Octive prompt. It

53
00:04:35,388 --> 00:04:40,962
shows what version of Octive and so on. If
you don't want that prompt, this is

54
00:04:40,962 --> 00:04:46,485
somewhat cryptic to come on. Quote
particular then and so on that you can use

55
00:04:46,485 --> 00:04:52,121
to change the prop and I guess this quoted
string in the middle you know quote

56
00:04:52,121 --> 00:04:57,686
greater than greater than state, that's
what I prefer my octave prompt to look

57
00:04:57,686 --> 00:05:03,179
like, so if I hit enter, oh excuse me,
like so, PS1 like so now my octave prompt

58
00:05:03,179 --> 00:05:09,100
has changed to the greater than greater
than sign which you know looks quite a bit

59
00:05:09,100 --> 00:05:15,295
better. Next lets talk about octave
variables. I can take the variable A and

60
00:05:15,295 --> 00:05:21,181
assign it to three and hit enter. And now
A is equal to three. You want to sign a

61
00:05:21,181 --> 00:05:26,008
variable but you don't want to print out
the result if you put a semicolon. The

62
00:05:26,008 --> 00:05:32,546
semicolon. Suppresses, the, print, the,
the print output. So to do that enter, it

63
00:05:32,546 --> 00:05:38,639
doesn't print anything. Whereas A=3, you
know, makes it printed out. Whereas A=3;

64
00:05:38,639 --> 00:05:44,798
doesn't print anything. I can do string
assignment, B=high. If I just enter b, it

65
00:05:44,798 --> 00:05:51,726
prints out the variable b. So b is the
string high. C equals three grade integral

66
00:05:51,726 --> 00:05:58,220
one. So now c evaluates the true. If you
want to print out a display of your

67
00:05:58,220 --> 00:06:05,029
variable, here's how you go about it. Let
me set a equals pi. And, if I wanna print

68
00:06:05,029 --> 00:06:10,341
A, I can just type A, like so, and it
prints it out. For more complex printing,

69
00:06:10,341 --> 00:06:15,795
there's also the [inaudible] command,
which, sends the displays. [inaudible]

70
00:06:15,795 --> 00:06:21,107
display A, it just prints out A like so.
You can also display the strings, so

71
00:06:21,107 --> 00:06:27,571
[inaudible] F, two decimals. And percent
0.2f, a like so. And this will print out

72
00:06:27,571 --> 00:06:34,076
the string two decimal colon 3.14. This is
kind of a [inaudible] old style C-syntax.

73
00:06:34,311 --> 00:06:40,502
For those of you that have program C
before this is [inaudible] syntax used to

74
00:06:40,502 --> 00:06:46,522
print strings. So sprintf generates a
sprint, generates a string. Does this and

75
00:06:46,522 --> 00:06:53,020
two decimals 3.1 pulls the string this
percent 0.2F means substitute A into here

76
00:06:53,020 --> 00:06:58,976
showing it with two digits after the
decimal point and this takes the string

77
00:06:58,976 --> 00:07:05,086
this generated by the sprint F command S
print f the sprint F command and this

78
00:07:05,086 --> 00:07:11,378
actually displays the string and to show
you an example, sprint F six decimals. >>

79
00:07:11,378 --> 00:07:17,660
Percent 0.6F comma A. And this should
print pi with six decimal, to, to, six

80
00:07:17,660 --> 00:07:24,287
decimal places. Finally, I'll explain A
like so, look like this, there, there are

81
00:07:24,287 --> 00:07:30,656
useful shortcuts you take, formats long,
it causes strings to, by default, be

82
00:07:30,656 --> 00:07:37,455
displayed to a lot more decimal places,
and format short [inaudible] default of

83
00:07:37,455 --> 00:07:44,200
just printing a small number of digits. >>
Okay. That's how you work with variables

84
00:07:44,200 --> 00:07:50,529
now lets look at vectors and [inaudible]
let's say you want to assign A to matrix

85
00:07:50,529 --> 00:07:56,081
let me show you an example, twelve:34: .
Five, six. This generates a three by three

86
00:07:56,081 --> 00:08:01,366
matrix A who's first row is 1,2, second
row three, four, third row is five, six.

87
00:08:01,366 --> 00:08:06,721
What the semi colon does is essentially
say go to the next row of the matrix.

88
00:08:06,721 --> 00:08:12,297
There are other ways to type this in. Type
angles one, two semi colon. Three, four;

89
00:08:12,297 --> 00:08:18,149
five, six, like so. And that's another
equivalent way of assigning A to be the

90
00:08:18,149 --> 00:08:24,232
values of, this, three by two matrix. Some
[inaudible] assign factors. So V=1, two,

91
00:08:24,232 --> 00:08:30,392
three. This is actually a [inaudible]
vector. Or this is a three by one vector,

92
00:08:30,392 --> 00:08:36,321
right? This is a [inaudible] Y vector,
excuse me. Not, this is, a one by three

93
00:08:36,321 --> 00:08:44,273
matrix. Right not N by one if I want to
assign this to a. Harden factor. What we

94
00:08:44,273 --> 00:08:50,290
do instead is B equals one semicolon, two
semicolon, three and this will give me a.

95
00:08:50,290 --> 00:08:57,162
Three by one is one by three vector so
this is a column vector. Here some more

96
00:08:57,162 --> 00:09:04,299
useful notations b equals one colon 0.1
colon two. What this does is it sets b to

97
00:09:04,299 --> 00:09:12,236
the bunch of elements that start from one.
And increments and, and steps of 0.1 until

98
00:09:12,236 --> 00:09:20,508
you get up to two. So if I do this, V is
going to be this you know, low vector. Or

99
00:09:20,508 --> 00:09:28,679
this is what, one by eleven matrix really.
That's 1.1, one, 1.1, 1.2, 1.3 and so on

100
00:09:28,679 --> 00:09:37,429
until we get up to two. Now and I can also
say B = one:6 and that sets B to be these

101
00:09:37,429 --> 00:09:44,835
numbers one through six. Okay now here's
some other way to generating matrices, 1's

102
00:09:45,093 --> 00:09:52,328
2x3 is a command that generates a matrix
that is a 2x3 matrix that is the matrix of

103
00:09:52,328 --> 00:09:59,649
our 1's so if I set C = two x 1's 2x3 this
generates a 2x3 matrix that is all 2's and

104
00:09:59,649 --> 00:10:07,228
this is you can think of this as a shorter
way of writing this NC = 222 semicolon 222

105
00:10:07,228 --> 00:10:16,100
which will also give you the same result.
Lets say W = 1's, 1x3 so this is going to

106
00:10:16,100 --> 00:10:27,316
be a row vector or a you know row of three
1's and some of you, you can also say W =

107
00:10:27,316 --> 00:10:36,121
0's 1x3 this generates a matrix, 1x3
matrix, of all 0's. Just a couple more

108
00:10:36,121 --> 00:10:43,205
ways to generate matrixes. There I do W
equals rand one by three. This gives me a

109
00:10:43,205 --> 00:10:49,628
one by three matrix of all random numbers.
If I do rand. Three by three excuse me a

110
00:10:49,628 --> 00:10:53,918
three by three matrix of all random
numbers drawn from the uniform

111
00:10:53,918 --> 00:10:59,105
distribution which is 01. So every time I
do this I get a different set of random

112
00:10:59,105 --> 00:11:04,163
numbers drawn uniformly between the zero
and the one. For those of you who know

113
00:11:04,163 --> 00:11:09,158
what a Gaussian random variable is or for
those who know what a Normal random

114
00:11:09,158 --> 00:11:14,792
variable is you can also say that W called
rant N one-third. So these are going to be

115
00:11:14,792 --> 00:11:19,787
three values drawn from a Gaussian
distribution which means zero and variance

116
00:11:19,787 --> 00:11:25,654
distribution is equal to one. And. Can set
more complex things like W = -six plus

117
00:11:25,654 --> 00:11:31,475
square root ten. Times. Let say rand
[inaudible] one by 10,000. [inaudible]

118
00:11:31,475 --> 00:11:37,928
semicolon at the end because I don't
really want to [inaudible] it out. This is

119
00:11:37,928 --> 00:11:44,695
going to be a what. Well this is going to
be a vector of 100,000 [inaudible] 10,000

120
00:11:44,695 --> 00:11:50,352
elements so. Well actually you know what
let's print it up so this would generate a

121
00:11:50,352 --> 00:11:56,445
matrix like this Right? With 10,000
elements so that's what W is. And if I now

122
00:11:56,445 --> 00:12:02,958
plot a histogram, W, with the hiss command
I can now enter [inaudible]. Hiss command

123
00:12:02,958 --> 00:12:08,915
takes a couple seconds to bring these up
but this is a histogram, my random

124
00:12:08,915 --> 00:12:14,871
variable for W that was minus six plus
zero ten times this Gaussian random

125
00:12:14,871 --> 00:12:21,305
variable. And I can plot a histogram with
more buckets, with more bins, with say 50

126
00:12:21,305 --> 00:12:27,737
bins and. This is my histogram of
[inaudible] with mean - six because I have

127
00:12:27,737 --> 00:12:34,531
a -six t here plus [inaudible] ten times
so the, the variants or this calcium is

128
00:12:34,531 --> 00:12:41,408
therefore ten on the standard deviation
the square root of ten which is about what

129
00:12:41,408 --> 00:12:46,664
3.1. Finally one special command to
generate a matrix which is the I command

130
00:12:46,664 --> 00:12:52,878
so. I stands for, this is maybe pun on the
word identity. But so they set i4, this is

131
00:12:52,878 --> 00:12:58,813
the four by four identity matrix. And I,
of course i4, this gives me a four by four

132
00:12:58,813 --> 00:13:04,602
identity matrix and I [inaudible] i5, i6,
that gives me a six by six identity

133
00:13:04,602 --> 00:13:09,878
matrix, as i3 gives the three by three
identity matrix. Lots of these are

134
00:13:09,878 --> 00:13:15,887
[inaudible] has one more useful command
which is the help command. So you can type

135
00:13:15,887 --> 00:13:21,761
help I, and this brings up the help
function for the identity matrix. Hit Q to

136
00:13:21,761 --> 00:13:27,702
quit and you can also type help rand
brings up documentation for the rand or

137
00:13:27,702 --> 00:13:33,643
the random number generation function or
even help, help which shows you help on

138
00:13:33,643 --> 00:13:40,568
the help function. So, those are the basic
operations in octave and with this you

139
00:13:40,568 --> 00:13:46,486
should be able to generate a few matrices,
multiply, add things, and, and use the

140
00:13:46,486 --> 00:13:52,111
basic operations in octave. In the next
video, I'd like to start talking about

141
00:13:52,111 --> 00:13:58,321
more sophisticated commands and how to
move data around and start to process data

142
00:13:58,321 --> 00:13:59,052
in octave.
