• Amazon Personalize는 어떻게 동작하는걸까?

    2021. 4. 9. 17:55

    by. 위지원

     

    1. 스택 생성 및 쥬피터 노트북 실행

    아래 페이지에 따라 차근차근 따라하면 큰 무리없이 쥬피터 노트북까지 접근이 가능하다.

    중간에 쥬피터 초기화가 조금 오래걸렸다. 

     

    aws-samples/amazon-personalize-samples

    Notebooks and examples on how to onboard and use various features of Amazon Personalize - aws-samples/amazon-personalize-samples

    github.com

    ❣️TIP. Boto3: AWS SDK ; Software Development Kit의 약자로 특정한 소프트웨어나 플랫폼을 이용해서 소프트웨어를 개발할 때 이를 돕는 개발도구의 집합이다. (https://opentutorials.org/course/608/3089)

     

    2. 데이터 가공 및 S3에 저장

    쥬피터 노트북에 있는대로 그대로 실행만 해주면 다음과같이 원본데이터에서 rating>3 필터를 걸고 rating필드를 없엔 데이터를 S3에 저장한다.

     

    3. 데이터셋 생성: 스키마 및 데이터 그룹 지정

    데이터 셋을 생성하기 위해 데이터의 스키마와 그룹을 생성해야한다. 

     

    (1) 스키마 생성

    여기가 가장 중요한 것 같다. 노트북에도 아래와같이 작성되어있다.  아 이런식으로 해서 column이 달라도 이해할 수 있도록 하는구나.

    A core component of how Personalize understands your data comes from the Schema that is defined below. 

     

    (2) 데이터 그룹 생성

    DataGroup은 사용전에 Active해줘야한다!

    Before we can use the Dataset Group in any items below it must be active
    ❣️TIP. ARN 은 Amazon Resource Number의 약자로 우리가 람다함수를 생성할때 EC2를 생성할때 생성되는 일련번호

     

    (3)  Attach policy to S3 bucket, Create Personalize Role

    버켓에 접근하기 위해 policy 및 Roles 설정

    Amazon Personalize needs to be able to read the content of your S3 bucket that you created earlier.
    Also Amazon Personalize needs the ability to assume Roles in AWS in order to have the permissions to execute certain tasks, 

     

     

    4. Dataset import job 생성 및 active

     

    5. 모델링(솔루션화)

    아래 보면 트레이닝된 모델을 솔루션이라고 부른다고 한다. 또한 recipie는 아직 알고리즘에 트레이닝되지 않은 데이터이다. 

    처음에 레시피로 순간읽어서 왠 레시피..? 영화 데이터가지고 해놓고? 라고생각했다.

    In Amazon Personalize a trained model is called a Solution,
    a recipie is an algorithm that has not been trained on your data yet.

    (1) recepies 선택

    recepies 를 보면 아래와 같이 많은 정보들을 담고있다. 나도 나중에 데이터를 전달할때 아래와같이 자세한 정보를 포함해야겠다고 생각했다.

    {'recipes': [{'name': 'aws-hrnn',
       'recipeArn': 'arn:aws:personalize:::recipe/aws-hrnn',
       'status': 'ACTIVE',
       'creationDateTime': datetime.datetime(2019, 6, 10, 0, 0, tzinfo=tzlocal()),
       'lastUpdatedDateTime': datetime.datetime(2021, 2, 6, 15, 39, 36, 214000, tzinfo=tzlocal())},
      {'name': 'aws-hrnn-coldstart',
       'recipeArn': 'arn:aws:personalize:::recipe/aws-hrnn-coldstart',
       'status': 'ACTIVE',
       'creationDateTime': datetime.datetime(2019, 6, 10, 0, 0, tzinfo=tzlocal()),
       'lastUpdatedDateTime': datetime.datetime(2021, 2, 6, 15, 39, 36, 213000, tzinfo=tzlocal())},
      {'name': 'aws-hrnn-metadata',
       'recipeArn': 'arn:aws:personalize:::recipe/aws-hrnn-metadata',
       'status': 'ACTIVE',
       'creationDateTime': datetime.datetime(2019, 6, 10, 0, 0, tzinfo=tzlocal()),
       'lastUpdatedDateTime': datetime.datetime(2021, 2, 6, 15, 39, 36, 213000, tzinfo=tzlocal())},
      {'name': 'aws-personalized-ranking',
       'recipeArn': 'arn:aws:personalize:::recipe/aws-personalized-ranking',
       'status': 'ACTIVE',
       'creationDateTime': datetime.datetime(2019, 6, 10, 0, 0, tzinfo=tzlocal()),
       'lastUpdatedDateTime': datetime.datetime(2021, 2, 6, 15, 39, 36, 214000, tzinfo=tzlocal())},
      {'name': 'aws-popularity-count',
       'recipeArn': 'arn:aws:personalize:::recipe/aws-popularity-count',
       'status': 'ACTIVE',
       'creationDateTime': datetime.datetime(2019, 6, 10, 0, 0, tzinfo=tzlocal()),
       'lastUpdatedDateTime': datetime.datetime(2021, 2, 6, 15, 39, 36, 214000, tzinfo=tzlocal())},
      {'name': 'aws-sims',
       'recipeArn': 'arn:aws:personalize:::recipe/aws-sims',
       'status': 'ACTIVE',
       'creationDateTime': datetime.datetime(2019, 6, 10, 0, 0, tzinfo=tzlocal()),
       'lastUpdatedDateTime': datetime.datetime(2021, 2, 6, 15, 39, 36, 213000, tzinfo=tzlocal())},
      {'name': 'aws-user-personalization',
       'recipeArn': 'arn:aws:personalize:::recipe/aws-user-personalization',
       'status': 'ACTIVE',
       'creationDateTime': datetime.datetime(2019, 6, 10, 0, 0, tzinfo=tzlocal()),
       'lastUpdatedDateTime': datetime.datetime(2021, 2, 6, 15, 39, 36, 214000, tzinfo=tzlocal())}],
     'ResponseMetadata': {'RequestId': '3f29c672-8e40-4964-94ad-4e1b5d86eb2b',
      'HTTPStatusCode': 200,
      'HTTPHeaders': {'content-type': 'application/x-amz-json-1.1',
       'date': 'Fri, 09 Apr 2021 06:44:13 GMT',
       'x-amzn-requestid': '3f29c672-8e40-4964-94ad-4e1b5d86eb2b',
       'content-length': '1259',
       'connection': 'keep-alive'},
      'RetryAttempts': 0}}

    (2) 솔루션 생성

    솔루션을 생성하고 버전까지 생성한다음 active될때까지 기다리면 된다.

     

    6. 캠페인 생성

    캠페인은 호스팅된 모델 버전이다. 마찬가지로 active될 때까지 기다린다. 

    A campaign is a hosted solution version; 

     

    7.추천 진행 

    이 다음에 Recommendation 받으면 된다.

    대화의 장 💬