1
00:00:00,000 --> 00:00:04,781
When developing learning algorithms. Very
often, a few simple plots can give you a

2
00:00:04,781 --> 00:00:08,869
better sense of what the algorithm is
doing, and just sanity check that

3
00:00:08,869 --> 00:00:13,015
everything's going okay, and the
algorithm's doing what it's supposed to.

4
00:00:13,015 --> 00:00:17,679
For example, in an earlier video, I talked
about how plotting the cause function, J

5
00:00:17,679 --> 00:00:21,883
of theta, can help you make sure that
[inaudible] the sense is converging.

6
00:00:21,883 --> 00:00:26,259
Often, plots of the data, or of the
learning algorithm outputs will also give

7
00:00:26,259 --> 00:00:31,096
you ideas for how to improve your learning
algorithm, Fortunately, Octave has, very

8
00:00:31,096 --> 00:00:35,300
simple tools to generate lots of different
plots. And when I use learning.

9
00:00:35,300 --> 00:00:40,475
Algorithms. I find that plotting the data,
plotting the linear algorithm. And so on

10
00:00:40,475 --> 00:00:46,999
are often. An important part of how I get
ideas for improving the algorithms. And,

11
00:00:47,229 --> 00:00:53,343
in this video, I'd like to show you some
of these [inaudible] tools for plotting

12
00:00:53,343 --> 00:00:59,304
and visualizing your data. Here's my
[inaudible] window. Let's quickly generate

13
00:00:59,304 --> 00:01:05,418
some data. First the plots. I'm gonna set
T to be equal to, you know, this array of

14
00:01:05,418 --> 00:01:11,302
numbers. Here's T, set of numbers going
from zero up to.98. Let's say Y1 equals

15
00:01:11,302 --> 00:01:17,898
sine of two pi 4T. And if I want to plot.
The side function is very easy I just type

16
00:01:17,898 --> 00:01:23,901
plot T, Y one, and hit enter. And up comes
this part where the horizontal axis is the

17
00:01:23,901 --> 00:01:29,284
T variable and the vertical axis is Y one
which is this sort of [inaudible] sort of

18
00:01:29,284 --> 00:01:35,361
function that we just computed. Let's say
Y two is to be equal to. The co-sign of

19
00:01:35,361 --> 00:01:43,917
two pie four T like so and [cough] if I
plot. T, Y2 what octave will do is it will

20
00:01:43,917 --> 00:01:49,267
take my [inaudible] plot and it will
replace it with this cosign function that

21
00:01:49,267 --> 00:01:54,955
you know cosign of X start at one, right,
now what if I want to have, have both the

22
00:01:54,955 --> 00:02:00,643
sign and the cosign plots on top of each
other what I'm going to do is I'm going to

23
00:02:00,643 --> 00:02:05,518
type, plot T, Y1 so here's my sign
function and then I'm going to use the

24
00:02:05,518 --> 00:02:11,186
function, hold on. And what hold on does
is it causes Octave to now plot new

25
00:02:11,186 --> 00:02:17,495
figures on top of the old one and let me
now plot T Y two I'm plot the cosign

26
00:02:17,495 --> 00:02:24,114
function in a different color so when we
put in R in quotation marks there and

27
00:02:24,114 --> 00:02:30,422
instead of replacing current figure of
plot the cosign function on top and the R

28
00:02:30,422 --> 00:02:37,339
indicates the [inaudible] color and. Here
are additional commands it's labeled times

29
00:02:37,339 --> 00:02:44,208
to label the X axis or horizontal axis and
Y labeled values [inaudible] to label the

30
00:02:44,208 --> 00:02:56,204
vertical axis value and I can also.
[cough] And I can also label my two lines

31
00:02:56,204 --> 00:03:02,517
with this command legend, sign, cosign,
and, this plus this legend, up on the

32
00:03:02,517 --> 00:03:08,748
upper right showing what the two lines
are. And finally title my plot, put a

33
00:03:08,748 --> 00:03:15,393
title at the top of this figure. Lastly if
you want to save this figure, you type

34
00:03:15,393 --> 00:03:22,723
print, [inaudible] d, p and g. My plot
PNG. So, PNG is a graphics file format.

35
00:03:22,723 --> 00:03:30,670
And if you do this, this will actually
save this as a file. If I do that, let me

36
00:03:30,670 --> 00:03:38,086
ch-, change directory to Let's see. Put
that. And then I will print that out. So,

37
00:03:38,086 --> 00:03:44,678
this will take a while. Depending on how
your Octave conversions set up. This may

38
00:03:44,678 --> 00:03:50,733
take a few seconds. But change the
directory to my desktop. And Octave is now

39
00:03:50,733 --> 00:03:57,860
taking a few seconds to save this. If I
now go to my desktop. [cough] Let's hide

40
00:03:57,860 --> 00:04:03,892
these windows [inaudible] that's the
figure saved as a PNG file also can save

41
00:04:03,892 --> 00:04:10,311
in other formats as well so you can type
help plot if you want to see the other

42
00:04:10,543 --> 00:04:16,962
file formats rather than PNG that we can
save figures in and lastly if you want to

43
00:04:16,962 --> 00:04:22,711
get rid of the plot, the close command
[sound]. Causes a figure to go away so

44
00:04:22,711 --> 00:04:28,290
there's a figure I type close you know
that figure just disappeared from my, just

45
00:04:28,290 --> 00:04:35,290
disappeared from my desktop. Altiv also
lets you specify a figure of numbers you

46
00:04:35,290 --> 00:04:41,578
type figure one + T one, one. That starts
up a first figure and that helps TY1 and

47
00:04:41,578 --> 00:04:47,040
then if you want a second figure you
specify different figure numbers so figure

48
00:04:47,040 --> 00:04:52,639
two plot T Y two like so and now on my
desktop I actually have two figures figure

49
00:04:52,639 --> 00:04:58,238
one and figure two there's one plotting
the sign function one plotting the cosign

50
00:04:58,238 --> 00:05:03,427
function. Here's one other neat command
that often use which is the sub plot

51
00:05:03,427 --> 00:05:09,163
command so we're going to use sub plot one
two one what this does is it divides, sub

52
00:05:09,163 --> 00:05:15,489
divides the plot, into A 1x2 grid that's
what the first two parameters are and it

53
00:05:15,489 --> 00:05:21,988
starts to access the first element, that's
what the final parameter of one is right

54
00:05:21,988 --> 00:05:28,564
so just divide my figure into 1x2 grid and
I want to access the first element right

55
00:05:28,564 --> 00:05:35,063
now and so if I type that in this product
this figure is on the left and if I plot

56
00:05:35,063 --> 00:05:42,270
T. Y1, it now fills up this, you know,
first element. And if I now do subplot

57
00:05:42,270 --> 00:05:49,606
122, I'm gonna start to acess a second
element, and plot TY2. We'll throw in Y2

58
00:05:49,606 --> 00:05:56,769
in the right hand side or in the second
element. And last command, you can also

59
00:05:56,769 --> 00:06:03,415
change the access scales, and change
accesses to 1.51 minus 1.1. And this sets

60
00:06:03,415 --> 00:06:09,122
the X range and Y range for the figure on
the right. And completely assess the

61
00:06:09,122 --> 00:06:14,363
horizontal major values in figure on the
right that range to 0.5 to one and

62
00:06:14,363 --> 00:06:19,811
vertical axis values that range from -one
to one. And you know you don't need to

63
00:06:19,811 --> 00:06:25,534
memorize all these command and if you ever
need to change the axis all you need to

64
00:06:25,534 --> 00:06:31,327
know is that there's axis command and you
can really get the details from the usual

65
00:06:31,327 --> 00:06:37,099
[inaudible] help command. Finally just a
[inaudible] CLF here's the figure. And his

66
00:06:37,099 --> 00:06:44,131
one, one matrix less than A is equal to a
five by five matrix square [inaudible] say

67
00:06:44,131 --> 00:06:50,159
so A is now this five by five matrix.
Doesn't we trick lesson as used to

68
00:06:50,159 --> 00:06:56,827
visualize a matrix which I can use image
as c Of A, and what this will do is this

69
00:06:56,827 --> 00:07:03,671
will plot a five by five, matrix. So I'll
take my matrix and plot this as a five by

70
00:07:03,671 --> 00:07:10,273
five grid of colors, where the different
colors correspond to the different values

71
00:07:10,273 --> 00:07:16,634
in the A matrix. So, [inaudible], I can
also do color bar, let me use a more

72
00:07:16,634 --> 00:07:22,251
sophisticated command, [inaudible] color
bar, color. Map gray. This is actually

73
00:07:22,251 --> 00:07:27,210
running three commands at a time. We're
running image sc, then we're running color

74
00:07:27,210 --> 00:07:32,107
bar and we're running colormap gray. And
what this does is it sets the color for

75
00:07:32,107 --> 00:07:37,249
map to gray colormap and on the right it
also puts in this color bar. And so this

76
00:07:37,249 --> 00:07:42,147
color bar shows what the different shades
of color correspond to. Concretely, the

77
00:07:42,147 --> 00:07:46,861
upper left element of the a matrix is
seventeen and so, yeah, that corresponds

78
00:07:46,861 --> 00:07:52,916
to kind of a knit shade of gray. Where as
in contrast the second element of A sort

79
00:07:52,916 --> 00:07:59,408
of the one two element of A is 24 where it
says A one two is 24 so that response to

80
00:07:59,408 --> 00:08:08,047
this graph here which is a nearly a shade
of white. And the small values say A, what

81
00:08:08,047 --> 00:08:15,322
is that, A four five It's about a three
over here that response you can see on my

82
00:08:15,322 --> 00:08:21,135
color bar, that response much darker of
shade in this image. So, here's an example

83
00:08:21,135 --> 00:08:27,166
I can plot it larger [inaudible] magic
fifteen. That gives me fifteen by fifteen

84
00:08:27,166 --> 00:08:33,342
matrix square and this gives me a plot of
a what my fifteen by fifteen matrix values

85
00:08:33,342 --> 00:08:38,865
look like. And finally to wrap up this
video. What you see me do here is use a

86
00:08:38,865 --> 00:08:44,502
comma chaining of function calls. Here's
how you actually do this. If I type A

87
00:08:44,502 --> 00:08:49,868
equals one, B equals two, C equals three
And hit enter then this, this is actually

88
00:08:49,868 --> 00:08:55,170
carrying out three commands at the same
time or really carrying out three commands

89
00:08:55,170 --> 00:09:00,535
one after another and it prints out all
three results and this is a lot like =one

90
00:09:00,535 --> 00:09:05,389
B=2 C=3 except that if I use semicolons
instead of a comma it doesn't print out

91
00:09:05,389 --> 00:09:10,499
anything, so this you know this thing here
we call comma chaining of commands so

92
00:09:10,499 --> 00:09:15,800
comma chaining of function calls and it's
just another convenient way in octave to

93
00:09:15,800 --> 00:09:21,003
put multiple commands like image. See
color bar, color map to put muti commands

94
00:09:21,003 --> 00:09:25,683
on the same line. So that's it. You now
know how to plot different figures in

95
00:09:25,683 --> 00:09:30,784
[inaudible]. And, in, Nick's video, the,
the [inaudible] I wanna tell you about is,

96
00:09:30,966 --> 00:09:35,764
how to write control statements. Like
if/while/for statements in [inaudible], as

97
00:09:35,764 --> 00:09:38,194
well as how to define and use functions.
