‫Welcome back.
‫And so we've done a whole bunch of plotting so far.
‫And don't worry if you're sort of a little bit confused at the moment, like you're like, Daniel,
‫show me all these plots.
‫I'm looking at different data sets.
‫Well, how am I going to remember all this?
‫It's all right.
‫That's perfectly fine to feel like that.
‫It's going to take a little bit of practice to start to understand different kinds of plots, what you
‫should use, which plot?
‫Four.
‫But that's all part of the process, right?
‫It's just having a little practice, having a go and just trying it out, seeing what it looks like.
‫Does this make sense?
‫So that's why in this video we're going to do a similar plot to what we've just saw on before on the
‫car sales data set, on another data set.
‫Let's try on another data set and if we come up here.
‫We've got heart disease, HSV, which we've seen before, which is a data set which has different parameters
‫of patients and whether or not they have heart disease.
‫So let's import that as PD, read CSV, as we're going to call it, just heart disease.
‫And so we'll go.
‫Heart disease dot C is very beautiful.
‫Now we'll have a look at it just to make sure we know what's happening.
‫Well, I'll give you the first five rows because it's about 300.
‫And this one.
‫Excellent.
‫We have these parameters.
‫We've seen them before and we've got a Target column right on the end.
‫So what we might do is create a histogram just to see the distribution of the age column.
‫So heart disease.
‫Age.
‫Dot plot Dot hissed, and we might just see the default number of bins.
‫Can you remember how many that will be?
‫Shift tab bins is going to be ten.
‫Beautiful.
‫So we'll just leave it at that.
‫Okay.
‫So this is where we're starting to see that curve, right?
‫This is that normal distribution.
‫It's very common.
‫So we're kind of getting that curve here.
‫We would say that most of the patients are around.
‫It's this line here.
‫So maybe late fifties, early sixties, thereabouts.
‫So what if we change the number of bins?
‫So let's go.
‫Bins equals 20.
‫Okay.
‫We're starting to lose that curve shape a little bit.
‫30.
‫Still relatively there were definitely starting to see this more pronounced line here right at the late
‫fifties there.
‫Gregory Jacques it up to 50 and see what happens.
‫All right.
‫So that shape is still relatively there.
‫Our initial shape that what we got from just having ten bends is kind of consistent the whole way through.
‫And maybe we'd look at this and go, okay, this one's a bit of an outlier.
‫These are a bit of an outlier.
‫Why are they outliers?
‫Well, because they're so far from the middle.
‫When you hear the word outlier, that's kind of what it's talking about.
‫In statistic terms, it's about more than three standard deviations away from the mean.
‫Now, of course, that definition will change depending on what data you're working with, but this
‫is kind of a way that you can visualize it.
‫So let's take that back to ten.
‫That looks pretty good.
‫All right.
‫Now, these kind of visualizations are the things you'll do whenever you deal with a new data set.
‫Let's finish.
‫We have this one more type of plot we haven't looked at directly from a data frame that's subplots.
‫So we'll finish that off.
‫We'll go heart disease.
‫Don't head.
‫Okay.
‫This is our data frame.
‫Now let's plot every single columns.
‫Histogram in one plot.
‫Let's see how we would do that.
‫Heart disease.
‫So we've got the age histogram here, but let's just make one for all of these and check the distribution
‫dot plot dot hist.
‫So remember this is just going straight from the entire data frame up here.
‫We selected the age column.
‫Don't haste and maybe we want subplots equals true.
‫Does that make sense?
‫Because we want to put it all on the one plot.
‫Key word.
‫So that's part of that.
‫Maybe if we could read down a little bit.
‫Examples.
‫So this is one of those scenarios where if you wanted to use this hist method and have it all in one
‫plot because the docstring doesn't really have an example of putting it all with this subplot, this
‫would take a little bit of research, so you might look up a question like how to plot a histogram on
‫subplots from a pandas data frame, and then you'd find this little parameter here.
‫Only reason I know it is because I've had a little bit of experience plotting subplots from PANDAS data
‫frames.
‫So let's see what this looks like.
‫Might take a little while because we're plotting ten columns or 15 columns thereabouts.
‫Oh, that doesn't look very good, does it?
‫We've got overlapping plots.
‫We've got legends everywhere.
‫We've got these things aren't even to scale, so maybe to fix it up, we'll change the fig size.
‫So what do we want?
‫We want?
‫Width.
‫Height.
‫We want it to be a bit higher.
‫So it stretches.
‫It stretches it out because there's hardly any space here.
‫Okay.
‫That's looking a little bit better, but still.
‫You've got columns like this which are just all clumped up here because what it's doing is it's using
‫the same scale for all of them.
‫But in reality, these all have different measures.
‫That's not very ideal, right?
‫It might work out for some like this one.
‫Cholesterol might work out for that column, but it doesn't work at all for the other ones.
‫Right.
‫So Slope, I'll pick Zang.
‫So what can we do?
‫Well, this code runs, but it's not ideal.
‫And there's different scales, and it's probably a bit too much going on for this plot to even be meaningful.
‫But this is a good Segway, though.
‫Now, we've covered a few simple plots directly on a pandas data frame.
‫Let's have a look at how we'd make some visualizations using the O method.
‫So remember back in a previous video we talked about IO method, which is subplots.
‫Don't worry if it's confusing, we'll have a look in a second.
‫But what we've been using so far is plotting directly from pandas using the stateless method.
‫So in the meantime, I have a practice.
‫Keep using the plot.
‫Make another plot of your own before we come into the next video and I'll see you there.
‫We'll practice using the more flexible object orientated map plot lib API directly with pandas.