<jupyter_start><jupyter_text>Import Statements<jupyter_code>import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
from sklearn.datasets import make_classification
from sklearn.cluster import KMeans<jupyter_output><empty_output><jupyter_text>Creating a Dataset for the Example<jupyter_code>dataset = make_classification(n_samples=100000, n_features=5)
dataset = np.c_[dataset[0], dataset[1]]
df = pd.DataFrame(dataset, columns=['A', 'B', 'C', 'D', 'E', 'Target'])<jupyter_output><empty_output><jupyter_text>Here I use a function built in to Scikit-learn to create a dataset for visualization. It will create a dataset with (in this case) 100,000 rows, and 5 features, and a target feature. I then transfrorm the dataset and instantiate a DataFrame with those values and the Target vector.<jupyter_code>df.describe()<jupyter_output><empty_output><jupyter_text>Some simple plotsI am using Seaborn because it will do most of the work for you in the background.<jupyter_code>fig, ax = plt.subplots(figsize=(10,10))
sns.boxplot(data=df[['A', 'B', 'C', 'D', 'E']])
plt.show()
fig, ax = plt.subplots(figsize=(10,10))
sns.histplot(data=df, x='B')
plt.show()
corr = df.corr()
mask = np.zeros_like(corr)
mask[np.triu_indices_from(mask)] = True
fig, ax = plt.subplots(figsize=(10,10))
sns.heatmap(data=corr, mask=mask, annot=True, cmap='BuPu')
plt.show()<jupyter_output><empty_output><jupyter_text>Due to the correlation between columns, 'A', 'B' and 'E', I am going to plot a multi-variate distribution plot, to have a look and see if a clustering approach might be valuable.<jupyter_code>sns.pairplot(data=df, hue='Target', kind='kde')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12727272727272726, 'fraction_numerical': 0.016422287390029325, 'mean_word_length': 7.241545893719807, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '592255', 'license': 'Apache-2.0', 'n_tokens_mistral': 633, 'n_tokens_neox': 593, 'n_words': 171, 'path': 'presentations/Jupyter Notebooks - 2021-04-28/Lunch and Learn - Example.ipynb', 'repo_name': 'ashlinrichardson/bcgov-python-presentations', 'size': '1705'}