Transcript for:
Creating Word Cloud in Python

hello everyone welcome back to the channel so in this video we are going to make a word cloud using the python Library word cloud okay so before starting uh you have to keep txt file in which you have to keep some 25 to 30 words in that and remember one thing keep that file in the same directory where your file has been created where you have created your file okay so let's get started with the programming so you have to import the word cloud module from that we have to import the word cloud class okay now one more thing if you guys have not installed the module then you can install the module by writing this pip install word cloud okay now after after that you have to import the matplot lib not P plot Library 2 because for doing the modification and for showing the W Cloud the W Cloud which will create using the wordcloud class for showing that class for the visualization purpose we have to use the matplot libp plot module okay so now we will read the file the file which we have created cl. txt in which the Ws we have stored so we will use the withth statement to read the file because the read statement because the withth statements close the file automatically and then one more thing one more parameter we are using that is encoding and we are giving the universal uni code that is utf8 which makes easier for the programming language just to read the read the files okay and we are giving an alas name file and now we'll create the text and in that we are going to read our file read out all the contents of our file okay now after that we are going to create a instance of our class W cloud and it is the instance of our Cloud class word cloud which we have imported here okay then there are some parameters also which we have to specify so there is width then there is height and then there is one background color tool background color we'll give the background color to white only and then we have to use one method or you can say you have to apply one method generate and in this generate we'll give the input the content which we have read in our file which we have stored in the text so that we will give as the input okay and now for reading this we will use the IM am show method and in this IM am show method we'll give the input the instance which we have created wordcloud and one more thing interp potion now this interpolation parameter the use of this parameter is it displays it gives the figure in a more polarized manner in and this bilinear is by default there are many more like B minear there are many more ways to display it so as you can see when I have run the code so some of the uh some of the words from here are getting read and then they are showing in this Cloud format okay now there are one uh some parameters more which we can apply and there is one paramet one method figure in that there is one parameter fixed size which is which is used to give the figure size in inches so I'll give 10 the width and five the height and then let's see yeah it's good now and after that I want to remove this axis x and y axis and this graph data so for that there is one more method AIS and we have to turn it off okay yeah it will not be e it will be I and yes now the exis have been removed and then we can use the PLT show method to show it more effectively yeah so as you can see it is so interactive we have formed an image of The Words which we have kept in our file and how precisely the image has been formed now one more thing here you can change there are many values there is one bilinear now bilinear is a default value then there is one nearest also which can be used this is the nearest uh the use of the nearest is that it is fastest but it results in Jack dages as you can so as you can see here the images the edges of the images are not clear okay then there is one by cubic also Now by cubic gives more smoother uh interactive images of the word cloud but it is bit slower also and then there are many more uh which uh which print different types of which has its own characters which print different types of images but these are the few and you can change the background color also to Black you'll get a black background image okay so this was how you can create a word cloud using an existing file how you can read the file and store the contents in the text then you can create the class an instance of the class then you can apply some parameters with height background color and then using the generate method you can pass the content of your file as a input and then for doing the modification and for the sewing the image which you have created you have to use this mat plot Li P plot library and some methods of that and yes there you go so I hope you like this video thanks for watching the video we'll see you in the next video