Univariate analysis

We have already discussed univariate, bivariate, and multivariate analysis in Chapter 7, Correlation. Let's revise and see how much you remember. 

The simplest way to visualize the numeric data and their distribution is by using a histogram. Let's plot the histogram here; we start by importing the required matplotlib.pyplot library:

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
%matplotlib inline

Next, we draw the histogram, as shown:

fig = df_wines.hist(bins=15, color='fuchsia', edgecolor='darkmagenta', linewidth=1.0, xlabelsize=10, ylabelsize=10, xrot=45, yrot=0, figsize=(10,9), grid=False)

plt.tight_layout(rect=(0, 0, 1.5, 1.5))

Note that we have used the tight_layout() method to keep the graph combined. 

You can get the list of all matplotlib color codes from the official website, at https://matplotlib.org/examples/color/named_colors.html

The output of the preceding code is given as follows:

Figure 12.12 - Output of the univariate analysis

The preceding screenshot shows each of the variables/columns and their distribution in the combined dataframe. The resulting graph should be self-explanatory by now. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.137.213