1
00:00:00,000 --> 00:00:02,100
So now, if we look at the values

2
00:00:02,100 --> 00:00:04,080
again and see that
these are the weights

3
00:00:04,080 --> 00:00:06,525
for the values at
that particular timestamp

4
00:00:06,525 --> 00:00:09,465
and b is the bias or the slope,

5
00:00:09,465 --> 00:00:11,820
we can do a standard
linear regression

6
00:00:11,820 --> 00:00:14,020
like this to predict
the value of y

7
00:00:14,020 --> 00:00:16,430
at any step by multiplying out

8
00:00:16,430 --> 00:00:19,475
the x values by the weights
and then adding the bias.

9
00:00:19,475 --> 00:00:21,590
So for example, if I take

10
00:00:21,590 --> 00:00:24,080
20 items in my series
and print them out,

11
00:00:24,080 --> 00:00:26,345
I can see the 20x values.

12
00:00:26,345 --> 00:00:27,965
If I want to predict them,

13
00:00:27,965 --> 00:00:30,860
I can pass that series into
my model to get a prediction.

14
00:00:30,860 --> 00:00:33,290
The NumPy new axis then just

15
00:00:33,290 --> 00:00:35,510
reshapes it to
the input dimension

16
00:00:35,510 --> 00:00:36,995
that's used by the model.

17
00:00:36,995 --> 00:00:39,545
The output will look like this.

18
00:00:39,545 --> 00:00:42,950
The top array is the 20 values
that provide the input to

19
00:00:42,950 --> 00:00:44,690
our model and the bottom is

20
00:00:44,690 --> 00:00:47,435
the predicted value
back from the model.

21
00:00:47,435 --> 00:00:49,370
So we've trained
our model to say that

22
00:00:49,370 --> 00:00:51,440
when it sees 20 values like this,

23
00:00:51,440 --> 00:00:55,780
the predicted next value
is 49.08478.

24
00:00:55,780 --> 00:00:59,690
So if we want to plot our
forecasts for every point on

25
00:00:59,690 --> 00:01:01,640
the time-series relative to

26
00:01:01,640 --> 00:01:05,480
the 20 points before it where
our window size was 20,

27
00:01:05,480 --> 00:01:07,490
we can write code like this.

28
00:01:07,490 --> 00:01:11,060
We create an empty list
of forecasts and

29
00:01:11,060 --> 00:01:12,530
then iterate over the series

30
00:01:12,530 --> 00:01:14,300
taking slices and window size,

31
00:01:14,300 --> 00:01:15,770
predicting them, and adding

32
00:01:15,770 --> 00:01:17,720
the results to the forecast list.

33
00:01:17,720 --> 00:01:19,910
We had split our time series

34
00:01:19,910 --> 00:01:21,635
into training and testing sense

35
00:01:21,635 --> 00:01:23,870
taking everything
before a certain time

36
00:01:23,870 --> 00:01:26,345
is training and
the rest is validation.

37
00:01:26,345 --> 00:01:28,670
So we'll just take
the forecasts after

38
00:01:28,670 --> 00:01:30,200
the split time and load

39
00:01:30,200 --> 00:01:32,435
them into a NuimPy array
for charting.

40
00:01:32,435 --> 00:01:34,880
That chart looks like this with

41
00:01:34,880 --> 00:01:35,960
the actual values in

42
00:01:35,960 --> 00:01:38,420
blue and the predicted
ones in orange.

43
00:01:38,420 --> 00:01:40,220
You can see that
our predictions look pretty

44
00:01:40,220 --> 00:01:41,780
good and getting them was

45
00:01:41,780 --> 00:01:44,150
relatively simple
in comparison with

46
00:01:44,150 --> 00:01:45,680
all the statistical gymnastics

47
00:01:45,680 --> 00:01:47,840
that we had to do
in the last videos.

48
00:01:47,840 --> 00:01:50,345
So let's measure
the mean absolute error

49
00:01:50,345 --> 00:01:51,830
as we've done before,

50
00:01:51,830 --> 00:01:54,680
and we can see that we're in
a similar ballpark to where

51
00:01:54,680 --> 00:01:58,100
we were with a complex analysis
that we did previously.

52
00:01:58,100 --> 00:02:00,950
Now that's just using
a single layer in

53
00:02:00,950 --> 00:02:03,770
a neural network to calculate
a linear regression.

54
00:02:03,770 --> 00:02:05,300
Let's see if we
could do better with

55
00:02:05,300 --> 00:02:07,505
a fully-connected DNN next.

56
00:02:07,505 --> 00:02:09,020
Before you get to that,

57
00:02:09,020 --> 00:02:11,225
we'll go through
the workbook for this lesson

58
00:02:11,225 --> 00:02:12,650
to ensure that you understand

59
00:02:12,650 --> 00:02:14,285
everything we've done up to now.

60
00:02:14,285 --> 00:02:16,700
The next video will be
a screencast of going through

61
00:02:16,700 --> 00:02:20,070
that and then you'll work
on the DNN after that.