Skip to content

Movie Recommendation

Author License Homepage Contributor

Tags: movie, recommendation system

Dataset for Movie Recommendation from MovieLens && OMDB, see this blog post for dataset preparation and ETL process, this blog post for recommendation system with graph database. Download

Data Showcase

Screen Capture

Schema

CREATE TAG person(name string, birthdate string);
CREATE TAG movie(name string);
CREATE TAG genre(name string);
CREATE TAG `user`(user_id string);

CREATE EDGE acted_by();
CREATE EDGE directed_by();
CREATE EDGE with_genre();
CREATE EDGE watched(rate float);
Download DDL

graph TD
  person[person]
  movie[movie]
  genre[genre]
  user[user]

  movie -->|acted_by| person
  movie -->|directed_by| person
  movie -->|with_genre| genre
  user -->|watched| movie

  style person fill:#f9d,stroke:#333,stroke-width:2px;
  style movie fill:#fcc,stroke:#333,stroke-width:2px;
  style genre fill:#cfc,stroke:#333,stroke-width:2px;
  style user fill:#ccf,stroke:#333,stroke-width:2px;

classDiagram
  class person {
      string name
      string birthdate
  }
  class movie {
      string name
  }
  class genre {
      string name
  }
  class user {
      string user_id
  }

  movie --> person : acted_by
  movie --> person : directed_by
  movie --> genre : with_genre
  user --> movie : watched(rate float)

  style person fill:#f9d,stroke:#333,stroke-width:2px;
  style movie fill:#fcc,stroke:#333,stroke-width:2px;
  style genre fill:#cfc,stroke:#333,stroke-width:2px;
  style user fill:#ccf,stroke:#333,stroke-width:2px;

Sample Data

:VID(string) movie.name
1 Cowboy Bebop
3 Shadows in Paradise
4 State of Siege
4 Estado De Sitio
:SRC_VID(string) :DST_VID(string)
1 g_11
1 g_18
1 g_28
1 g_34
:SRC_VID(string) :DST_VID(string)
11 p_1
12 p_7
13 p_24
14 p_39
u_1 5 Seven (a.k.a. Se7en) 807 Mystery,Thriller
u_1 5 Star Wars: Episode IV - A New Hope 11 Action,Adventure,Sci-Fi
u_1 5 Star Wars: Episode IV - A New Hope 10 Action,Adventure,Sci-Fi
u_1 4 Mask, The 832 Action,Comedy,Crime,Fantasy
u_1 3 Mrs. Doubtfire 832 Comedy,Drama
:VID(string) genre.name
g_1 Genre
g_2 Source
g_3 Class
g_3 Style
:SRC_VID(string) :DST_VID(string)
11 p_2
11 p_3
11 p_4
11 p_5
:VID(string) person.name person.birthdate
p_1 George Lucas 1944-05-14
p_2 Mark Hamill 1951-09-25
p_3 Harrison Ford 1942-07-13
p_4 Carrie Fisher 1956-10-21

Download

Download Gephi Lite File

Gephi Lite is an OSS tool for Graph Visualization and In Canvas Graph Exploration and Computational Analysis.

Download this sample Gephi Lite file to visualize the sampled graph data from here.

💡: You can generate gephi file from any graph query with NebulaGraph-Gephi.

Install the Jupyter-NebulaGraph extension, refer to the documentation for more information.

!pip install jupyter-nebulagraph
%load_ext ngql
%ngql --address 127.0.0.1 --port 9669 --user root --password nebula

Create Graph Space and Schema.

%ngql CREATE SPACE movie_recommendation(partition_num=1, replica_factor=1, vid_type=fixed_string(128));
# wait for a while
%ngql USE movie_recommendation;
# DDL with `%%ngql` magic for multi-line execution
%%ngql
CREATE TAG person(name string, birthdate string);
CREATE TAG movie(name string);
CREATE TAG genre(name string);
CREATE TAG `user`(user_id string);

CREATE EDGE acted_by();
CREATE EDGE directed_by();
CREATE EDGE with_genre();
CREATE EDGE watched(rate float);

Refer to jupyter-nebulagraph for more information.

%ng_load --header --source https://github.com/wey-gu/awesome-graph-dataset/raw/main/datasets/movie_recommendation/small/people.csv --tag person --vid 0 --props 1:name,2:birthdate --space movie_recommendation
%ng_load --header --source https://github.com/wey-gu/awesome-graph-dataset/raw/main/datasets/movie_recommendation/small/movies.csv --tag movie --vid 0 --props 1:name --space movie_recommendation
%ng_load --header --source https://github.com/wey-gu/awesome-graph-dataset/raw/main/datasets/movie_recommendation/small/genres.csv --tag genre --vid 0 --props 1:name --space movie_recommendation
%ng_load --source https://github.com/wey-gu/awesome-graph-dataset/raw/main/datasets/movie_recommendation/small/user_watched_movies.csv --tag user --vid 0 --props 0:user_id --space movie_recommendation

%ng_load --source https://github.com/wey-gu/awesome-graph-dataset/raw/main/datasets/movie_recommendation/small/user_watched_movies.csv --edge watched --src 0 --dst 3 --props 1:rate --space movie_recommendation
%ng_load --header --source https://github.com/wey-gu/awesome-graph-dataset/raw/main/datasets/movie_recommendation/small/with_genre.csv --edge with_genre --src 0 --dst 1 --space movie_recommendation
%ng_load --header --source https://github.com/wey-gu/awesome-graph-dataset/raw/main/datasets/movie_recommendation/small/directed_by.csv --edge directed_by --src 0 --dst 1 --space movie_recommendation
%ng_load --header --source https://github.com/wey-gu/awesome-graph-dataset/raw/main/datasets/movie_recommendation/small/acted_by.csv --edge acted_by --src 0 --dst 1 --space movie_recommendation

The Nebula Importer is a tool for importing data from various data sources into NebulaGraph.

We provide a configuration file for the Nebula Importer(version: v3) to import the dataset.

Reference call command, assuming the configuration file is named nebula-importer.yaml in your current directory:

# get the configuration file
# modify the configuration file according to your environment

# ls -l ./data/movie_recommendation/

# ls -l nebula-importer.yaml

# run the importer
docker run --rm -ti \
    -v ${PWD}/data/movie_recommendation/:/data \
    -v ${PWD}/nebula-importer.yaml:/root/importer_v3_config.yaml \
    vesoft/nebula-importer:v3 \
    -c /root/importer_v3_config.yaml