<jupyter_start><jupyter_text>This notebook is developed using the `Python 3 (Data Science)` kernel on an `ml.t3.medium` instance.<jupyter_code>import os
import sagemaker
sess = sagemaker.Session()
bucket = sess.default_bucket()
prefix = 'sagemaker-studio-book/chapter08'

local_prefix='winequality'
os.makedirs(local_prefix, exist_ok=True)
!wget https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-white.csv -P {local_prefix}
import pandas as pd
from sklearn.model_selection import train_test_split
df = pd.read_csv(f'{local_prefix}/winequality-white.csv', delimiter = ';')
df.head()
df_train, df_test = train_test_split(df, test_size = 0.1, random_state = 42)
df_train.shape, df_test.shape
df_train['quality'].value_counts()
df_train.to_csv(f'{local_prefix}/winequality-white-train.csv', index=False)
df_test.to_csv(f'{local_prefix}/winequality-white-test.csv', index=False)
df_test.drop(columns=['quality']).to_csv(f'{local_prefix}/winequality-white-test-notarget.csv', 
                                         index=False, header=False)
sagemaker.s3.S3Uploader.upload(local_path=f'{local_prefix}/winequality-white-train.csv',
                               desired_s3_uri=f's3://{bucket}/{prefix}/{local_prefix}',
                               sagemaker_session=sess)
sagemaker.s3.S3Uploader.upload(local_path=f'{local_prefix}/winequality-white-test.csv',
                               desired_s3_uri=f's3://{bucket}/{prefix}/{local_prefix}',
                               sagemaker_session=sess)
df_test.drop(columns=['quality']).to_csv(f'{local_prefix}/winequality-white-test-notarget.csv', 
                                         index=False, header=False)
sagemaker.s3.S3Uploader.upload(local_path=f'{local_prefix}/winequality-white-test-notarget.csv',
                               desired_s3_uri=f's3://{bucket}/{prefix}/{local_prefix}',
                               sagemaker_session=sess)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13560182833925852, 'fraction_numerical': 0.01015744032503809, 'mean_word_length': 3.436936936936937, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '295899', 'license': 'MIT', 'n_tokens_mistral': 671, 'n_tokens_neox': 648, 'n_words': 72, 'path': 'chapter08/02-prep_data_for_sm_autopilot.ipynb', 'repo_name': 'PacktPublishing/Getting-Started-with-Amazon-SageMaker-Studio', 'size': '1969'}