This is a final project of EN.601.429/629 Functional Programming in Software Engineering in Fall 2022.
An Interactive command-line application built in OCaml for movie recommendation. Use three modes based on the three types of recommendation systems to generate the recommendation list:
-
Demographic Mode
It offers generalized recommendations to every user based on movie popularity, which can be treated as a top list among all movies in our movie library. Users don’t need to input their movie preference list, and every user will get the same ordered list.
-
Content Based Mode
It provides similar movies. First genreate TF-IDF vector for feature
overview
, and counter vector for featureskeywords
,genres
,casts
, anddirector
, and then combine these two vectors to calculate cosine similarity for movie pairs. Users need to input their movie preference list, and will get a similar recommended movie list. -
Collaborative Mode
It provides recommendations based on the rating data. Use biasSVD to predict rating for movies. Users need to input a rating list which contains the movie and corresponding rates.
-
Install python library sklearn (See the official instructions)
$pip3 install -U scikit-learn
-
Ensure that
csv
,yojson
,owl
,sklearn
,inquire
,ppx_deriving
,ounit2
,bisect_ppx
and its dependencies are installed by running:$opam install csv yojson owl sklearn inquire ppx_deriving ounit2 bisect_ppx
-
Build project in the project directory, it will generate an executable file
main.exe
$dune build
Then run the program with the following command
$./_build/default/src/main.exe
Or directly use the following command to build and run the program
$dune exec ./src/main.exe
movie.ml
- The movie data related data typeMovie.t
and functionsrating.ml
- The rating data related data typeRating.t
data_preprocessing.ml
- Parse csv file and load data, callload_movie_data (credits_filename) (movie_filename)
to load movie dataset andload_rating_data (rating_filename)
to load rating datasetutils
- Common used functionsdemographic_mode.ml
- Main logic of demographic mode, callget_recommendations (movie_list:Movie.t) (n:int)
to get recommended movie listcontent_based_mode.ml
- Main logic of demographic mode, callget_recommendations ~(title:string) ~(n:int) ~(movie_list:Movie.t)
to get recommended movie listcollaborative_mode.ml
- Main logic of collaborative mode, callget_recommendations ~(movie_list:Movie.t) ~(rating_list:Rating.t) ~(ur_list:Rating.t) ~(n:int)
to get recommended movie listmain.ml
- Main logic for interactive commend line interface