1
00:00:00,000 --> 00:00:01,000
Hello guys.

2
00:00:01,000 --> 00:00:04,000
So we are going to continue a discussion with respect to Streamlit app.

3
00:00:04,000 --> 00:00:10,000
Uh, now in this video I'll just try to show you and uh, project uh, again a machine learning project.

4
00:00:10,000 --> 00:00:16,000
And just to give you an idea like how easily you'll be able to create any web app with the help of Streamlit.

5
00:00:16,000 --> 00:00:22,000
Okay, I know, uh, you may not have seen any machine learning algorithms yet.

6
00:00:22,000 --> 00:00:26,000
I would suggest at least you have some idea about some of the machine learning algorithms, like Random

7
00:00:26,000 --> 00:00:27,000
Forest and all.

8
00:00:27,000 --> 00:00:32,000
But here in this problem statement, I am going to solve a classification problem statement, right?

9
00:00:32,000 --> 00:00:38,000
So this is just to show you or give you an idea like how to properly develop an end to end project with

10
00:00:38,000 --> 00:00:39,000
the help of Streamlit.

11
00:00:39,000 --> 00:00:45,000
So first of all, I will go ahead and import all this libraries that is Streamlit pandas and sklearn

12
00:00:45,000 --> 00:00:49,000
dot datasets uh and sklearn dot uh learn dot ensemble.

13
00:00:49,000 --> 00:00:54,000
So first of all I need to go ahead and install this sky kit.

14
00:00:54,000 --> 00:00:55,000
Learn.

15
00:00:55,000 --> 00:01:02,000
Okay, so I will just go ahead and, uh, I have to import one very important library that is called

16
00:01:02,000 --> 00:01:04,000
as Sky Kit learn, which is nothing.

17
00:01:04,000 --> 00:01:06,000
But this is the same as sklearn.

18
00:01:06,000 --> 00:01:09,000
So for that I need to go ahead and install this.

19
00:01:09,000 --> 00:01:16,000
So here I will open my terminal and uh I will close this okay.

20
00:01:16,000 --> 00:01:22,000
So let's quickly go ahead and do the pip install uh minus our requirement dot txt.

21
00:01:22,000 --> 00:01:25,000
So here you can see requirement dot txt file is not visible.

22
00:01:25,000 --> 00:01:29,000
The reason is very much simple because I'm inside my Streamlit folder.

23
00:01:29,000 --> 00:01:31,000
So I'll just go ahead and write CD dot dot.

24
00:01:31,000 --> 00:01:33,000
Now let me go ahead and do the installation.

25
00:01:33,000 --> 00:01:37,000
So once I do the installation my scikit learn will get installed.

26
00:01:37,000 --> 00:01:42,000
And then only I will be able to use this sklearn dot datasets and sklearn dot ensemble.

27
00:01:42,000 --> 00:01:46,000
And this is one of the classification algorithm that we are going to use okay.

28
00:01:47,000 --> 00:01:52,000
So it is going to take some time till the entire installation of this particular library happens okay.

29
00:01:53,000 --> 00:01:58,000
And you always have to do this installation in your same environment, uh, where you are working.

30
00:01:58,000 --> 00:01:58,000
Okay.

31
00:01:59,000 --> 00:02:02,000
Now, uh, I'm going to use this load iris data set.

32
00:02:02,000 --> 00:02:09,000
This data set has four important features that is nothing but petal length, sepal length, petal width

33
00:02:09,000 --> 00:02:10,000
and sepal width.

34
00:02:10,000 --> 00:02:11,000
So I'm going to use that.

35
00:02:12,000 --> 00:02:17,000
Um so here let me just go ahead and create one of the function okay.

36
00:02:18,000 --> 00:02:22,000
Now inside this function I have written definition load underscore data.

37
00:02:23,000 --> 00:02:25,000
I'm going to initialize this load iris over here.

38
00:02:26,000 --> 00:02:29,000
This is going to give me my data set inside this iris folder okay.

39
00:02:30,000 --> 00:02:34,000
And then I'm going to convert this into a data frame just by writing PD dot data frame.

40
00:02:34,000 --> 00:02:36,000
And here I have given iris dot data.

41
00:02:36,000 --> 00:02:39,000
And the column name is iris dot feature underscore names okay.

42
00:02:40,000 --> 00:02:46,000
So uh, don't worry if you are not just able to understand this right now, because later on we'll be

43
00:02:46,000 --> 00:02:49,000
having this detailed discussion when we discuss about all the algorithms.

44
00:02:49,000 --> 00:02:52,000
But in short, this is my independent features.

45
00:02:52,000 --> 00:02:54,000
Uh, this is my feature name, right?

46
00:02:54,000 --> 00:02:57,000
All the feature names and this is my data that is available over there.

47
00:02:57,000 --> 00:02:59,000
Okay, then.

48
00:02:59,000 --> 00:03:00,000
Um, this is my target feature.

49
00:03:00,000 --> 00:03:04,000
That is nothing but DF of species that I've actually created, right?

50
00:03:04,000 --> 00:03:06,000
And then we are returning both this information over here.

51
00:03:06,000 --> 00:03:07,000
Okay.

52
00:03:07,000 --> 00:03:13,000
Let me make sure to write, uh, important decorator, which is called as SD dot cache.

53
00:03:13,000 --> 00:03:19,000
And, uh, I'm writing this so that, uh, every time we load this, uh, we should be able to save

54
00:03:19,000 --> 00:03:25,000
this entire data into the cache, and we not each and every time load this from this particular library.

55
00:03:25,000 --> 00:03:32,000
Okay, so here is my let's go ahead and call my DF comma target underscore name.

56
00:03:32,000 --> 00:03:35,000
So this I'm going to call it from my load underscore data.

57
00:03:35,000 --> 00:03:40,000
So I will just go ahead and write load underscore data function okay.

58
00:03:40,000 --> 00:03:46,000
Now uh I'll just give you an idea over here.

59
00:03:46,000 --> 00:03:49,000
Uh how I am going to apply the machine learning algorithm.

60
00:03:49,000 --> 00:03:55,000
So over here we are just going to apply model is equal to a random forest classifier okay.

61
00:03:55,000 --> 00:03:57,000
So I'm going to use this particular model.

62
00:03:57,000 --> 00:04:01,000
And this model will be requiring an input and output feature.

63
00:04:01,000 --> 00:04:05,000
So here in order to train I'll just go ahead and write model dot fit.

64
00:04:05,000 --> 00:04:12,000
And let me just go ahead and write DF dot Ilok which will be uh taking the independent.

65
00:04:12,000 --> 00:04:17,000
This is my all my independent features, and this is my output feature.

66
00:04:17,000 --> 00:04:17,000
Okay.

67
00:04:17,000 --> 00:04:23,000
So basically I'm just going to take in my x axis all my independent features, excluding the last feature.

68
00:04:23,000 --> 00:04:24,000
Okay.

69
00:04:24,000 --> 00:04:25,000
Last feature is my dependent.

70
00:04:25,000 --> 00:04:27,000
So last feature is nothing.

71
00:04:27,000 --> 00:04:29,000
It is the species.

72
00:04:29,000 --> 00:04:29,000
Right.

73
00:04:29,000 --> 00:04:32,000
So this basically becomes my independent feature over here.

74
00:04:32,000 --> 00:04:35,000
And this will basically become my dependent feature over here.

75
00:04:35,000 --> 00:04:37,000
So that is the reason I'm doing model dot fit.

76
00:04:37,000 --> 00:04:43,000
Now, uh, in order to select and make this diagram or make this application interactive, I'm going

77
00:04:43,000 --> 00:04:45,000
to use this st dot slider.

78
00:04:45,000 --> 00:04:50,000
And I'm going to use with respect to sepal length, sepal width, petal length and petal width where

79
00:04:50,000 --> 00:04:56,000
my values will be between min to max right whatever sepal length minimum is them whatever sepal length

80
00:04:56,000 --> 00:04:58,000
maximum is there I will be able to slide it okay.

81
00:04:59,000 --> 00:05:04,000
And uh I will take all these input data, whichever input data I select.

82
00:05:04,000 --> 00:05:04,000
Okay.

83
00:05:05,000 --> 00:05:08,000
I'll take the sepal length, sepal width, petal length and petal width in the form of list.

84
00:05:08,000 --> 00:05:11,000
And then we will do the prediction.

85
00:05:12,000 --> 00:05:15,000
So here in the next step we basically do the prediction.

86
00:05:15,000 --> 00:05:16,000
Okay.

87
00:05:16,000 --> 00:05:20,000
This is just to give you an idea uh what exactly we are doing.

88
00:05:20,000 --> 00:05:21,000
Okay.

89
00:05:21,000 --> 00:05:25,000
And one thing that you really need to see that okay.

90
00:05:26,000 --> 00:05:31,000
It's okay if you don't understand this, but because in the later stages we'll be able to understand

91
00:05:31,000 --> 00:05:31,000
it.

92
00:05:31,000 --> 00:05:35,000
But just I really wanted to show you the power of how an application will look like.

93
00:05:35,000 --> 00:05:36,000
Okay.

94
00:05:36,000 --> 00:05:41,000
So finally we will go ahead and write down all this prediction particular predictions and predictions

95
00:05:41,000 --> 00:05:42,000
pieces.

96
00:05:42,000 --> 00:05:42,000
Okay.

97
00:05:43,000 --> 00:05:45,000
So let's go ahead and execute it.

98
00:05:45,000 --> 00:05:48,000
So in order to execute it again I will just go ahead and open this.

99
00:05:49,000 --> 00:05:53,000
Uh you'll be able to see okay let me just execute this entire application.

100
00:05:53,000 --> 00:05:56,000
So I'll go ahead and write CD 14 Streamlit.

101
00:05:56,000 --> 00:06:03,000
And let me just go ahead and run this Streamlit run classification.py.

102
00:06:04,000 --> 00:06:09,000
So if I go ahead and execute this here, this is how my browser will look like.

103
00:06:09,000 --> 00:06:09,000
See.

104
00:06:10,000 --> 00:06:13,000
So this is getting loaded with respect to the data set that I have.

105
00:06:14,000 --> 00:06:18,000
So it says that hey SD dot cache is deprecated and will be removed soon.

106
00:06:18,000 --> 00:06:21,000
We can use SD dot cache underscore data.

107
00:06:21,000 --> 00:06:21,000
Okay.

108
00:06:21,000 --> 00:06:23,000
So let's go ahead and use this.

109
00:06:24,000 --> 00:06:24,000
Okay.

110
00:06:27,000 --> 00:06:29,000
So I will reload it.

111
00:06:31,000 --> 00:06:32,000
Okay.

112
00:06:32,000 --> 00:06:32,000
Perfect.

113
00:06:32,000 --> 00:06:35,000
Now see right now I have not selected any.

114
00:06:35,000 --> 00:06:41,000
Now let's go ahead and select my sepal length sepal width petal length and petal width.

115
00:06:41,000 --> 00:06:45,000
So here you can see my predicted output is versicolor.

116
00:06:45,000 --> 00:06:48,000
So this is the kind of plant that I'm actually getting right.

117
00:06:49,000 --> 00:06:55,000
Uh if I go ahead and change my sepal width again if I go ahead and change my petal length, if I go

118
00:06:55,000 --> 00:06:56,000
ahead and reduce my petal width.

119
00:06:56,000 --> 00:06:57,000
So see it is showing setosa.

120
00:06:58,000 --> 00:07:01,000
If I go ahead and increase my sepal length it is showing setosa.

121
00:07:01,000 --> 00:07:03,000
If I decrease my petal length.

122
00:07:03,000 --> 00:07:06,000
If I increase my petal width I'm getting virginica.

123
00:07:06,000 --> 00:07:08,000
So how beautifully.

124
00:07:08,000 --> 00:07:12,000
This is just like a machine learning application, which will be in the left hand side just by with

125
00:07:12,000 --> 00:07:13,000
the help of slider.

126
00:07:13,000 --> 00:07:20,000
You're using this, uh, and just by doing this automatically, your machine learning is able to give

127
00:07:20,000 --> 00:07:21,000
this right entire.

128
00:07:21,000 --> 00:07:25,000
Obviously, if you do not understand the machine learning algorithms, don't worry, we will be covering

129
00:07:25,000 --> 00:07:25,000
that.

130
00:07:25,000 --> 00:07:31,000
But the main intention of this particular video is just to show you the power of the Streamlit and show

131
00:07:31,000 --> 00:07:36,000
you that how beautiful this is with respect to showing the predictions, right?

132
00:07:36,000 --> 00:07:38,000
And here I did not write much HTML code at all.

133
00:07:38,000 --> 00:07:44,000
Uh, it was very much easy to probably, uh, display this entire things and, uh, this code that you

134
00:07:44,000 --> 00:07:51,000
see, uh, over here, uh, if we just see step by step, we have used components like slider, we have

135
00:07:51,000 --> 00:07:55,000
created this store cached data so that it it does not every time load this.

136
00:07:55,000 --> 00:07:57,000
Instead it takes the cashier data from there.

137
00:07:57,000 --> 00:07:58,000
With respect to the prediction.

138
00:07:58,000 --> 00:08:01,000
I have this and we are writing that prediction in the screen itself.

139
00:08:01,000 --> 00:08:02,000
Right.

140
00:08:02,000 --> 00:08:05,000
So yes, uh, this was it, uh, from my side.

141
00:08:05,000 --> 00:08:07,000
Uh, I hope you like this particular video.

142
00:08:08,000 --> 00:08:11,000
Um, I will see you all in the next video.

143
00:08:11,000 --> 00:08:16,000
But, uh, this is just an example with respect to the machine learning algorithms and how easily it

144
00:08:16,000 --> 00:08:17,000
will be able to display.

145
00:08:17,000 --> 00:08:18,000
Right.

146
00:08:18,000 --> 00:08:21,000
So yeah, I'll see you all in the next video.

147
00:08:21,000 --> 00:08:21,000
Thank you.

