Violin plots EDA Lecture 12@Applied AI Course

Combining Histograms and PDFs with Violin Plots

You may think that we have seen histograms and PDFs, as well as box plots, each with their own advantages and disadvantages, so why don't we actually combine both these plots to get the best of both worlds? A plot that combines both of these is called a violin plot. The name "violin" might be considered melodramatic, but it's a very simple idea that is very useful.

Violin plots are very simple to draw using your Seaborn. It's just one line command similar to what we saw earlier, except that you have to say while in plot. Let's look at the plot and see what it is and how it works for us again as usual. We have our set over here, we have our versicolor here, and we have our virginica here.

A violin plot looks like this, which resembles a violin playing a melody, right? It has both the components. Let's see how it works so what it's doing literally is this black thick black area okay. You can change the color of this thick black area that you're seeing to your box pot box right, which is your box plot. This is your box plots box right with the white color in center being your 50th percentile the top corner being your 75th percentile the bottom one your 25th percentile and these are your whiskers.

So, it actually internally has box plots so here this is your 50th percentile 75th percentile 25th percentile your lower whisker and upper whisker. Similarly, here the median 75th 25th lower whisker upper whisker so your violent plot already has your box plot inside it. Then you might ask what is this plot that you're seeing on the sides again. This is symmetric to this right.

So if you just turn around and look at it like this look at it like this this is nothing but this this looks exactly like your bell curve right so this also looks exactly like your bell curve. So, what does a violin plot do? It takes both your density plots or your histogram on the side right and merges them into a single block.

Violin plots are useful because they give you the best of both worlds. You know what the distribution looks like because from this diagram I know that the distribution looks like a Gaussian Gaussian distribution again those of you who don't know what a Gaussian distribution is please don't worry but some of you who might have encountered this in your probability class this looks like a bell curve right so we'll discuss this.

I promise you we'll discuss this in great detail when we learn basics of from built-in statistics okay so but it also has your box plot so it has the best of both worlds and you can read off this one the 75th percentile value was the 25th percentile value is.

"WEBVTTKind: captionsLanguage: ennow you might say that we have seen we have seen histograms and PDFs and box plots right of course both of them have their own advantages and disadvantages so why don't we actually combine both these plots and get the best of both worlds such a plot is called a violent plot why the name is is very melodramatic it's a very simple idea and it's a very useful one I really like these plots because it gives us the best of both worlds very simply so again violent plots are very simple to draw using your Seabourn it's just one line command very similar to what we saw earlier except that you have to say while in plot right so let's look at the plot and what it is and how it works for us again as usual we have our set over here we have our versicolor here and virginica here a violent plot looks like this looks like a while in red like somebody playing a violin right so it has it it has both the components so let's see let's see how it works so what it's doing literally is this black this thick black area okay let you change the color here this thick black area that you're seeing is your box pot box right this is your box plots box right with the white color in Center being your 50th percentile the top corner being your 75th percentile the bottom one your 25th percentile and these are your whiskers right so it actually internally quantity has box plots so here this is your 50th percentile 75th percentile 25th percentile your lower whisker and upper whisker similarly here the median 75th 25th lower whisker upper whisker so your violent plot already has your your box plot inside it then you might ask what is this plot that you're seeing on the sides again this is symmetric to this right so if you just turn around and look at it like this look at it like this this is nothing but this this looks exactly like your bell curve right so this also looks exactly like your bell curve so what violent plot does is violent plot towards the probability distribution functions or probably density function sorry or your histogram on the side right it's actually so if you turn your head a little and see them what you see is your setosa distribution your versicolor distribution and you're watching Macca's distribution so your violent plot is basically taking both your disturb your density plots or your histogram your smooth histogram which is your probability density plot and just taking your your box plot and merging both of them into a single block and of course this is this is again useful because it gives you the best of both worlds you know what the distribution looks like because from this diagram I know that the distribution looks like a Gaussian Gaussian distribution again those of you who don't know what a Gaussian distribution is please don't worry but some of you who might have encountered this in your probability class this looks like a bell curve right so we'll discuss this I promise you we'll discuss this in great detail when we learn basics of from built in statistics okay so but it also has your box plot so it has the best of both worlds and you can read off this one the 75th percentile value was the 25th percentile value is and typically I would prefer to do either box plot or or sometimes a volume plot because it gives us the best of both worlds very very simple and elegant ideanow you might say that we have seen we have seen histograms and PDFs and box plots right of course both of them have their own advantages and disadvantages so why don't we actually combine both these plots and get the best of both worlds such a plot is called a violent plot why the name is is very melodramatic it's a very simple idea and it's a very useful one I really like these plots because it gives us the best of both worlds very simply so again violent plots are very simple to draw using your Seabourn it's just one line command very similar to what we saw earlier except that you have to say while in plot right so let's look at the plot and what it is and how it works for us again as usual we have our set over here we have our versicolor here and virginica here a violent plot looks like this looks like a while in red like somebody playing a violin right so it has it it has both the components so let's see let's see how it works so what it's doing literally is this black this thick black area okay let you change the color here this thick black area that you're seeing is your box pot box right this is your box plots box right with the white color in Center being your 50th percentile the top corner being your 75th percentile the bottom one your 25th percentile and these are your whiskers right so it actually internally quantity has box plots so here this is your 50th percentile 75th percentile 25th percentile your lower whisker and upper whisker similarly here the median 75th 25th lower whisker upper whisker so your violent plot already has your your box plot inside it then you might ask what is this plot that you're seeing on the sides again this is symmetric to this right so if you just turn around and look at it like this look at it like this this is nothing but this this looks exactly like your bell curve right so this also looks exactly like your bell curve so what violent plot does is violent plot towards the probability distribution functions or probably density function sorry or your histogram on the side right it's actually so if you turn your head a little and see them what you see is your setosa distribution your versicolor distribution and you're watching Macca's distribution so your violent plot is basically taking both your disturb your density plots or your histogram your smooth histogram which is your probability density plot and just taking your your box plot and merging both of them into a single block and of course this is this is again useful because it gives you the best of both worlds you know what the distribution looks like because from this diagram I know that the distribution looks like a Gaussian Gaussian distribution again those of you who don't know what a Gaussian distribution is please don't worry but some of you who might have encountered this in your probability class this looks like a bell curve right so we'll discuss this I promise you we'll discuss this in great detail when we learn basics of from built in statistics okay so but it also has your box plot so it has the best of both worlds and you can read off this one the 75th percentile value was the 25th percentile value is and typically I would prefer to do either box plot or or sometimes a volume plot because it gives us the best of both worlds very very simple and elegant idea\n"