<jupyter_start><jupyter_text>Boxplot Normal Distribution Notebook: https://github.com/mGalarnyk/Python_Tutorials/blob/master/Statistics/boxplot/box_plot.ipynb  Boxplot Interpretation Data taken from https://www.kaggle.com/uciml/breast-cancer-wisconsin-data/version/2<jupyter_code># Import all libraries for the rest of the blog post
from scipy.integrate import quad
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

%matplotlib inline<jupyter_output><empty_output><jupyter_text>Load Data<jupyter_code>df = pd.read_csv('https://raw.githubusercontent.com/mGalarnyk/Python_Tutorials/master/Kaggle/BreastCancerWisconsin/data/data.csv')
df.head(1)<jupyter_output><empty_output><jupyter_text>Exploratory Data Analysis<jupyter_code># Looking at the Distribution of the Dataset in terms of Diagnosis
df['diagnosis'].value_counts(dropna = False)<jupyter_output><empty_output><jupyter_text>The section below is so that we can compare test performance with null accuracy<jupyter_code>length = len(df)

# Number of malignant cases
malignant = len(df[df['diagnosis']=='M'])

#Rate of malignant tumors over all cases
rate = (float(malignant)/(length))*100

print('The malignant percentage is: {}%'.format(rate))
print('The benign percentage is: {}%'.format(100 - rate))<jupyter_output>The malignant percentage is: 37.2583479789%
The benign percentage is: 62.7416520211%<jupyter_text>It is also possible to create a scatter matrix with the features. The red dots correspond to malignant diagnosis and blue to benign. Look how in some cases reds and blues dots occupies different regions of the plots. This might not be useful with so many features  Look at Boxplot<jupyter_code>features = set(df.columns)
features.remove('diagnosis')<jupyter_output><empty_output><jupyter_text>Seaborn<jupyter_code>sns.boxplot(x='diagnosis', y='area_mean', data=df)
plt.savefig('seaborn_basic_area_mean_diagnosis.png')<jupyter_output><empty_output><jupyter_text>Matplotlib<jupyter_code>malignant = df[df['diagnosis']=='M']['area_mean']
benign = df[df['diagnosis']=='B']['area_mean']

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

plt.savefig('matplotlib_basic_area_mean_diagnosis.png');<jupyter_output><empty_output><jupyter_text>Pandas<jupyter_code>df.boxplot(column = 'area_mean', by = 'diagnosis');
plt.title('')
plt.savefig('pandas_basic_area_mean_diagnosis.png')<jupyter_output><empty_output><jupyter_text>Nicer Seaborn<jupyter_code>plt.figure(figsize=(5,5))

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

# Changing default seaborn/matplotlib to be more readable
plt.xlabel('diagnosis', fontsize = 24)
plt.ylabel('area_mean', fontsize = 24)
plt.xticks(fontsize = 20)
plt.yticks(fontsize = 20)

plt.savefig('area_mean_diagnosis.png')<jupyter_output><empty_output><jupyter_text>Notched Boxplot<jupyter_code>malignant = df[df['diagnosis']=='M']['area_mean']
benign = df[df['diagnosis']=='B']['area_mean']
fig = plt.figure()
ax = fig.add_subplot(111)
ax.boxplot([malignant,benign], notch = True, labels=['M', 'B']);<jupyter_output><empty_output><jupyter_text>Nicer Notched Boxplot<jupyter_code>malignant = df[df['diagnosis']=='M']['area_mean']
benign = df[df['diagnosis']=='B']['area_mean']

fig = plt.figure(figsize = (8,5))
ax = fig.add_subplot(111)
boxplots = ax.boxplot([malignant,benign],
           notch = True,
           labels=['M', 'B'],
           widths = .7,
           patch_artist=True,
           medianprops = dict(linestyle='-', linewidth=2, color='Yellow'),
           boxprops = dict(linestyle='--', linewidth=2, color='Black', facecolor = 'blue', alpha = .4)
          );

boxplot1 = boxplots['boxes'][0]
boxplot1.set_facecolor('red')

plt.xlabel('diagnosis', fontsize = 20);
plt.ylabel('area_mean', fontsize = 20);
plt.xticks(fontsize = 16);
plt.yticks(fontsize = 16);

plt.savefig('nicer_notchedBoxplot_basic_area_mean_diagnosis.png')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1436839456467036, 'fraction_numerical': 0.017362858580775038, 'mean_word_length': 7.229813664596273, 'pattern_counts': {'":': 0, '<': 44, '<?xml version=': 0, '>': 44, 'https://': 3, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '11', 'dir': 'jupyter-structured-clean-dedup', 'id': '467053', 'license': 'MIT', 'n_tokens_mistral': 1532, 'n_tokens_neox': 1411, 'n_words': 261, 'path': 'Statistics/boxplot/.ipynb_checkpoints/Box_plot_interpretation-checkpoint.ipynb', 'repo_name': 'mrpal39/Python_Tutorials', 'size': '3974'}