Amazon SageMaker là một nền tảng machine learning toàn diện cho phép bạn xây dựng, đào tạo và triển khai các mô hình machine learning trong AWS. Đây là một dịch vụ có tính mô-đun cao cho phép bạn sử dụng từng thành phần này một cách độc lập với nhau.
Ở bài này, chúng ta sẽ thực hành:

Truy cập Amazon Sagemaker, Tại Notebook instances chọn Create notebook instance

Nhập các thông tin sau:



Chọn Create notebook instance

Đợi Trạng thái của note book thành InService. Chọn Open Jupyter

Mở notebook interface

Tại Jupyter notebook tab, Chọn New và chọn conda_python3

Cài đặt PyAthena
!pip install PyAthena[SQLAlchemy]

!aws configure get region
Chạy đoạn code sau trong note book:
from sqlalchemy import create_engine
import pandas as pd
s3_staging_dir = "s3://dmslab-student-dmslabs3bucket-xxx/athenaquery/"
connection_string = f"awsathena+rest://:@athena.us-east-1.amazonaws.com:443/ticketdata?s3_staging_dir={s3_staging_dir}"
engine = create_engine(connection_string)
df = pd.read_sql('SELECT * FROM "ticketdata"."nfl_stadium_data" order by stadium limit 10;', engine)
df

df = pd.read_sql('SELECT sport, \
event_date_time, \
home_team,away_team, \
city, \
count(*) as tickets, \
sum(ticket_price) as total_tickets_amt, \
avg(ticket_price) as avg_ticket_price, \
max(ticket_price) as max_ticket_price, \
min(ticket_price) as min_ticket_price \
FROM "ticketdata"."sporting_event_ticket_info" \
group by 1,2,3,4,5 \
order by 1,2,3,4,5 limit 1000;', engine)
df

import matplotlib.pyplot as plt
df.plot(x='event_date_time',y='avg_ticket_price')
