Visualizing a dataset by basic plotting
Plots are a great way to visualize a dataset and gauge possible relationships between the columns of a dataset. There are various kinds of plots that can be drawn. For example, a scatter plot, histogram, box-plot, and so on.
Let's import the Customer Churn Model
dataset and try some basic plots:
import pandas as pd data=pd.read_csv('E:/Personal/Learning/Predictive Modeling Book/Book Datasets/Customer Churn Model.txt')
While plotting any kind of plot, it helps to keep these things in mind:
If you are using IPython Notebook, write
% matplotlib inline
in the input cell and run it before plotting to see the output plot inline (in the output cell).To save a plot in your local directory as a file, you can use the
savefig
method. Let's go back to the example where we plotted four scatter plots in a 2x2 panel. The name of this image is specified in the beginning of the snippet, as afigure
parameter of the plot. To save this image one can write the following code...