The idea behind Content-based cognitive filtering recommendation system is to recommend an item based on a comparison between the content of the items and a user profile. In simple words, I may get recommendation for a movie based on the description of other movies.
- They suggest similar items based on a particular item.
- This system uses item metadata, such as genre, director, description, actors, etc.
- For movies, to make these recommendations.
- The general idea behind these recommender systems is that if a person liked a particular item he or she will also like an item that is similar to it.
- This system matches persons with similar interests and provides recommendations based on this matching.
- Collaborative filters do not require item metadata like its content-based counterparts.
A. Data collection : Tmdb 5000 dataset
B. Data set after cleaning text
C. Recommend function
Cosine similarity
def recommend(movie):
# Fetch the index
movie_index= new_df[new_df['title'] == movie].index[0]
# Fetch the distances
distances = similarity[movie_index]
# Get the 5 similar movies
movies_list= sorted(list(enumerate(distances)),reverse=True,key=lambda x:x[1])[1:6]
# Now print the first indexe's of the top 5 similar movies
for i in movies_list:
print(new_df.iloc[i[0]].title)
- Folder structure
- setup.sh file
‘setup.sh’ specifies the commands to be executed to configure the environment before running the app. In our ‘setup.sh’, we first create a ‘.streamlit’ directory to store the credentials and config files. Then, we specify the e-mail registered with streamlit.io and write it to a ‘credentials.toml’ file. Then, we add the config details to the ‘config.toml’ file. Both these files reside in the ‘.streamlit’ directory.
mkdir -p ~/.streamlit/
echo "\
[general]\n\
email = \"email@domain\"\n\
" > ~/.streamlit/credentials.toml
echo "\
[server]\n\
headless = true\n\
enableCORS=false\n\
port = $PORT\n\
" > ~/.streamlit/config.toml
- Procfile
‘Procfile’ lists the commands to be executed to start the app. In our ‘Procfile’, we’ll first run ‘setup.sh’ that creates the required config files. Then run the app using the ‘streamlit run’ command.
web: sh setup.sh && streamlit run app.py
- Heroku commands
$ heroku login
$ git init
$ heroku git:remote -a mrs-ajay
$ git add .
$ git commit -am "movies recommender"
$ git push heroku master