Visualizing Data using Python #machinelearning #visualization #python
Key Takeaways
The video demonstrates data visualization using Python, covering various techniques and tools for representing data in graphical forms to identify patterns and trends.
Full Transcript
uh welcome everyone in the another session of data okay this session is completely full of the actions and the learning part you can ask your any question in the q a sections if you have any question okay uh and those who are new here enjoying the first time in the data conversation I want to let them know that this data our session is completely uh series of webinar which is conducted by analytics with there so that they can teach you data sense in a fun way okay so you can visit our website for the more details or we will share the link in the chat box meanwhile I am going to handle the session to Mr Jess who is going to take this session forward he's the trainer for the today's session and uh today agenda is the visualizing data set using python okay so Jess will move further on this regard so hello I would like please introduce yourself to our participants hello hi all I hope everybody is doing fine having a good time learning great things can you please share the data set let me start the session you will automatically able to see which data set we are going to use so no need to worry and uh Jupiter notebook I will be sharing uh and even I will also share the link to the Jupiter notebook in my GitHub profile so you can also download it from there itself we will share all the details and all the links so stay tuned with us okay uh we will share all the details at the last okay so please uh just you can proceed forward can you enable my screen sharing please yeah yeah I I think it's provided uh just I think you can share the screen now yeah give me a second yeah okay so uh is my screen visible to all uh yeah and the code Snippets that are written uh that is also visible to all right or should I zoom it more okay great no so thank you so guys in this session uh we will be talking about plotting of data in Python right and why why we should upload the data what is the importance or what is the significance of plotting this particular data am I not Audible uh you are audible yes I can hear you yeah maybe then jockey you should check your speaker or something right so yeah uh in a in one of the previous session in data hours here in analytics Vidya itself uh I talked about ADA exploratory data analysis right so in Edith basically there are uh three major tools that we generally use in data science industry first of all two are numpy and pandas pandas basically used for data manipulation or making your data ready for your machine learning algorithm right and numpy is generally used for playing around the arrays or basically all the uh high level your all the high level libraries like tensorflow and pytorch all those works on numpy itself so this uh session is kind of in continuation with that particular session uh in this session we will be discussing about floating and visualizing the data right if I get that I got the data from my client or my customers now I have to develop a let us suppose now I have to develop a data analytics solution or you in that data analytics solution you can use anything a machine learning or deep learning right but before moving on to that particular part first of all you need to know about your data right because if you are not if you are not familiar with the data if you don't know about your data it will be in impossible no matter how powerful algorithm you are going to use it is impossible to find or create a solution so data visualization kind of comes uh into picture in the very initial step itself in our exploration data analysis step right and it is basically the representation of data using some of the common Graphics charts plots different different type of plots like loads pie chart uh or you can say heat map distribution plots all those things we are going to uh discuss in today's session and also with the plotting or with this data visualization you can also tell different types of stories that is related related in that particular data set right you can build a story between the features and Target the variables right features uh in machine learning uh language if we talk about features and Target value Target values the basically the value that we are going to predict by our ml or DL model right and feature values are the you are you can say are kind of input that we are going to provide to our model so by visualizing the particular data set we can tell different types of stories about these features and Target variables right and also you are able to uh communicate complex data relationship if some of the relationship is present uh in between uh different different features of your data set I guess someone has their hands up yeah subramaniam you want to talk or what is your question you can write in the chat box uh we can answer later right analytics which I will be able to provide so now if you guys have any question just put it in the chat box we will discuss that later in the session itself now let's start uh our session it's our Hands-On coding itself so first of all we will be talking about matplotlib the very basic Library used for plotting in Python all the other uh all the other libraries that are used nowadays for floating purposes just like your plotly or a Seaborn all those are built upon this matplotlib itself right so it is the first order you can say very basic library for uh plotting purpose that is present inside your uh python system so first of all we are going to import uh the libraries I am also importing numpy and pandas as I am going to use these two libraries also at a different different uh point in our session itself so I'm importing numpy pandas and met probably by plot splt and if you guys know this nppd and PLT these are nothing but Alias for these libraries so that if I have to call a certain function at a particular point I need not to write the complete name instead of writing the complete name I just can write NP PD or PLT and from that particular Library I can import a particular function that I need to use right so let's create our own data first of all that's why I said we are not going to use any CSV file or anything we are going to use our own data or some of the data sets that are present in C bone Library itself right so here in this particular line what I am doing I am creating a random points random normal points if you can say random I am using from numpy I'm creating thousand random points with uh and from those random points I am going to create a pandas data frame right whose index will be uh your date range starting from 7th of July 7th of June 2019 and again here I'm imagining that okay I want 100 dates right for these 100 different different data points and I am writing the name of that particular column as value let's see this particular cell and let's see our data frame how it's look like so if you see a standardized uh standardized normal distribution data has been created and that has fitted inside this data frame inside the column value and if you see the index of this particular data frame is nothing but the date range that I have provided starting from 7th of June 2019 and going till 1000 days so it is around uh second March 2022. so for if I want to visualize this particular value right I have thousand points I want to visualize this particular value what I can do inside your pandas itself there is this uh pandas floating that again is written upon matte plotly be itself right so you can just you need to just write the name of your data frame here it is DF right I just write DF and after that I have just used Dot Plot right and if you see the output you can see your data has been plotted here in in a particular fashion right so this is basically a simple line plot for your data points that are present inside your data frame now let's add one more column inside this data frame and let's name it comes sum so basically this will be cumulative sum of all the values what does this mean let's first of all see this particular uh DF again I have added this new column comes from by adding uh by using the com sum function of pandas now if you see the first value of your uh come some column is uh the initial value that is present at the first Index right now the second value will be the sum of first and the second value third value will be some uh some of these three values so in this way I kind of created a cumulative sum of all the previous values right this particular things we generally use when we are dealing with the time series data that's why also I have mentioned the index uh as the date range right so if you see on your x-axis itself it has taken the index of the data frame that is nothing but the date range and on the y-axis it is representing these particular value points right now what will happen uh because in this data frame there are two columns now there are two columns right one is value and other one is comes up now if I hit this particular cell or if I run this particular uh code what will be the output of this particular thing because initially there was only one uh one column present right so it automatically uh gave the plot of that particular column now if more than one column is present and if I run DF Dot Plot so it will plot all the values or all the columns uh in one plot itself so here you can see the blue one is representing your uh this value column and the orange one is representing your comes some volume uh come some value right and these two plots are kind of present in one figure itself right now if I want to see uh and from this particular thing itself you can also see that the range of chromosome is varying a lot it is from around minus 770 to 10. whereas our range of values will be in between minus three to three because we are we have just used a red and right here standard normal distribution now what if I want to uh use two different subplots for these two different values for doing that what you can do inside your df.plot function attribute you you need to pass your subplots uh subplots option as true and you need to pass the figure so you can also pass the figure size for example I want to uh increase the figure size of this particular plot so I am passing the figure size of 15 cross seven so 15 will be my length and 7 will be my width so now if I run this particular cell here you will see two different subplots are now present for each of the column I inside my data frame comes some uh is again different from this particular thing and by using figure size I am also able to increase the size of my plot right with other modules packages for floating life floaty and pipe plot is matloat libender for we should Master others uh if you are uh great with matplotlib itself there uh the other or the syntax of other libraries like plotly and cufflinks all the syntax kind of matches with the matplotlib itself so if you are uh good in matloat limb that is enough a Danish guitar and Anonymous can you explain how to plot using calendar I don't know which calendar you are talking about so yeah now uh moving on to the next thing so this was simple line plot right now there are other types of plots also present inside this pandas profiling or pandas plotting for example in this particular cell I want to I am plotting a histogram plot so for doing that what you can do you just need to pass this particular argument kind of argument as history so it will automatically uh python will automatically understand that okay this particular data frame is coming and uh subplots are true and kind of type of my plot need to be histogram so if I run this particular cell here you can see the histograms uh for both the both the columns comes summon value histogram is basically your plot of values versus frequency how how many times uh a particular number or a particular number from a range is repeating in your total data that is your histogram and by looking at the histogram you can also uh tell about the distribution of your data how your data is distributive right and many more or if you see this particular thing let's run an error many more uh I guess bar chart is also present inside this kind things it will take a lot of time because in floating parts are that will be seeing one of the num each of the numbers so it will take a lot of time promoting the bar chart yeah C bone can also be used right so here you can see bar chart for each number that is present uh inside our data sets itself has been created right and if you uh press shift tab here in this particular function you will see the dog string of this function and inside that you can see different different kind of plots that are present inside it so we have seen the histogram plot and our bar chart right now let's move on to the next part or let's see how PLT think that a metalloately blood type load I have imported as PLT how does that particular thing works right so for this particular thing first of all I'm importing C bone because there are some of the data sets some of basic data sets uh present inside that c board so I am going to use those particular data sets for this uh session itself so I'm importing C bonus SNS and from that c bone Library I'm unloading uh I am loading a data set of Iris ideas flowers that are data set so basically this Iris data set is of uh different different flowers and their sample length and petal length and bits all those things are present inside this Iris data set let's import this particular thing so if you see here uh this Iris dot hat is basically showing first five values from your data frame so safer length simple width petal length petal width and species these uh five things are present inside your iris data set that okay if the simple length is this particular thing simple width is this then what is this species and if you see let's see this particular thing else also Iris is this so three different type of species of flowers are present inside this data set your virginica vertical and cytosa and information about uh those uh information about those things present inside this particular data four times this model now forecasted statistical method which packages mostly used for time series model generally the stats model package is used or you can also use uh deep learning techniques like like RN and recurrent neural network code lstm those things but if you want to use a remand a simple statistical method then stats model package is good now let's again use our by default first of all see our by default plotting that is provided by pandas so here if I when I used Iris Dot Plot you can see the different different Columns of this Iris data set has been plotted our red is representing petal width green is our petal length orange is separate and blue is your sample length Now by seeing this particular data first of all first thing that we can see or get information about is about the range of your different data columns right for example this simple length if you see the sample length the range of your sample length varies from five to around 8 right and let's assume these are in centimeters so your sample length kind of varies from five to eight centimeter right and your petal width varies from one to ah zero to two centimeter only and if you see The Petal length here there is a a lot of variation in your petal length right it starts in the range of your petal lenses it is starting from around one and going till six right so this type of initial observation you can get by just visualizing the data right okay that what are the different different range of my uh different different columns right and how one column is correlated with other all those things you can get or you can understand about your data right and again we are using subplots itself so yeah we are plotting different different volume columns here now how to uh use plt.plot or uh PLT Library itself right so first of all I'm going to talk about line plot so for uh plotting a line plot if I want to uh plot two variables on x-axis for example on x axis I want simple length and on Y axis I want triple width and I want a light plot of them right so I can just use plt.plot function of your matplotlip plot function and inside that at the first argument I will pass the values that I want at my x axis so on x-axis I want triple length right so I have passed Iris triple length and on Y axis I want my sample width right so you can also say that this is a kind of a by bivariate analysis because we are using two variable here right simple length and Sample width and now when I am going to hit this particular cell here you can see a line plot has been created but it is kind of uh meshy right because different different points are kind of representing uh different points from this particular data frame so I am not able to kind of understand this particular approach so instead of light plot in this particular cell in this particular thing instead of line plot I can just use scatter plot itself right so instead of plot I need to use plt.scatter and when I'm going to run this particular cell you can see the scatters now here on the x-axis your sample length points are present and on the y-axis your sample weight points are present right there is not a direct relationship between these two so because but if you see there is a kind of little bit little bit not a lot little bit linear relationship right for if we see this particular cluster itself when my sample length is increasing my sample width is increasing right if you see this particular thing or give me a second let me connect right in order to look here so if you guys see here at this particular point there is a kind of a linear linear relationship right so all these things uh we can visualize in our initial stage itself right so this uh this is our scatter plot basic scatter plotter you can say points for visualizing uh by data for doing bivariate analysis right now same thing uh here we were visualizing the relationship between separ length and sepal width and in The Next Step I'm kind of seeing the plot between separate length and petal width right so this is again here we can kind of see our linear relationship type of thing right now what if I want to plot these uh both Scatter Plots in one figure itself for doing that what you need to do in oneself itself you first of all you need to uh you need to write the first uh scatter first plot that you want to plot right for here uh for example here in the first slide I have written that okay I need a scatter plot between simple length and simple width and in the second line I have written that I want a scatter plot in between separate length and petal width now if I'm going to run this particular cell you you can see that both the Scatter Plots are plotted in one figure itself write the but we don't know we don't know which color is representing which one right that particular thing comes in your beautification or all customizing your props that again we will come see in the next uh next few seconds but if I want to change this particular scatter plot into a line plot that particular thing oh sorry not line plot everything speed plot itself so that particular thing is also possible here so you can also plot different different kind of plots itself in one figure right this thing clear to all let me see some questions you could use a Better Business example for visualization yeah Nishant but this is kind of session for beginners I guess that's why I'm using these data sets again subramaniam this is for a visualization session but the question that you are asking that particular uh thing can be you can use psychic learn there is this SQL library that can be used right so let's move on now our next step will be beautifying the plots right we have made this particular plot but I am not able to see that what what is my XX is representing or what is my Y axis representing right and I also am not able to tell that what what are my orange points and what are my blue points so let's beautify our plots right so first of all we will start by labeling our x axis and y axis so what you can do this particular uh this particular two lines are similar to this particular thing now for enabling your x-axis we all know our x-axis is nothing but simple lens you can use plt.x label X label function that is present inside your mat flow clip you can use this plt.x label and just uh name uh just pass the name that you want to label on your x axis right so I'm uh labeling my x axis as sample length and in a similar way for labeling my Y axis I am using bits right because both of these things are bits one is sample width and other is petal width now when I'm going to run this particular cell you can see your XX is now simple then this particular thing is present and it's Apple width is present again you can customize it a little more by providing the color itself so for example I passed the color of my X label will be red and also you can also pass the size Itself by S okay so here you can see I I passed size argument as 20. so this x label has been increased right now uh our next step will be adding grids right for why adding grids so by adding rates it will kind of become easy to understand that okay when my point is 5 this particular what this particular point is representing is it around one or eight is it around 1.5 as this particular data set is a very basic one so we are able to tell that okay yeah this is around 2 or 2.5 but uh for a complex data set for for example you have a 2000 so ten thousands of rows in that particular thing you will not be able to directly tell from the plot itself so in those purposes grid also comes into picture so by adding rates you will be able to add the these vertical and horizontal lines right now in my next step I will be adding Legend to each of the legend is basically it will tell that okay what my orange point is representing and what my blue scatters are representing so for doing this what I'm doing in my scatter code itself I am adding that okay this supplement and Sample width the label of this particular uh scatters plot is my or this particular scatter points is separate length versus sample width and for the below one the label is my sample lens what's this petal width right these two labels has been added and apart from that I'm also adding this particular line PLT dot legend that will kind of uh let me first of all run this particular cell now this PLT dot Legend will add this particular information about your scatter points that okay your blue skaters are representing separate length versus separate and your orange points are representing separate lengths versus petal width right and this loc is basically your location where do you want a location of this particular boss right so uh currently I have written upper right but yeah okay if you remove this loc part itself so it will automatically place your location at the best point whichever sport is best for that particular location or uh whichever location is kind of hiding less number of points right now we have what we have done we have added grids we have added X labels y labels we have added Legends now let's change the size of plot because it is kind of a little bit smaller right so for changing the size of plot all the other commands will remain same but at the starting of your uh plotting itself you just need to write PLT dot figure and inside that you need to pass the figure size argument and here you can password whatever size you want to to see for example here I have passed 16 Cross 10 so 16 will be the length of my plot and 10 will be the width of my plot so here you can see right now let's change it a little bit because it is going on out of our screen so this is my 15 cross eight plot right now these things has done also you can also change the color of your scatter points and size of your scatter points itself you just need to pass these argument as representing your size say representing your color so I have changed the size of the first one to 25 and color to Blue and the size of the second one 250 and color 2 red here you can see a different different size and Guys these all things that we are doing these are kind of used for understanding the data data itself right so I'm just telling the basic things but when you have the real data and you know all these particular uploads or all these particular tricks and you are doing your ad exploratory data analysis part you will be able to get a lot of information from your raw data itself right now uh in the next part we are just adding the title for adding the title you can just use PLT dot title and I have added the title as simple length versus width and here you go your title has been also added and you can also kind of change the Styles uh styles of your clothing right this is your by default normal style inside your mat load clip there are different different styles available you just need to write plt.style dot available and it will uh give you a list of different different styles and ins from these particular Styles you can use any one of them for example here I am using my classic style for clothing so I'll just uh Define that okay plt.style dot use use the classic style and here you go this is your final product so we started from a very basic plot right from this particular plot and our end result of beautifying the plot is this particular thing right so we are clear till this point right is there any restriction on which color to use no there are no restriction you can just pass the hexagonal code of any color and you can use okay so this is our final course I'm also copy pasting this particular final code inside the chat box itself okay oh yeah pankaj is saying can you take one large data now and show no uh maybe in the last if we got some time I will take a large data set and show you some of the plots right but yeah before on before that let's move on go back to Styles here are your different different styles and this is the code for getting your styles right now let's see the line plot itself right because when we saw the line plot earlier for this particular data set that was kind of giving some messy things right so uh for this particular thing I I will be doing the same thing I will be beautifying the plot right but the data I am again creating myself for the x-axis I'm creating creating a numpy array Linear by using the numpy Lin space function uh I'm getting the address as starting from 0 till 4 pi and having thousand points right this particular cell is kind of creating your numpy area having thousand points starting from 0 to 4 pi y variable will be my sinusoidal curve of X sine X function Z variable will be my course function of that X right and all other things will remain same itself but instead of PLT dot scatter now we will be using plt.plot and here uh if you see above I used s uh attribute for assigning the size of scatter right now if you want to change the width of your line there is this LW line width of a attribute present inside your plt.plot function that you can use for changing the width of your lines right and again I think the idea this particular thing I uh copied from above itself let's change the title also science and course and on our next level will be let's say x values y label will be signed and close let's just hit this cell so here you can see your line plot itself right now uh you can also change your line floats also you can also uh kind of change the style of clothing for example this particular Blue Line this sinusoidal line instead of this sinusoidal line if I want kind of Dash lines or bash lines that particular thing you can also do for example in this line of code if you see plt.plot I am passing my X values and Y values and after that I am passing that okay I need this particular styling here right so if I run this particular cell here you can see your line has been converted into your dashed lines again depending on your business case or different different things you can use this particular customization in the plots itself right now uh coming on to our next type of plot that will be histogram as we discussed earlier itself so it will kind of give us estimate that how many time a number is occurred in a particular data and by that histogram itself you will be able to understand the distribution of your data right I'm not going in depth of the distribution because again that is again a different topic for different discussion there are different different distributions present so for uh for uh seeing or for visualizing the histogram of a particular data or a particular data column you can just use PLT dot hist function and inside that just pass that particular data set of which you want to see the histogram so here I am passing what is what is my distribution of simple length so here you can see the histogram of your sleeper lens so it is basically denoting that for this particular uh interval around nine points are occurring in my data sets for this particular interval around 20 24 points are occurring in my data set right and again in a similar way as we discussed uh earlier we can also plot two different figures itself we can also plot two different plots itself in one figure so here I am plotting the histogram of simple length as well as Peter length right again but I don't know which one has been which that thing you can uh do by adding the adding the label thing here and using PLT dot Legend right the same thing we can directly be done by using the data frame Itself by using df.plot over here my data frame name is Iris so Iris Dot Plot inside that just pass kind you can pass the kind that histogram okay so all the different different histograms of the columns that are present inside your iris data set are plotted in this particular figure that you can see again if you uh do the subplots as true here so you can see here different different plots also now you can also change the bin size so basically bins are these particular rectangles that are repeating right so if I represent bins as 100 I want 100 bins so here you can see uh business size has been changed so when we changed the bin size so when we increased the bin size your interval that we were taking earlier that has kind of decreased so it is kind of now showing that for a point from 0 to 0.1 let's assume this particular point is 0.1 around five points are present so in this particular way you can also change your PIN size itself and here let's change into thousand now more minute detail can be seen right so in this way you can play around with the histogram itself and again here I'm changing the bin size 200 and my subplots are true so different different subplots you can see here of histogram right great now next is our pie chart pie chart will kind of tell us that okay in a particular distribution or in a particular data how much percentage uh or for one thing is present for example let's see this particular data itself so what I am doing here I am doing I am kind of getting my first line from my this Iris data set by using dot I lock function right and first of all let's remove this particular thing then I will tell so if I say this data right here you can see my simple length simple width petal length petal width and species is setosa and here I'm using uh this till minus one because I don't want this pieces to be presenter when I am fast I am going to pass this particular thing inside my pie chart because that is going to throw me an error because if you see here Seto size your object type and all the other things are your numerical type right so we will not be able to uh kind of visualize that particular object in a pie chart itself right now when I'm going to hit this particular cell it will give me the percentage kind of percentage that okay if I add all these numbers in that particular thing we're going we are going to add all these number what percentage of my simple length is present right so if you see simple length is 5.1 and I am assuming that the sum of all these numbers will be around 10 so around 50 percent of my simple length is present in this particular data set right that's why you can see around the half half of my uh circle of the pie chart is of blue then simple width is 3.5 here you can see in this way you can kind of see the different different proportion of your data set right by using this pie chart our now our next plot uh will be box plot now this particular box plot is a stat statistical plot first of all we will be plotting this particular thing and then I will be telling what this particular uh box plot represents let me open my whiteboard itself so yeah so box plot basically your box blocks box plot will look like this particular thing so basically your box plot kind of gives you a hint about the statistics of our data for example let's assume uh let's assume I have a data X right or we can say this x is kind of age of students in the school age of students in a school right now if I'm going to plot a box plot of this particular X it will give me a statistical information about this particular X statistical information and what are those statistical information basically uh there are these five data points present inside your statistic statistics your minimum point your maximum point your median your first quartile or you can say 25 percentile and you're 75 percentile right by visualize by saying your box plot you will be able to tell that okay what is your minimum value for this particular data what is your maximum value and at what value 25 percentage of the data is line right this is that particular thing and what is the median of your data or you can save 50 percentile of your data is lying at uh which point and 75 percentile of data is lying at which point and by seeing this particular box plot itself you will be able to understand the distribution of your uh data now if this is a kind of symmetrical box plot so this will be kind of representing a normal distribution itself right and also in some data points or in some variables inside your data there will be some Outlets present right so those outliers will be uh visualized by these dot points that again we will be seeing uh in this session itself so those uh outliers will be represented by dot dot points in box plots and by visualizing the box plot itself you you can also uh Define or program a rule for removing these outliers before feeding it inside uh some machine learning algorithm or something right so here I am uploading a box plot of my uh petal length so here you can see your minimum value is around one maximum value is around seven and my median is lying uh in between 4.5 or something right and my 25 percentage of data is lesser than your 1.5 less assume it's 1.5 right and my 75 percentage of data is less than 5. so all these things uh you can visualize by how are the outliers Pro defined again the outliers that I just told you sorry yep that the outlets that I told you are in ideal condition but but again the outliers again will be dependent on your use case and problem statement itself the for example there can be a situation uh or there can be a variable again depending on uh depending on in which domain we are talking about right for like uh so let me give you an example in uh oil and gas industry itself right so we well let's take that uh let's take an example that we have the data foil for oil production from a particular well right and I am plotting that uh data in a box plot so there can be a chance that it it can show that okay there there can be a chance that oil production from a well is zero right but box plot will be able to tell me that okay this zero point is outlier because it is not lying in the normal distribution itself but if you are a petroleum engineer or any engineer or whatever domain we are talking about you know that okay yeah this particular value variable can take this value my oil production can take zero value so it is not an outlier you know that but your box plot can show that okay this is an outlet that's why uh this Outlet there is no such definition of outlet that completely depends on your use case as well as in which domain we are talking about how can yeah Jupiter notebook will be shared with you now uh our next upload is scatter Matrix so this particular plot is used for doing the comparison of the all the data inside your data frame right so uh skaters of different different features will be plotted and histogram for the same feature will be plotted so first of all from pandas dot plotting I am importing this scatter Matrix function right or I have already imported a pandas SPD so I can just use this pd.plotting.scatter Matrix inside that just pass the data frame uh for which scatter Matrix you want to plot past the figure size color and Alpha Ali Alpha value will kind of give me that how much damage in the points I want so here you can see this is your particular scatter Matrix so by looking as at this plots you can just see the visualize the relationship between different different variables if we see this petal length and simple length so simple length is increasing with petal length right here you can visualize this particular thing again Peter length is increasing with petal width itself so all these things you can visualize with this character Matrix and on the diagonal thing for the same uh for example this separ length versus separate length you can directly see the histogram itself so instead of plotting uh different different clothes all these things can be visualized in one plot States one plot Itself by using this scatter Matrix you can write your question in the chat box uh no need to worry spring I will post the link of the notebook from my Gateway itself in the chat book later on the session now there this was kind of basic clothes now the next thing that comes into picture is dynamic floating right so these are static plots right nothing is moving and kind of static itself now there can be a scenario there can be a use case for you for example there is some variable that is changing right let's take this example itself here so uh here what I'm doing I'm importing this interactive function from IPI widgets so these I Pi widgets is a library by default that is by default present inside your Jupiter kernel itself right from that Library I am importing this iterative function right and what I am doing here here I am writing a function which name whose name is power and inside that uh argument of annual pass right and what will this function do this will basically uh first of all it is making a points between minus five to five and it is making 100 points let's take hundred points between minus five to five and uh it will calculate the uh value of y at nth power it will calculate the value of y as x to the power n here if you see I am telling that okay my Y is equal to x to the power n right and after that it is doing nothing but a plotting uh my Y X versus y right and from this function I am taking the return of X and Y now what I can do I can make this particular thing Dynamic how by using this interactive function so I just need to write this interactive here and inside that interactive function I just need to pass the function which I want to make Dynamic so I want to make this power function Dynamic right this power function so I passed power here and after that I just need to pass the values often or value of arguments here and is my argument right what values this n can take so I have passed that okay it can take the values from 0 to 8. now right now when I'm going to run this particular cell and when I'm going to run this W here you can see your Dynamic plot has been created now when I'm going to change this and your plot is changing for n to the power 0 when n is 0 your Y is X to the power 0 right and it will be a straight line all values will be corresponding to 1. when n is one you know uh y will be Y is equal to x to the power 1 right at the straight line here y equal to X when n is 2 y equal to x square X Cube x to the power 4 5 6 7 8 and one more catch one more thing here you not only one argument you can pass multiple arguments itself for example I am also passing M here and that M will be added inside this uh y function itself and let's also give the value of this particular M from let's say 10 to 20 now if I'm going to see W so there will be two different different uh two different uh things for n m right two different cursors so you can play around again this particular thing you can use in your different use case or in your different application itself right no it is not advisable to always remove outliers before you are sure that okay this particular thing is outlier right again that will not be uh not only with the data visualization thing uh but with domain knowledge also you need to tell that okay if a particular point is on outlier or not that's why I always always say data science is just a tool it's not a complete domain right data science is just a tool that you can use to solve different different problems in different different domains you need to uh have the domain knowledge for for the problem statement that you are solving okay what else yeah great great example Josh with the dynamic at this particular Dynamic plot you can see which occurs bat fits better at your data Ankit again this is for uh this session is kind of for plotting itself if you want to know about outliers treatment we can again connect offline I will provide my uh LinkedIn details later in the session right now let's come to our next part or our final part of this particular session that is C bone Library again this C bone is python data visualization library that is built on your macro Libya itself but it kind of provides a high level interface right for getting some of the statistical information about your data and again we were using the sabon data sets itself so for seeing all the data sets that are present inside your C board you just need to write sns.get data set names so these are some of the basic data sets that you can use for practice practicing around initially in the in your initial phase of learning right so here uh for my next step I am using the tips data set from the C bone itself so this this data set is basically the data set for different different uh value of tips given by people on a total bill and what was the sex of those people and what was they smoker or not and what was the day and whether they had dinner or lunch and how many member uh of their family or how many people have gone in that particular restaurant so this is this tips data set is basically a data set of a restaurant uh kind of showing different different tips now one of the use case that you can do from this particular thing is uh by using machine learning you can estimate that what will be the tip if uh what will but what will be the tip depending on the total bill sex smoker day time and size right so now let's do some visualizing thing first so our first plot in C bone will be rail plot again you can say that this Rel plot is nothing but the scatter plot of C bone right it is a fancy brother or fancy cousin of uh scatter plot that has went to U.S and however we can use this cell plot we can see so just write sns.rel plot again on my x-axis what do you want on Y axis what do you want right for for here I want on x axis total bill and on Y axis tips so here you can see on x-axis is my total bill on Y axis is tip again or linear type of relationship you can visualize but what happened in scatter plot was you will you were only able to uh do a bivariate analysis right but in Rel plot you can use multivariable you can kind of visualize multivariate analysis how for example here I can add one more thing Hue that is kind of that is kind of representing the color of this particular points and I am saying that okay my Hue will change with time right and now if I run this particular cell here you can see my time is lunch and dinner my blue points are representing that okay uh this particular point is representing for the lunch time and the bill was around 35 and Bill uh tip was around 5.5 or 5.6 something right so I have added one more variable here in the visualization right earlier it was only total bill and tip but I have added a time itself time also that okay so the people who has given this particular depend total bill was having dinner or lunch now I can also add one more variable by using this style input here I am passing that okay my style of this particular pointers need to change with uh the whether the person is smoker or not right and also this part in the from this particular thing you can uh see this thing that okay the bill uh that maximum tip is from the maximum build itself right the person who had the maximum tip has given the mag has the maximum bill has given the maximum tip and that guy has arrived during the dinner right here what I have added I have added that whether the person is smoker or not so here you can see the style of points has been changed depending on that person is smoker or not if that person is smoker then your uh scatter will be around and if he was not a smoker he or she was not a smoker then it it will be a cross so if I see the maximum bill was paid by a smoker and here here I have changed with the day right and he has came on Saturday and from the above uh graph I noticed that he has came for the dinner so three information by just visualizing the plot itself maximum tip we were given by the maximum Bill guy and he was a smoker and he came on Saturday for dinner right in this way you can build the story around your data by visualizing uh visualization itself so this was the fancy scatter plot of our C board now coming next our next plot is Count plot so basically it will kind of just give me the count of the different different variable so for example I'm using the account load for getting the count of my sex type or how many total number of males and females are represent inside that particular data so here you can see around 160 uh mail over there and around 80 to 90 females were there right in a similar way you can also point out that what is the percentage of smokers and non-smokers by using this corn plot itself right so around 90 to 90 we were smokers and 151 non-smokers you can also visualize tips right for different different days that okay now what were the tips given at a particular day right so from this particular thing you can see that last number of people has came on Friday right so in this way your account load can be used now our next thing is uh what how to do uh analysis between categorical and numerical values right so for that categorical plots come into picture so for example here I'm doing a analysis between my day that is your categorical value and uh another variable is my total bill that is my numerical value right so from here you can just see the the it has kind of plotted the total bill versus days right that okay on Thursday the maximum number of Bill was around or maximum amount of bill was around 42 on Saturday maximum amount of bill was around 51 on Sunday maximum amount amount of bill was around uh 49 and 48 something like that so in this way you can kind of visualize or you can get a relationship between your categorical as well as numerical value categorical versus numerical version by using this categorical clocks right and here again I am doing the visualization uh with respect to Smoker versus total bills right so next uh next plot is box plot from our C bone the value Basics box plot we had already seen from our matplotlip that was kind of a very basic point right the seabond uh kind of pro again provides some of a more functionality in this box plot right so first of all I'm going to see a simple box plot of tips 10 days so I have passed two variables days and TP itself right so on the x-axis is day and on Y axis is my tip value so it is kind of uh telling me the distribution or telling me the sorry telling me the statistical approach or minimum maximum or median all those values for different different days tips now you can say that okay these particular things are outliers right from visualization you can say but again whether they are outliers or not that completely depends on your use case right so in this way you can use your box plot so in C board what different functionality is there that okay for each uh different day or for each different categorical value you can also plot a box plot for your numerical value and here one more thing I can add that is Hue again my color that my Hue is changing with respect to sex so here if you see with respect to day itself as well as with respect to whether a guy is male or female we are again able to see the uh distribution of our data right so if you see this particular thing on Thursday females the median of female tips is kind of lower than the male tips on Friday median of the female tips is kind of higher than the male tips right so in this particular way you can kind of again get to some informations about the data from using this box plots itself now a joint plot this is kind of scatter metric Matrix itself of Seaborn right but it will only give you uh it will only give you a scatter scatter plot and histogram for one variable or for two variables only right so again it is my tips value right I am using SNS dot joint plot here so here you can see uh these particular things are my distributions of tips this particular thing is the distribution of tips and this particular thing is distribution of total bill and here in between is your scatter plot so this joint plot is nothing but a combination of your scatter plot and histogram right and this pair plot is your complete that particular thing that we already see earlier histograms for the same values uh and scatter plot for the different different variables now the last thing that comes into picture you can also fit a regression line for data points by using a c bone library right so inside C bone Library there is this LM plot that will fit a regression line for your data points so you can also say that kind of uh doing a small linear regression type of project by using C bone only no need to use psychic learn or anything you just need to pass the use the sns.lm plot whatever things you want at x-axis which thing you want at Y axis right and data I am just passing that I am using tips data so if I'm going to run this cell here you can see it has kind of floated a regression line itself between my total bill and tip and by seeing this particular regression line you can just tell that okay what will be the value of my tip when my total bill is this a simple linear regression application by using plotting only nothing else right so here I have just used tips and uh total bill itself again you can also do it by day wise itself for example here I have passed that okay column uh I want this so for different different days you can upload different different linear regression types that okay if a guy is coming on Thursday and his total business is 40 so his tip will be around 6 rupees if he is coming on Friday then it it is around 4.5 rupees in this way by using one more variable itself you can kind of do this particular regression thing so yeah guys uh that's all from my side uh basic or brief introduction to floating again first of all let me share this particular notebook to you guys so it is present at my in my GitHub repository and the previous notebook is also present in this particular uh repository itself this one is from the my previous session from numpy and pandas it's loading it's kind of heavy a little bit heavy this is from my number and Panda session notebook and for this particular session is this notebook pasting it in the chat box and this is my GitHub profile if you want to see more projects or more things uh kind of maintain different different repositories you will get to know about all the repositories I have a complete petronum by course itself and also if you want to go as this session also for uh one hour itself if you want to go a little bit in more detail if you like this particular session you can also subscribe to my YouTube channel petroleum from scratch here itself I kind of teach different different data science things or different different data science algorithms plotting and all those things statistics ah so you can also subscribe to my channel also I'm also sharing this link and for connecting me on my LinkedIn this is my LinkedIn profile I hope you guys enjoyed the session itself and all these details are again itself present in this notebook itself right thank you very much I really enjoyed the conversation even I'm also a learner and I am learning teach all things and I really emerged by seeing the concept you are taking about outliers and notifying the concept of the graph so I really Imagine by using your way of teaching and I hope the our audience also enjoyed your session and we will conduct such more sessions with you for the coming uh working uh coming page okay yeah okay thank you and guys it is the time for the question answers you can post the question answers yes uh yes uh meanwhile we have some questions in the Q a sections uh yeah I will see that give me a second already okay uh someone is asking the plots are not there right because uh when I uploaded this file if you see I want to run the cell if you download this particular cell and run in your local system or on your collab system the plot will kind of appear so no need to worry about that it's just code or code things floats are not present there if you want me to upload this particular thing also that I can also upload it give me a second plots um okay so the uploads file has also been uploaded let me share the link to this sources and here are all the links I'm just pasting all them together yeah now let's see the question answer session is it advisable to always remove our player before using data to build models I already answered it ah again depends on your use case would you advise normalizing or standardizing your data set to annul the effect of outliers and normalize the data set again you cannot directly say that by normalizing or standardizing uh we'll kind of funnel the effect of outliers it will not please explain the data equal to tips variable okay so what happens in C bones let me come to here so what I am doing I am using this plot right sns.lm plot or any plot let's take example of which one okay let's to take the example of that one itself so one thing is whether I can pass that okay X is equal to my tips column of my tips data set total bill and again here Y is my tips uh column of my tips data frame right and call uh here SQL is my again that particular thing right one way is doing this or other way is just pass the value of x and y's that okay my X will be this column and Y will be this column and data is I'm I'm using tip uh tips data Frame data how to scale the y and x axis variables in the plots I am not able to understand these questions there are for scaling a particular data frame there are midnight scaling and standard scaling present inside your scikit library that you can use but you why you want to uh scale uh at the first place itself or in the first phase itself yeah idea deals with outliers and data pre-processing but your first phase will be understanding the data right you will you will know that okay what what is the range of my data set if I do uh the scaling at the first phase itself how would I know that okay this particular uh feature from my data frame is ranging from which value to which value foreign okay then share LinkedIn link I already shared all the links let me copy paste it here okay then I guess there are no more question left it was a great session guys I hope you all enjoyed it thank you very much really I enjoyed your sessions and I hope thank you participants also enjoyed your session we will meet you in the next session okay thank you all okay thank you have a good day happy learning bye
Original Description
Data Visualization refers to the representation of Data in the forms of Graph, Charts, Lines etc. It makes the process of analyzing and identifying patterns, trends and outliers in large data sets Easy. It helps us to understand the data and draw insights from.
In this DataHour Jaiyesh will explain how data visualization is done using python. He will elaborate on the most important library of python which is used for visualization, Matplotlib. He will also cover how to create static plots, how to beautify plots, all about dynamic plotting with examples and then seaborn plotting will be discussed briefly.
🔗 More action pack session here: https://datahack.analyticsvidhya.com/contest/all/
Stay on top of your industry by interacting with us on our social channels:
Follow us on Instagram: https://www.instagram.com/analytics_vidhya/
Like us on Facebook: https://www.facebook.com/AnalyticsVidhya/
Follow us on Twitter: https://twitter.com/AnalyticsVidhya
Follow us on LinkedIn:https://www.linkedin.com/company/analytics-vidhya
Playlist
Uploads from Analytics Vidhya · Analytics Vidhya · 29 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
▶
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
The DataHour: Data Science in Retail
Analytics Vidhya
The DataHour: Anomaly detection using NLP and Predictive Modeling
Analytics Vidhya
The DataHour: Energy Data Science Project from Scratch
Analytics Vidhya
The DataHour: Explainable AI Need and Implementation
Analytics Vidhya
The DataHour: Google Cloud AI/ML
Analytics Vidhya
Prediction to Production in Machine Learning #machinelearning #prediction
Analytics Vidhya
Practical Applications of Data science in Ecommerce
Analytics Vidhya
How to tackle Overfitting?#machinelearning #overfitting
Analytics Vidhya
Building Data Pipelines on GCP #googlecloud #datapipelines #data
Analytics Vidhya
Hands-on with A/B Testing #abtesting #datascience
Analytics Vidhya
Efficient Implementations of Transformers #transformers #cnn #machinelearning
Analytics Vidhya
Modern Deep Learning Architecture #deeplearning #architecture #deeplearningtutorial
Analytics Vidhya
Key steps for Designing Artificial Neural Network (ANN) for Image classification #machinelearning
Analytics Vidhya
5 things you should know about Azure SQL #azure #sql #datahour #datascience
Analytics Vidhya
AI & ML in the Automotive Industry #machinelearning #ai
Analytics Vidhya
Building Machine Learning Models in BigQuery
Analytics Vidhya
NLP aspects in Telecommunication Industry
Analytics Vidhya
Practical Time Series Analysis
Analytics Vidhya
Fundamentals of Quantum Computing
Analytics Vidhya
A DAY IN THE LIFE of a Data Scientist (From waking up to working on algorithms)
Analytics Vidhya
Classification Machine Learning Model from Scratch
Analytics Vidhya
Knowledge Graph Solutions using Neo4j
Analytics Vidhya
Model Guesstimation (MLOps)
Analytics Vidhya
ETL Pipelines in Google Cloud Platform
Analytics Vidhya
Key steps for Designing Convolutional Neural Network(CNN) for Image Classification
Analytics Vidhya
Getting Started with AWS EC2 #amazon #aws
Analytics Vidhya
How to Use Azure NLP and Graph Databases for Intelligent Knowledge Mining
Analytics Vidhya
Certified AI & ML BlackBelt Plus Program #shorts
Analytics Vidhya
Visualizing Data using Python #machinelearning #visualization #python
Analytics Vidhya
DCNN for Machine RUL Prediction using Time-series Data #timeseries #machinelearning #datascience
Analytics Vidhya
M in ML stands for Math & Magic
Analytics Vidhya
An Unsupervised ML approach using Clustering
Analytics Vidhya
Customizing Large Language Models GPT3 for Real-life Use Cases #gpt3 #datascience
Analytics Vidhya
Model Parameters vs Hyperparameters - Techniques in ML Engineering #machinelearning
Analytics Vidhya
Practical MLOps #mlops #datascience
Analytics Vidhya
Data Engineering with Databricks #dataengineering #databricks
Analytics Vidhya
Multi-Objective Optimisation
Analytics Vidhya
When Airflow Meets Kubernetes
Analytics Vidhya
AI in Banking
Analytics Vidhya
Learn Convolutional Neural Network for Image Recognition
Analytics Vidhya
Extracting Value from Data
Analytics Vidhya
How to measure Marketing Channel Effectiveness
Analytics Vidhya
Transforming Lives | Data Science Immersive Bootcamp
Analytics Vidhya
Stock Market Analysis - AI driven approach
Analytics Vidhya
Become a Data Engineering Professional in 2022 | Future Trends + Skills Required
Analytics Vidhya
Ensemble Techniques in Machine Learning #machinelearning #ensemble #datascience
Analytics Vidhya
The Power of Visualization | Tableau Full Course | Analytics Vidhya
Analytics Vidhya
Demand for Data Engineers is on the Rise | Data Engineer | Analytics Vidhya
Analytics Vidhya
Data Visualization in Data Science | DataHour | Analytics Vidhya
Analytics Vidhya
Role of Optimization in Machine Learning & Deep Learning | DataHour | Analytics Vidhya
Analytics Vidhya
Solving any Machine Learning Problem | Approach and Steps Involved
Analytics Vidhya
Topic Modeling Explained with Implementation | Using LDA in Python | DataHour by Arpendu Ganguly
Analytics Vidhya
Data Engineering in E-Commerce | The Best Case Study
Analytics Vidhya
Introduction to Classification using Azure Machine Learning | DataHour | Analytics Vidhya
Analytics Vidhya
Introduction to Federated Learning | DataHour | Analytics Vidhya
Analytics Vidhya
Diffusion Models for Generative Arts | DataHour | Analytics Vidhya
Analytics Vidhya
Master Google Analytics in 1 Hour | DataHour | Analytics Vidhya
Analytics Vidhya
Learn Hypothesis Testing | DataHour | Analytics Vidhya
Analytics Vidhya
A Practical Approach to Kaggle Competition | DataHour | Analytics Vidhya
Analytics Vidhya
Making AI work for Business | DataHour | Analytics Vidhya
Analytics Vidhya
More on: Python for Data
View skill →Related Reads
📰
📰
📰
📰
Power BI for Beginners: Complete Learning Roadmap to Become a Data Analyst
Medium · AI
How People Counting Software Helps Businesses Understand Customer Traffic
Medium · AI
Data Science Interview Questions: The Complete Prep Guide (2026)
Medium · Data Science
Why Netflix Rarely Feels Random: The Data Journey Behind a Personalised Recommendation
Medium · AI
🎓
Tutor Explanation
DeepCamp AI