﻿1
00:00:00,570 --> 00:00:01,470
‫Welcome back.

2
00:00:02,130 --> 00:00:09,120
‫In the last lecture, we saw how to combine and train our model  in this lecture.

3
00:00:09,210 --> 00:00:16,780
‫We will learn how to evaluate performance of our model and how to predict classes on the new dataset

4
00:00:17,100 --> 00:00:27,150
‫using over this train model first to evaluate performance of our model than we have to use the evaluate

5
00:00:27,150 --> 00:00:27,600
‫method.

6
00:00:28,230 --> 00:00:33,440
‫So just write, you have model object name, which in our case is model

7
00:00:33,840 --> 00:00:39,550
‫And then we are calling evaluate method and inside evaluate.

8
00:00:39,720 --> 00:00:42,740
‫We have to give our test datasets.

9
00:00:43,320 --> 00:00:49,910
‫So we are writing X test first the independent test dataset and then dependent test set

10
00:00:51,150 --> 00:00:53,310
‫So let's just run this.

11
00:00:58,910 --> 00:01:04,700
‫So the output here is first the loss and then the accuracy.

12
00:01:05,330 --> 00:01:12,990
‫This is accuracy because this is the metrics which we mention when compiling a lot more than a few remember.

13
00:01:13,510 --> 00:01:17,720
‫While compiling, we mentioned metrics equal to accuracy.

14
00:01:18,350 --> 00:01:22,700
‫And that's why the second value which we are getting here is of accuracy.

15
00:01:23,600 --> 00:01:33,230
‫So on our test set, the accuracy which we are getting is 86 percent, which is really good as compared

16
00:01:33,230 --> 00:01:37,450
‫to logistic liquidations or decision trees on the same dataset.

17
00:01:38,600 --> 00:01:42,860
‫So with those models, you will get around 70 to 80 percent accuracy.

18
00:01:42,920 --> 00:01:47,810
‫But here with ann we are getting 86 percent accuracy.

19
00:01:49,730 --> 00:01:55,170
‫So once again, to check the accuracy score or just to check the performance of your model.

20
00:01:56,030 --> 00:01:57,190
‫You have to use evaluate method

21
00:01:57,190 --> 00:01:57,770
‫.

22
00:01:58,670 --> 00:02:06,560
‫Now let's learn how to predict the probabilities and how to predict the classes on our new unseen data

23
00:02:07,900 --> 00:02:08,150
‫since.

24
00:02:08,670 --> 00:02:10,460
‫Right now we do not have any new data.

25
00:02:11,030 --> 00:02:20,690
‫We just taking first three samples from our test dataset and consider that as your new unseen data now

26
00:02:21,080 --> 00:02:22,250
‫just run this.

27
00:02:23,840 --> 00:02:31,340
‫So we have Stored the first three records from our test dataset and we are considering it as our new record.

28
00:02:32,600 --> 00:02:35,060
‫So there are two parameters which you can predict.

29
00:02:35,420 --> 00:02:42,320
‫First one is the probability of each class and second one is the class.

30
00:02:42,380 --> 00:02:42,850
‫Itself

31
00:02:44,790 --> 00:02:49,460
‫Let's first calculate the probability score assigned to each class.

32
00:02:50,810 --> 00:02:53,740
‫To do that, we can use dot predict method.

33
00:02:54,980 --> 00:02:59,840
‫So we'll write our object name model then dot predict method

34
00:03:00,440 --> 00:03:04,830
‫And as an argument, we are passing our new unseen data.

35
00:03:04,910 --> 00:03:06,440
‫Which is X_new

36
00:03:08,730 --> 00:03:10,080
‫Let's just run this.

37
00:03:11,930 --> 00:03:15,770
‫You can see our new that contains three records.

38
00:03:16,100 --> 00:03:18,830
‫That's why we are getting output for three records.

39
00:03:19,250 --> 00:03:28,360
‫And there are ten values in each of these elements representing the probability values of corresponding

40
00:03:28,360 --> 00:03:28,820
‫class.

41
00:03:31,090 --> 00:03:33,100
‫So for the first record.

42
00:03:34,870 --> 00:03:41,670
‫The maximum probability is for label equal to 10 and the probability value is 0.99 .

43
00:03:43,190 --> 00:03:49,910
‫For the second record, probability is one, for the label corresponding to the third object and for the

44
00:03:49,910 --> 00:03:54,500
‫third record, we have probably equal to hundred for the second object.

45
00:03:56,560 --> 00:04:02,840
‫We are also using round equal to 2 just to round off these probabilities values to 2 decimal digits.

46
00:04:03,080 --> 00:04:03,400
‫.

47
00:04:05,980 --> 00:04:07,360
‫Now with dot predict

48
00:04:07,660 --> 00:04:14,530
‫We are predicting probabilities, but if we want to directly predict the class and not the probability scores,

49
00:04:15,010 --> 00:04:17,540
‫we can use dot predict underscore.

50
00:04:17,700 --> 00:04:18,600
‫Classes method

51
00:04:20,170 --> 00:04:21,630
‫So Syntex is almost same.

52
00:04:21,850 --> 00:04:28,080
‫First, you have to write your model object name and then call the predict underscore classes method.

53
00:04:28,450 --> 00:04:31,400
‫And in bracket, you have to mention your new dataset.

54
00:04:32,830 --> 00:04:33,760
‫Just run this.

55
00:04:36,540 --> 00:04:40,800
‫You can see here we are getting an array of the labels.

56
00:04:41,160 --> 00:04:42,600
‫So for the first object.

57
00:04:44,210 --> 00:04:49,430
‫The class label is nine, so you can also confirm it from here also.

58
00:04:50,720 --> 00:04:58,180
‫The maximum probability was assigned to this object and here also we are getting the position as 9

59
00:04:58,510 --> 00:05:00,630
‫remember the numbering

60
00:05:00,650 --> 00:05:01,850
‫starts from zero

61
00:05:02,000 --> 00:05:03,350
‫So this one is zero.

62
00:05:03,680 --> 00:05:04,640
‫This one is one.

63
00:05:04,940 --> 00:05:05,600
‫And so on.

64
00:05:05,840 --> 00:05:06,950
‫And this one is nine.

65
00:05:08,620 --> 00:05:13,570
‫So for the second record, we are getting the predicted class is 2.

66
00:05:13,990 --> 00:05:20,370
‫And you can also see that the probability was maximum for this record, which is zero one two.

67
00:05:20,710 --> 00:05:24,250
‫So second object for the third record.

68
00:05:24,960 --> 00:05:28,510
‫We are getting the predicted class as one.

69
00:05:29,680 --> 00:05:37,800
‫And in the probabilities also, you can see that the maximum probability correspond to position number

70
00:05:37,810 --> 00:05:38,080
‫one.

71
00:05:39,950 --> 00:05:45,500
‫Now, again, it's a little bit difficult to interpret results like this.

72
00:05:45,530 --> 00:05:46,670
‫Nine to one.

73
00:05:47,240 --> 00:05:55,400
‫So let's just call the label description instead of this, numerical labels. So will do the same thing we did

74
00:05:55,550 --> 00:05:56,060
‫earlier.

75
00:05:56,810 --> 00:06:00,260
‫We have already created a list called class Name.

76
00:06:00,770 --> 00:06:04,340
‫We are just passing y pred into that list.

77
00:06:05,880 --> 00:06:12,810
‫So if you run this instead of this labels, you will get the description of each record.

78
00:06:13,500 --> 00:06:20,750
‫So now let's just confirm this by plotting the image of our first new dataset.

79
00:06:22,100 --> 00:06:24,650
‫So the position is zero and we are using.

80
00:06:24,740 --> 00:06:27,230
‫Iamshow plot this.

81
00:06:30,650 --> 00:06:39,260
‫You can see this photo looks like an ankle boot, and we also predicted ankle boot for the second

82
00:06:39,260 --> 00:06:46,460
‫record where the position is one and see that this is a pullover.

83
00:06:46,700 --> 00:06:48,610
‫And we also predicted pullover.

84
00:06:50,830 --> 00:06:53,500
‫For the third object here, the position is 2

85
00:06:58,090 --> 00:07:04,000
‫You can see that this is a jeans or a trouser and we also predicted trouser

86
00:07:07,010 --> 00:07:15,710
‫So that's how we predict with our model we can use evaluate to evaluate performance of model

87
00:07:15,830 --> 00:07:18,950
‫on test set and to predict new values.

88
00:07:19,010 --> 00:07:26,420
‫We can either use dot predict method or dot predict underscore classes method. Dot predict

89
00:07:26,500 --> 00:07:32,460
‫method will give us the probability values assigned to each class for each record.

90
00:07:33,770 --> 00:07:41,720
‫While predict underscore classes will give us details about the most probable class for that record

91
00:07:46,220 --> 00:07:55,880
‫So that's how we create train and predict using mlp model. now just for a quick summary.

92
00:08:00,320 --> 00:08:03,670
‫We started with importing and installing tensorflow.

93
00:08:05,960 --> 00:08:11,240
‫Then we imported our fashion mnsist dataset with 10 categories.

94
00:08:14,070 --> 00:08:19,220
‫Then we divided that dataset in to train validation and test set

95
00:08:20,390 --> 00:08:23,160
‫And before that we also normalize our dataset

96
00:08:25,720 --> 00:08:32,740
‫Now, after that, we created architecture for a our model this is where you mention the activation

97
00:08:32,740 --> 00:08:37,270
‫functions, number of neurons you want in your layers.

98
00:08:40,580 --> 00:08:46,700
‫After that, we compiled our model to give loss function optimizer and the metrics we want

99
00:08:46,700 --> 00:08:47,410
‫to calculate.

100
00:08:47,870 --> 00:08:51,120
‫And after that we trained our model using dot fit

101
00:08:51,290 --> 00:08:51,770
‫Method

102
00:08:54,290 --> 00:09:02,670
‫And after our model is trained, we can use dot art history method to get all the loss anf accuracy's

103
00:09:02,730 --> 00:09:04,520
‫Values for each epoch.

104
00:09:05,610 --> 00:09:13,830
‫After that, we can use dot elevate method to check accuracy scores on our test dataset, and we can

105
00:09:13,830 --> 00:09:20,280
‫also predict values for new records using dot predict and dot predict underscore classes method.

