<jupyter_start><jupyter_text>The Data: [handwritten digits](https://scikit-learn.org/stable/auto_examples/datasets/plot_digits_last_image.html)<jupyter_code>import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import sklearn as sk
from sklearn import linear_model<jupyter_output><empty_output><jupyter_text>Load Data<jupyter_code>from sklearn import datasets
digits = datasets.load_digits()<jupyter_output><empty_output><jupyter_text>Review Data<jupyter_code>digits.data[8]
digits.images[8]
digits.target[8]
#Display the digit
plt.figure(1, figsize=(3, 3))
plt.imshow(digits.images[8], cmap=plt.cm.gray_r, interpolation='nearest')
plt.show()
print("digits.images.shape:", digits.images.shape) # 1797 images in 8x8 matrix representing pixels and locations
print("digits.data.shape:", digits.data.shape) # 1797 images unstacked into 64 columns ... vector
print("digits.target.shape:", digits.target.shape) # 1797 labels for the images
print("digits.target[:50]:", digits.target[:50]) # print first 50 labels<jupyter_output>digits.images.shape: (1797, 8, 8)
digits.data.shape: (1797, 64)
digits.target.shape: (1797,)
digits.target[:50]: [0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 9 5 5 6 5 0
 9 8 9 8 4 1 7 7 3 5 1 0 0]<jupyter_text>Re-categorize as Odd/Even<jupyter_code>digits_df = pd.DataFrame(data=digits.data)
digits_df['target'] = digits.target
digits_df['target_OE'] = digits_df['target'].apply(lambda x : 'Odd' if x%2==1 else ('Even' if x%2==0 else ''))
digits_df['target_OE']
tab = pd.crosstab(index=digits_df["target_OE"], columns='Percentage')
tabp = (100*tab/tab.sum()).rename_axis(None,axis='rows').rename_axis(None,axis='columns')
display(tabp)
plt.figure(figsize=(20,10))
for row in digits_df.head(10).itertuples():  
  pos = ((row.Index%2)*5)+1 + abs((row.Index%2)-1)*(row.Index/2) + (row.Index%2)*((row.Index-1)/2) # 1/5:even/odd + even_increment + odd_increment 
  plt.subplot(2, 5, pos)
  if pos == 1: plt.ylabel('Even Numbers', fontsize = 30)
  if pos == 6: plt.ylabel('Odd Numbers', fontsize = 30)
  plt.imshow(np.reshape(row[1:65],(8,8)), cmap=plt.cm.gray)
  plt.title('Training: %i\n' % row.target, fontsize = 20)<jupyter_output><empty_output><jupyter_text>Describe Data<jupyter_code>digits_df.describe()
digits_df.groupby('target_OE').agg(['median'])
digits_df.iloc[:,:64].corr(method='pearson')
digits_df.iloc[:,:64].corr(method='pearson').style.background_gradient(cmap='coolwarm')
digits_df.iloc[:,np.r_[-1,0:8]].groupby('target_OE').corr(method='pearson').style.background_gradient(cmap='coolwarm')
f=plt.figure(figsize=(9,9))
plt.matshow(digits_df.iloc[:,np.r_[-1,0:8]].groupby('target_OE').corr(method='pearson'),fignum=f.number)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17400881057268722, 'fraction_numerical': 0.05433186490455213, 'mean_word_length': 6.921511627906977, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '152939', 'license': 'MIT', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1065, 'n_words': 200, 'path': '03_Data_Review.ipynb', 'repo_name': 'statmike/Logistic-Regression', 'size': '2724'}