LoginSignup
0
0

「Amazon QuickSight で Amazon SageMaker 機械学習予測を視覚化する」のブログ記事の実施時の注意点

Posted at

概要

SageMakerとQuickSigthでの連携ということで、以下のサイトの通り実施してみたが、2023年9月22日時点ではエラーが発生してしまうため、その注意点のメモ。

ブログ記事

実施で使うソースがあるGitHub

修正点

ブログ記事のほうの「ノートブックを実行する」という項で、以下のJupyterファイルを使って実行するが、ところどころエラーになる。

quicksight-sagemaker-integration/customer_churn.ipynb

In 2番目

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import io
import os
import sys
import time
import json
from IPython.display import display
from time import strftime, gmtime
import sagemaker
from sagemaker.predictor import csv_serializer

最後のcsv_serializerは最新のバージョンでは無くなっていてエラーになる。
パッケージ含め変わっているようなので、以下に変更。

from sagemaker.serializers import CSVSerializer

In 3番目

!wget http://dataminingconsultant.com/DKD2e_data_sets.zip
!unzip -o DKD2e_data_sets.zip

シェル実行になるが、wgetで取得しようとしているファイルは、すでに無くなっていて404になる。
イシューでも上がっているが、取得先をその通りに変更する。

!wget https://raw.githubusercontent.com/srepho/srepho.github.io/master/Churn/churn.txt

In 4番目

churn = pd.read_csv('./Data sets/churn.txt')
pd.set_option('display.max_columns', 500)
churn.head()

1つ前の修正で、対象のファイルの配置先のパスが変わっているので変更する。

churn = pd.read_csv('./churn.txt')

In 8番目

from sagemaker.sklearn.estimator import SKLearn
sagemaker_session = sagemaker.Session()
git_config = {'repo': 'https://github.com/aws-samples/quicksight-sagemaker-integration-blog.git','branch': 'master'}

script_path = 'quicksight-sagemaker-integration/preprocessing.py'

sklearn_preprocessor = SKLearn(
    entry_point=script_path,
    git_config=git_config,
    role=role,
    instance_type="local",
    framework_version="0.20.0")
sklearn_preprocessor.fit({'train': s3_input_train})

実行すると docker-compose がインストールされてないとエラーになる。
このコードセルの上に新たなコードセルを追加し、以下を入力・実行して docker-compose をインストールする。
Docker Composeのバージョンはv2.18.1なら実行可能だった、それ以上上げるとエラーになる。
多分すでに入っているDockerのバージョンが、20.10.23だったので、それとの兼ね合いだと思われる。

!sudo curl -SL https://github.com/docker/compose/releases/download/v2.18.1/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
!sudo chmod +x /usr/local/bin/docker-compose
!docker compose version

あとは、そのまま実行していけば、このブログ記事通りに、Sage Makerにあるモデルを使って、
QuickSightでデータセットとモデルを連携させて、可視化を行うことができる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0