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(, axis=0)      std = np.std(, axis=0)      range_ = range(np.shape([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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.