<jupyter_start><jupyter_text>Visualize and upload dataset to Amazon S3  Import packages<jupyter_code>import boto3
import sagemaker
import pandas as pd
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>Create a sagemaker_session<jupyter_code>boto_session = boto3.Session()
sagemaker_boto_client = boto_session.client('sagemaker')

sagemaker_session = sagemaker.session.Session(
    boto_session=boto_session,
    sagemaker_client=sagemaker_boto_client)<jupyter_output><empty_output><jupyter_text>Use the default Amazon S3 bucket for dataset and results<jupyter_code>default_bucket = sagemaker_session.default_bucket()  # Alternatively you can use your custom bucket here.

prefix = 'sagemaker-tutorial'  # use this prefix to store all files pertaining to this workshop.
data_prefix = prefix + '/data'<jupyter_output><empty_output><jupyter_text>Visualize the dataset<jupyter_code>local_data_dir = './data'
df = pd.read_excel('./data/default_of_credit_card.xls', header=1)
df.head()
print(f'Total number of missing values in the data: {df.isnull().sum().sum()}')
# plot the bar graph customer gender
df['SEX'].value_counts(normalize=True).plot.bar()
plt.xticks([0,1], ['Male', 'Female'])
# plot the age distribution
plt.hist(df['AGE'], bins=30)
plt.xlabel('Clients Age Distribution')
df.to_csv('./data/dataset_unchanged.csv', index=False)

response = sagemaker_session.upload_data(f'{local_data_dir}/dataset_unchanged.csv', 
                                         bucket=default_bucket,
                                         key_prefix=data_prefix)
print(response)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.107958050586058, 'fraction_numerical': 0.005552128315854411, 'mean_word_length': 5.46215139442231, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '489708', 'license': 'Apache-2.0', 'n_tokens_mistral': 538, 'n_tokens_neox': 518, 'n_words': 105, 'path': 'notebooks/1_upload_dataset_for_autopilot.ipynb', 'repo_name': 'shashankprasanna/sagemaker-amer-summit-workshop', 'size': '1621'}