Skip to content
This repository was archived by the owner on Nov 23, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
7 changes: 7 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ExpandedNodes": [
""
],
"SelectedNode": "\\edsa_recommender.py",
"PreviewInSolutionExplorer": false
}
Binary file added .vs/slnx.sqlite
Binary file not shown.
Binary file not shown.
274 changes: 162 additions & 112 deletions edsa_recommender.py
Original file line number Diff line number Diff line change
@@ -1,112 +1,162 @@
"""

Streamlit webserver-based Recommender Engine.

Author: Explore Data Science Academy.

Note:
---------------------------------------------------------------------
Please follow the instructions provided within the README.md file
located within the root of this repository for guidance on how to use
this script correctly.

NB: !! Do not remove/modify the code delimited by dashes !!

This application is intended to be partly marked in an automated manner.
Altering delimited code may result in a mark of 0.
---------------------------------------------------------------------

Description: This file is used to launch a minimal streamlit web
application. You are expected to extend certain aspects of this script
and its dependencies as part of your predict project.

For further help with the Streamlit framework, see:

https://docs.streamlit.io/en/latest/

"""
# Streamlit dependencies
import streamlit as st

# Data handling dependencies
import pandas as pd
import numpy as np

# Custom Libraries
from utils.data_loader import load_movie_titles
from recommenders.collaborative_based import collab_model
from recommenders.content_based import content_model

# Data Loading
title_list = load_movie_titles('resources/data/movies.csv')

# App declaration
def main():

# DO NOT REMOVE the 'Recommender System' option below, however,
# you are welcome to add more options to enrich your app.
page_options = ["Recommender System","Solution Overview"]

# -------------------------------------------------------------------
# ----------- !! THIS CODE MUST NOT BE ALTERED !! -------------------
# -------------------------------------------------------------------
page_selection = st.sidebar.selectbox("Choose Option", page_options)
if page_selection == "Recommender System":
# Header contents
st.write('# Movie Recommender Engine')
st.write('### EXPLORE Data Science Academy Unsupervised Predict')
st.image('resources/imgs/Image_header.png',use_column_width=True)
# Recommender System algorithm selection
sys = st.radio("Select an algorithm",
('Content Based Filtering',
'Collaborative Based Filtering'))

# User-based preferences
st.write('### Enter Your Three Favorite Movies')
movie_1 = st.selectbox('Fisrt Option',title_list[14930:15200])
movie_2 = st.selectbox('Second Option',title_list[25055:25255])
movie_3 = st.selectbox('Third Option',title_list[21100:21200])
fav_movies = [movie_1,movie_2,movie_3]

# Perform top-10 movie recommendation generation
if sys == 'Content Based Filtering':
if st.button("Recommend"):
try:
with st.spinner('Crunching the numbers...'):
top_recommendations = content_model(movie_list=fav_movies,
top_n=10)
st.title("We think you'll like:")
for i,j in enumerate(top_recommendations):
st.subheader(str(i+1)+'. '+j)
except:
st.error("Oops! Looks like this algorithm does't work.\
We'll need to fix it!")


if sys == 'Collaborative Based Filtering':
if st.button("Recommend"):
try:
with st.spinner('Crunching the numbers...'):
top_recommendations = collab_model(movie_list=fav_movies,
top_n=10)
st.title("We think you'll like:")
for i,j in enumerate(top_recommendations):
st.subheader(str(i+1)+'. '+j)
except:
st.error("Oops! Looks like this algorithm does't work.\
We'll need to fix it!")


# -------------------------------------------------------------------

# ------------- SAFE FOR ALTERING/EXTENSION -------------------
if page_selection == "Solution Overview":
st.title("Solution Overview")
st.write("Describe your winning approach on this page")

# You may want to add more sections here for aspects such as an EDA,
# or to provide your business pitch.


if __name__ == '__main__':
main()
"""

Streamlit webserver-based Recommender Engine.

Author: Explore Data Science Academy.

Note:
---------------------------------------------------------------------
Please follow the instructions provided within the README.md file
located within the root of this repository for guidance on how to use
this script correctly.

NB: !! Do not remove/modify the code delimited by dashes !!

This application is intended to be partly marked in an automated manner.
Altering delimited code may result in a mark of 0.
---------------------------------------------------------------------

Description: This file is used to launch a minimal streamlit web
application. You are expected to extend certain aspects of this script
and its dependencies as part of your predict project.

For further help with the Streamlit framework, see:

https://docs.streamlit.io/en/latest/

"""
# Streamlit dependencies
import streamlit as st

# Data handling dependencies
import pandas as pd
import numpy as np

# Custom Libraries
from utils.data_loader import load_movie_titles
from recommenders.collaborative_based import collab_model
from recommenders.content_based import content_model

# Data Loading
title_list = load_movie_titles('resources/data/movies.csv')

# App declaration
def main():

# DO NOT REMOVE the 'Recommender System' option below, however,
# you are welcome to add more options to enrich your app.
page_options = ["Recommender System","Solution Overview","Business Proposal", "About Us" ,"Contact Us"]

# -------------------------------------------------------------------
# ----------- !! THIS CODE MUST NOT BE ALTERED !! -------------------
# -------------------------------------------------------------------
page_selection = st.sidebar.selectbox("Menu", page_options)
if page_selection == "Recommender System":
# Header contents
st.write('# Movie Recommender Engine')
st.write('### Videoligy')
st.image('resources/imgs/Image_header.png',use_column_width=True)
# Recommender System algorithm selection
sys = st.radio("Select an algorithm",
('Content Based Filtering',
'Collaborative Based Filtering'))

# User-based preferences
st.write('### Enter Your Three Favorite Movies')
movie_1 = st.selectbox('Fisrt Option',title_list[14930:15200])
movie_2 = st.selectbox('Second Option',title_list[25055:25255])
movie_3 = st.selectbox('Third Option',title_list[21100:21200])
fav_movies = [movie_1,movie_2,movie_3]

# Perform top-10 movie recommendation generation
if sys == 'Content Based Filtering':
if st.button("Recommend"):
try:
with st.spinner('Crunching the numbers...'):
top_recommendations = content_model(movie_list=fav_movies,
top_n=10)
st.title("We think you'll like:")
for i,j in enumerate(top_recommendations):
st.subheader(str(i+1)+'. '+j)
except:
st.error("Oops! Looks like this algorithm does't work.\
We'll need to fix it!")


if sys == 'Collaborative Based Filtering':
if st.button("Recommend"):
try:
with st.spinner('Crunching the numbers...'):
top_recommendations = collab_model(movie_list=fav_movies,
top_n=10)
st.title("We think you'll like:")
for i,j in enumerate(top_recommendations):
st.subheader(str(i+1)+'. '+j)
except:
st.error("Oops! Looks like this algorithm does't work.\
We'll need to fix it!")


# -------------------------------------------------------------------

# ------------- SAFE FOR ALTERING/EXTENSION -------------------
if page_selection == "Solution Overview":
st.title("Solution Overview")
st.image('resources/imgs/first.jpg', use_column_width= True)
st.markdown(open('resources/About_solution.md').read())
st.image('resources/imgs/third.jpg', use_column_width= True)
st.markdown(open('resources/About2.md').read())
st.image('resources/imgs/fourth.png', use_column_width= True)
st.markdown(open('resources/About3.md').read())
st.image('resources/imgs/fifth.png', use_column_width= True)
st.markdown(open('resources/About4.md').read())
st.markdown(open('resources/examples.md').read())
st.image('resources/imgs/netflix.jpg', use_column_width= True)
st.markdown(open('resources/benefits.md').read())

if page_selection == "Business Proposal":
st.title("Why our Product")
st.markdown(open("resources/Pages/Business.md").read())


if page_selection == "Contact Us":

#Adding sidebar image
#image = Image.open("resources/LOGOFINAL.png")

with st.form("form1", clear_on_submit=True):
st.subheader("Get in touch with us")
name = st.text_input("Enter full name")
email = st.text_input("Enter email")
message = st.text_area("Message")

submit = st.form_submit_button("Submit Form")
if submit:
st.write("Your form has been submitted and we will be in touch 🙂")



page_bg_img = f"""
<style>
[data-testid="stAppViewContainer"] > .main {{
background-image: url("https://images.unsplash.com/photo-1535303311164-664fc9ec6532?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1887&q=80");
background-size: 100%;
background-position: top;
background-repeat: no-repeat;
background-attachment: scroll;
color: black;
display : flex;
justify-content: centre;
align-items: centr;
}}

[data-testid="stHeader"].main
</style>"""

st.markdown(page_bg_img , unsafe_allow_html=True)
# You may want to add more sections here for aspects such as an EDA,
# or to provide your business pitch.


if __name__ == '__main__':
main()
Loading