﻿1
00:00:00,233 --> 00:00:01,100
Okay, my friends.

2
00:00:01,100 --> 00:00:04,033
So let's smash together
this last final step.

3
00:00:04,033 --> 00:00:08,266
Visualizing the decision tree
regression results in high resolution.

4
00:00:08,900 --> 00:00:09,366
All right,

5
00:00:09,366 --> 00:00:10,533
so we're going to do

6
00:00:10,533 --> 00:00:14,300
kind of the same exercise as what we did
previously with the SVR.

7
00:00:14,300 --> 00:00:19,900
You know that funny exercise where we
start from the polynomial regression code

8
00:00:20,066 --> 00:00:24,900
for the visualization of the results,
meaning this one.

9
00:00:25,100 --> 00:00:26,466
So we're going to start from this code.

10
00:00:26,466 --> 00:00:30,866
And then the exercise for
you will be to make the right change

11
00:00:30,866 --> 00:00:35,066
or changes in order to make this work
for the decision tree regression model.

12
00:00:35,433 --> 00:00:39,166
If we did this successfully
for the SVR model, well,

13
00:00:39,166 --> 00:00:42,366
it will be a piece of cake to do it
for the decision tree

14
00:00:42,366 --> 00:00:45,600
regression model, because indeed
no feature scaling was needed.

15
00:00:45,700 --> 00:00:46,300
And therefore

16
00:00:46,300 --> 00:00:50,300
we won't have to play with the transform
method or the inverse transform method.

17
00:00:50,500 --> 00:00:52,766
And therefore you will just smash this.

18
00:00:52,766 --> 00:00:54,533
Okay. So let's do this.

19
00:00:54,533 --> 00:00:55,366
That's the exercise.

20
00:00:55,366 --> 00:00:57,700
So let's take this whole code here.

21
00:00:57,700 --> 00:01:01,433
You know which plots indeed the regression
curve in high resolution.

22
00:01:01,433 --> 00:01:04,433
But for the polynomial regression model

23
00:01:04,500 --> 00:01:08,800
let's paste that right here
in the new code cell.

24
00:01:09,233 --> 00:01:10,666
And now well there you go.

25
00:01:10,666 --> 00:01:15,366
Please press pause on the video
and make the right change or right changes

26
00:01:15,600 --> 00:01:16,833
in order to make it work.

27
00:01:16,833 --> 00:01:20,600
For decision tree regression model okay.

28
00:01:20,766 --> 00:01:21,200
Good.

29
00:01:21,200 --> 00:01:23,666
So now I'm going to implement the solution
with you.

30
00:01:23,666 --> 00:01:26,100
And let's start with the obvious change.

31
00:01:26,100 --> 00:01:32,233
Let's replace polynomial here by well
decision tree okay.

32
00:01:32,233 --> 00:01:36,300
And then what was the change or changes
you had to make.

33
00:01:36,600 --> 00:01:39,600
Well as I told you here it's super easy.

34
00:01:39,833 --> 00:01:41,700
You just have to change two things.

35
00:01:41,700 --> 00:01:44,700
And actually only one row
which is row number four.

36
00:01:44,866 --> 00:01:45,166
Right.

37
00:01:45,166 --> 00:01:48,600
Because this row number three
is totally fine because here x

38
00:01:48,600 --> 00:01:52,500
and y are on the right scale, you know,
because no feature scaling was applied.

39
00:01:52,500 --> 00:01:53,533
That's fine.

40
00:01:53,533 --> 00:01:57,800
And here well, the obvious change
that we have to make is of course to first

41
00:01:57,800 --> 00:02:02,833
replace this regressor by the right
name of the regressor, which is regressor.

42
00:02:04,066 --> 00:02:04,933
All right.

43
00:02:04,933 --> 00:02:06,333
Good regressor.

44
00:02:06,333 --> 00:02:10,433
And then here, you know, remember this
poorly rag transformation object

45
00:02:10,533 --> 00:02:14,666
was used to transform the matrix
of single feature into this matrix

46
00:02:14,666 --> 00:02:17,900
of the same feature at different powers,
part two, three and four.

47
00:02:18,133 --> 00:02:19,000
And this time here.

48
00:02:19,000 --> 00:02:23,233
We absolutely don't need that because
we're not doing polynomial regression.

49
00:02:23,233 --> 00:02:27,433
So I'm removing this
and then also a parenthesis here.

50
00:02:28,000 --> 00:02:29,566
And now guess what.

51
00:02:29,566 --> 00:02:31,400
Well that's done right.

52
00:02:31,400 --> 00:02:33,966
That's the simple visualization code.

53
00:02:33,966 --> 00:02:36,700
When you know
you don't have to apply feature scaling,

54
00:02:36,700 --> 00:02:39,933
and you don't have to transform
your matrix of features

55
00:02:39,933 --> 00:02:42,933
into powered features
as in polynomial regression.

56
00:02:43,400 --> 00:02:45,000
So that was as simple as that.

57
00:02:45,000 --> 00:02:46,266
I told you. Right.

58
00:02:46,266 --> 00:02:47,966
But now that was a good news.

59
00:02:47,966 --> 00:02:49,200
And now I have some bad news.

60
00:02:49,200 --> 00:02:50,500
You're going to see that

61
00:02:50,500 --> 00:02:54,700
the results are not going to be pretty,
because indeed, let's do this now.

62
00:02:54,700 --> 00:02:56,366
Let's execute this cell.

63
00:02:56,366 --> 00:02:57,900
There you go playing.

64
00:02:57,900 --> 00:03:01,100
And here are the decision

65
00:03:01,100 --> 00:03:04,500
tree regression results
I really want to say this again.

66
00:03:04,500 --> 00:03:08,400
The decision tree regression
model is really not the best adapted

67
00:03:08,400 --> 00:03:10,200
to two dimensional data sets.

68
00:03:10,200 --> 00:03:12,966
You know, with only one feature
in one dependent variable.

69
00:03:12,966 --> 00:03:16,633
But once again, I'd like to remind that
the implementation we have here

70
00:03:16,800 --> 00:03:20,500
can be very easily
adapted to any other data sets.

71
00:03:20,500 --> 00:03:23,433
And I will show you what to do
at the end of this tutorial.

72
00:03:23,433 --> 00:03:25,200
You know what to change in this code,

73
00:03:25,200 --> 00:03:29,433
but I still wanted to show you the
decision tree regression results in 2D.

74
00:03:29,700 --> 00:03:31,600
And so why isn't this pretty?

75
00:03:31,600 --> 00:03:34,766
Because you know what this decision tree
regression model simply

76
00:03:34,766 --> 00:03:37,800
did was to take the real results.

77
00:03:37,933 --> 00:03:40,933
You know, the real salary
for each position level,

78
00:03:40,966 --> 00:03:46,033
and then for all the position levels
from position level minus 0.5

79
00:03:46,033 --> 00:03:50,000
and the position level plus 0.5, well,
it predicted

80
00:03:50,000 --> 00:03:54,100
the salary to be the same
as the position level in the middle.

81
00:03:54,300 --> 00:03:54,600
All right.

82
00:03:54,600 --> 00:03:55,766
So that's what it simply did.

83
00:03:55,766 --> 00:03:58,500
And that's
you know, understandable and intuitive.

84
00:03:58,500 --> 00:04:01,433
You know to understand
because you know how decision trees work.

85
00:04:01,433 --> 00:04:05,066
They work by splitting the data
through successive nodes.

86
00:04:05,300 --> 00:04:06,200
And so at the end, you know,

87
00:04:06,200 --> 00:04:10,000
you get different ranges of the features
where the prediction is the same.

88
00:04:10,600 --> 00:04:13,433
And so here all the predicted salaries

89
00:04:13,433 --> 00:04:16,733
in this range of position
levels are just the same.

90
00:04:16,733 --> 00:04:21,833
And that's why we have this stair looking
like curve up to the last position level.

91
00:04:21,833 --> 00:04:24,333
And of course here this is not continuous.

92
00:04:24,333 --> 00:04:25,900
This is actually a vertical bar.

93
00:04:25,900 --> 00:04:28,266
So the regression curve here
is not continuous.

94
00:04:28,266 --> 00:04:33,600
We jump from position level
to the next one every step of one okay.

95
00:04:33,600 --> 00:04:35,000
So not pretty at all.

96
00:04:35,000 --> 00:04:36,866
Not relevant at all in 2D.

97
00:04:36,866 --> 00:04:41,400
But I still recommend to try the decision
tree regression model for higher

98
00:04:41,400 --> 00:04:46,166
dimensional data sets because indeed it
can actually have great performance.

99
00:04:46,833 --> 00:04:49,133
All right. Great. So congratulations.

100
00:04:49,133 --> 00:04:52,800
Now you added this new machine
learning model in your toolkit.

101
00:04:52,800 --> 00:04:57,133
And now we will tackle together the final
regression model of this part two.

102
00:04:57,133 --> 00:04:58,966
And until then enjoy machine learning.
