How to Read Box and Whisker Plots

Understanding Boxplots

Michael Galarnyk

Different parts of a boxplot

What is a Boxplot?

There are times when mean, median, and mode aren't enough to describe a dataset (taken from here).

Different parts of a boxplot

Boxplot on a Normal Distribution

Comparing of a boxplot of a nearly normal distribution and a probability density part (pdf) for a normal distribution

Probability Density Function

PDF for a Normal Distribution

PDF for a Normal Distribution
          # Import all libraries for this portion of the blog post
from scipy.integrate import quad
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
x = np.linspace(-4, 4, num = 100)
constant = ane.0 / np.sqrt(2*np.pi)
pdf_normal_distribution = abiding * np.exp((-x**2) / 2.0)
fig, ax = plt.subplots(figsize=(10, five));
ax.plot(x, pdf_normal_distribution);
ax.set_ylim(0);
ax.set_title('Normal Distribution', size = twenty);
ax.set_ylabel('Probability Density', size = 20);

          # Brand PDF for the normal distribution a function
def normalProbabilityDensity(ten):
constant = ane.0 / np.sqrt(ii*np.pi)
return(constant * np.exp((-x**2) / two.0) )
# Integrate PDF from -.6745 to .6745
result_50p, _ = quad(normalProbabilityDensity, -.6745, .6745, limit = chiliad)
impress(result_50p)

          # Make a PDF for the normal distribution a function
def normalProbabilityDensity(x):
constant = ane.0 / np.sqrt(2*np.pi)
return(constant * np.exp((-x**2) / 2.0) )
# Integrate PDF from -ii.698 to 2.698
result_99_3p, _ = quad(normalProbabilityDensity,
-ii.698,
2.698,
limit = g)
print(result_99_3p)

Graphing and Interpreting a Boxplot

Costless preview video from the Using Python for Information Visualization grade

Read in the data

          import pandas as pd
import seaborn every bit sns
import matplotlib.pyplot as plt
# Put dataset on my github repo
df = pd.read_csv('https://raw.githubusercontent.com/mGalarnyk/Python_Tutorials/master/Kaggle/BreastCancerWisconsin/data/information.csv')

Graph Boxplot

          sns.boxplot(x='diagnosis', y='area_mean', data=df)        

          malignant = df[df['diagnosis']=='1000']['area_mean']
benign = df[df['diagnosis']=='B']['area_mean']
fig = plt.figure()
ax = fig.add_subplot(111)
ax.boxplot([cancerous,benign], labels=['M', 'B'])

You can brand this a lot prettier with a trivial bit of piece of work
          df.boxplot(column = 'area_mean', by = 'diagnosis');
plt.championship('')

Notched Boxplot

          cancerous = df[df['diagnosis']=='1000']['area_mean']
benign = df[df['diagnosis']=='B']['area_mean']
fig = plt.effigy()
ax = fig.add_subplot(111)
ax.boxplot([cancerous,benign], notch = True, labels=['G', 'B']);

Not the prettiest withal.

Interpreting a Boxplot

Conclusion

scherereccoved.blogspot.com

Source: https://towardsdatascience.com/understanding-boxplots-5e2df7bcbd51

0 Response to "How to Read Box and Whisker Plots"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel