Bar graphs

Bar graphs are useful for comparing quantities in different categories. They can be arranged either horizontally or vertically to present the mean estimate and error bands. They can be used to present various statistics of your predictors and how they relate to the target variable.

In our example, we will present the mean and standard deviation for the four variables of the Iris dataset:

In: from sklearn.datasets import load_iris     import numpy as np     import matplotlib.pyplot as plt     iris = load_iris()     average = np.mean(iris.data, axis=0)      std = np.std(iris.data, axis=0)      range_ = range(np.shape(iris.data)[1]) 

In our representation, we will prepare two subplots: one with horizontal bars (plt.barh), and the other with vertical ...

Get Python Data Science Essentials - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.