How to use Seaborn Data Visualization for Machine Learning


Data visualization provides insight into the distribution and relationships between variables in a dataset.
This insight can be helpful in selecting data preparation techniques to apply prior to modeling and the types of algorithms that may be most suited to the data.
Seaborn is a data visualization library for Python that runs on top of the popular Matplotlib data visualization library, although it provides a simple interface and aesthetically better-looking plots.
In this tutorial, you will discover a gentle introduction to Seaborn data visualization for machine learning.
After completing this tutorial, you will know:

How to summarize the distribution of variables using bar charts, histograms, and box and whisker plots.
How to summarize relationships using line plots and scatter plots.
How to compare the distribution and relationships of variables for different class values on the same plot.

Let’s get started.

How to use Seaborn Data Visualization for Machine Learning Photo by Martin Pettitt , some rights reserved.

Tutorial Overview
This tutorial is divided into six parts; they are:

Seaborn Data Visualization Library
Line Plots
Bar Chart Plots
Histogram Plots
Box and Whisker Plots
Scatter Plots

Seaborn Data Visualization Library
The primary plotting library for Python is called Matplotlib .
Seaborn is a plotting library that offers a simpler interface, sensible defaults for plots needed for machine learning, and most importantly, the plots are aesthetically better looking than those in Matplotlib.
Seaborn requires that Matplotlib is installed first.
You can install Matplotlib directly using pip , as follows:
sudo pip install matplotlib
Once installed, you can confirm that the library can be loaded and used by printing the version number, as follows:
# matplotlib
import matplotlib
print('matplotlib: %s' % matplotlib.__version__)
Running the example prints the current version of the Matplotlib library.
matplotlib: 3.1.2
Next, the Seaborn library can be installed, also using pip:
sudo pip install seaborn
Once installed, we can also confirm the library can be loaded and used by printing the version number, as follows:
# seaborn
import seaborn
print('seaborn: %s' % seaborn.__version__)
Running the example prints the current version of the Seaborn library.
seaborn: 0.10.0
To create Seaborn plots, you must import the Seaborn library and call functions to create the plots.
Importantly, Seaborn plotting functions expect data to be provided as Pandas DataFrames . This means that if you are loading your data from CSV files, you must use Pandas functions like read_csv() to load your data as a DataFrame. When plotting,...

Top