Code Monkey home page Code Monkey logo

fc-rec-workshop's Introduction

파이썬과 SQL로 배우는 추천시스템 Workshop

1. 실습 환경 구축

1.1 Python 실습 환경 설치

1.2 Jupyter Notebook 설치

1.3 실습 데이터 다운로드

1.4 성능 평가 실습

Movielens 평점 데이터를 기반으로 MAE와 RMSE를 계산하는 실습을 수행합니다. 평점 데이터를 9:1로 학습, 검증 데이터로 나눕니다. 학습 데이터를 이용해서 아래의 세가지 방법을 이용해서 사용자의 영화에 대한 평점을 예측 합니다.

  • 전체 영화의 평균 평점
  • 각 사용자의 영화에 대한 평균 평점
  • 각 영화의 평균 평점

세 가지 방법의 MAE와 RMSE를 계산하고 비교하여 봅니다.

2. Exploiting Explicit Feedback - 평점 예측을 이용한 영화 추천

2.1 Math Background

  • Vector and Matrix 표현
  • 유사도 함수
    • TF-IDF
    • Cosine Similarity
    • Pearson Correlation
  • exercise-2.1.ipynb

2.2 User Profile based CBF 알고리즘을 이용한 영화 로직 구현

  • 아이템 메타데이터를 이용해서 아이템간 유사도를 계산
  • 사용자 프로파일을 사용자 평점을 부여한 아이템 목록으로 표현
  • 아이템 목록에 있는 아이템과 유사한 다른 아이템들을 추천 아이템으로 생성
  • exercise-2.2.ipynb

2.3 Item-based CF 알고리즘을 이용한 영화 추천 로직 구현

  • 평점 분포를 이용한 아이템간 유사도 계산
  • 사용자 프로파일을 사용자 평점을 부여한 아이템 목록으로 표현
  • 아이템 목록에 있는 아이템과 유사한 다른 아이템들을 추천 아이템으로 생성
  • exercise-2.3.ipynb

2.4 User-based CF 알고리즘을 이용한 영화 추천 로직 구현

  • 평점 분포를 이용한 사용자간 유사도 계산
  • 나와 유사한 사용자가 각 아이템에 부여한 평점을 기반으로 평점 추정
  • exercise-2.4.ipynb

3. Exploiting Implicit Feedback - 트랜잭션 데이터 기반 e-commerce 상품 추천

데이터 다운로드 및 Postgresql 생성

3.1 Database Test

  • psycopg2 및 ipython-sql 설치

    pip install psycopg2 pip install ipython-sql

  • Jupyter에서의 DB 데이터 조회

3.2 데이터 로딩 및 확인

3.3 Best Recommendation

  • 조회 기반 베스트
  • 구매 기반 베스트
  • 사이트 전체 베스트
  • 카테고리 별 베스트
  • exercise-3.3.ipynb

3.4 Related Recommendation

  • 사용자 기준 연관 추천
  • 세션 기준 연관 추천
  • 인접 기준 연관 추천
  • exercise-3.4.ipynb

3.3 Personalized Recommendation

4. 고급 추천 시스템

4.1 Regression Model을 이용한 평점 예측 기반 영화 추천 로직 구현

  • 회귀 모델 (regression model)을 이용하여 사용자 프로파일 생성
  • 회귀 모델 프로파일을 이용하여 아이템 평점 예측
  • exercise-4.1.ipynb

4.2 Matrix Factorization

  • SVD를 이용한 유저와 아이템 추상화
  • 추상화된 아이템 간의 유사도 계산
  • exercise-4.2.ipynb

4.3 Weighted Randome Selection

fc-rec-workshop's People

Contributors

zincpark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fc-rec-workshop's Issues

kNN 에서 join 관련 질문입니다.

3.5 거의 맨 아랫부분에서, 중간결과물들을 합쳐서 최종 테이블을 만드는 부분인데요

from (
    -- 앞에서 구한 occurence 에, 인접 세션에 대한 아이템을 붙여준다. (이게 결국 추천이 되어야하는 아이템)
    select
        a.neighbor_session_id,
        a.target_session_id,
        a.target_uid,
        a.neighbor_score,
        b.item_id
    from session_neighbor_occurence a
    inner join session_item_view b on a.neighbor_session_id = b.session_id
)a
left outer join session_item_view b on a.target_session_id = b.session_id and a.item_id = b.item_id
inner join knn_idf c on a.item_id = c.item_id
group by a.target_uid, a.target_session_id, a.item_id

여기서 아래 한 줄에 해당 하는 부분은 쓰이지 않는것 같습니다.

left outer join session_item_view b on a.target_session_id = b.session_id and a.item_id = b.item_id

실제로도 빼고 실행시켜도 결과가 같습니다.

P3 그래프 추천에서 행렬곱 질문입니다.

안녕하세요..
코드를 보다보니 약간 궁금한 부분이 생겼습니다.

commerce의 4.4에서 P3 추천을 하는 부분에서 아래와 같은 코드가 있는데요:

-- Item:User x User:Item 그래프로 Item:Item 그래프 생성
drop table if exists tmp_p3_iter1;

create table tmp_p3_iter1 as
select item_index1, item_index2, prob
from (
   select
      item_index1, item_index2, prob, row_number() over (partition by item_index1 order by prob desc) as rank
   from
      (
        select
            a.item_index as item_index1,
            b.item_index as item_index2,
            sum(a.prob * b.prob) as prob
        from tmp_p3_graph a
        inner join tmp_p3_graph b
        on a.user_index = b.user_index and a.item_index != b.item_index
        group by a.item_index, b.item_index
   ) a
) a
where rank <= 100;

여기서 sum(a.prob * b.prob) as prob 하는 부분이 있는데,
a는 item → user 역할이고
b는 user → item 역할이기 때문에
b에선 user_prob을 가져오는게 맞지 않나요?
a에선 P(user|item)를, b에선 P(item|user)를 담당해주기 때문이라고 생각했습니다.
감사합니다.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.