Heatmap
Heatmap is used to visualize data in different colors with varying intensity. Here, we take the example of plotting a correlation matrix as a heatmap. Elements of the correlation matrix indicate the strength of a linear relationship between the two variables, and the matrix contains such values for all combinations of the attributes in the given data. If the data has five attributes, then the correlation matrix will be a 5 x 5 matrix.
Getting ready
We will use wine_quality
dataset for this example also. It has 12 different attributes. We will first get a correlation matrix and then plot it as a heatmap. There is no heatmap function/method as such, hence, we will use same imshow
method that we used to read and display the images.
Import required libraries:
import matplotlib.pyplot as plt import pandas as pd
How to do it...
- Following is the code block that plots heat map of correlation matrix:
# Read the data from a csv file into pandas data frame wine_quality = pd.read_csv('winequality.csv...