Posts

Showing posts with the label Data Visualization

Understanding Correlation Matrix Plot

Image
I’m loving this top down approach. Initially, I started with completing a ML project without clear understanding of how it is working as expected. Once I got the understanding at 10,000 ft level, I’m diving one step deeper to get into the understanding of “how” and “why”. Today I got into the deeper understanding of Correlation Matrix Plot. I have used this plot in my projects before. However I did not know why I’m executing certain code. In this post, I’ll explain what each line of code is doing. For this exercise, I took a new data set “ Breast Cancer Wisconsin (Diagnostic) Data Set ”. This data set has 32 attributes, hence a classic match to understand correlation matrix plot. Before we get into the plot, I need to load the data set. As usual I’ll import necessary libraries and then load the data. Since I have explained these before, I’m not going to repeat and I’ll simply show the code. import numpy as np import pandas as pd from pandas import read _csv # Load dat...

Data Visualization using Pandas - Multivariate Plots

Image
In the previous post, I explained about data visualization specifically Univariate plots. In this post, I’ll describe Multivariate plots. Multivariate plots shows correlation between multiple variables. I have used the same  Pima Indians Diabetes Database . Correlation Matrix Plot Correlation shows how two variables are related for changes. Let’s take an example. I’ve taken the code as it is from  https://machinelearningmastery.com/ . # Correction Matrix Plot import matplotlib.pyplot as plt import pandas import numpy url = "https://raw.githubusercontent.com/jbrownlee/Datasets/master/pima-indians-diabetes.csv" names = ['preg', 'plas', 'pres', 'skin', 'test', 'mass', 'pedi', 'age', 'class'] data = pandas.read_csv(url, names=names) correlations = data.corr() # plot correlation matrix fig = plt.figure() ax = fig.add_subplot(111) cax = ax.matshow(correlations, vmin=-1, vmax=1) fig.colorbar(cax) ticks = numpy.a...

Data Visualization using Pandas - Univariate Plots

Image
Data visualization is an important step in ML. That helps us to understand the data in visual representation. Why does it matter? Because it helps us to understand the distribution of the data, any outliers, and also relationship between multiple attributes. Experts also mention that understanding the distribution helps us in choosing correct algorithm. I cannot comment on this statement as of now, as I do not have enough knowledge on that. When I reach that stage, I’ll definitely share. Pandas library provides methods to plot data in multiple ways. In fact, I did use one of those plots called  Box and Whisker Plots  in my previous examples. However, those plots were used to see the difference between multiple algorithms. In this post, I’ll share how to visualize the data which is an important step much before we apply any ML algorithm. I’ll use the data set which was used for  Binary Classification . The data set is   Pima Indians Diabetes Database  which ...